]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-4.1-branch.patch
- update from rpm cvs
[packages/rpm.git] / rpm-4.1-branch.patch
1 Index: CHANGES
2 ===================================================================
3 RCS file: rpm/CHANGES,v
4 retrieving revision 1.1130.2.23
5 retrieving revision 1.1130.2.27
6 diff -u -u -r1.1130.2.23 -r1.1130.2.27
7 --- rpm/CHANGES 17 Sep 2002 15:18:23 -0000      1.1130.2.23
8 +++ rpm/CHANGES 6 Nov 2002 17:28:19 -0000       1.1130.2.27
9 @@ -286,6 +286,13 @@
10         - fix: register SIGCHLD handler before forking (#73134).
11         - better diagnostics on failed header parsing.
12         - lclint clean.
13 +       - rpm-4.1 release.
14 +       - fix: make sure that psm->child pid is set before SIGCHLD is handled.
15 +       - fix: use size_t consistently, avoid segfault on ia64.
16 +       - use %%{_lib} for libraries.
17 +       - fix: permit build with --disable-nls (#76258).
18 +       - backport db-4.1.17 changes.
19 +       - add _noDirTokens macro for 6x builds.
20  
21  4.0.3 -> 4.0.4:
22         - solaris: translate i86pc to i386 (#57182).
23 Index: autogen.sh
24 ===================================================================
25 RCS file: rpm/autogen.sh,v
26 retrieving revision 2.39
27 retrieving revision 2.39.2.1
28 diff -u -u -r2.39 -r2.39.2.1
29 --- rpm/autogen.sh      8 Aug 2002 22:20:26 -0000       2.39
30 +++ rpm/autogen.sh      25 Oct 2002 17:31:37 -0000      2.39.2.1
31 @@ -4,13 +4,13 @@
32  export LDFLAGS
33  
34  LTV="libtoolize (GNU libtool) 1.4.2"
35 -ACV="autoconf (GNU Autoconf) 2.53"
36 +ACV="autoconf (GNU Autoconf) 2.54"
37  AMV="automake (GNU automake) 1.6.3"
38  USAGE="
39  This script documents the versions of the tools I'm using to build rpm:
40         libtool-1.4.2
41 -       autoconf-2.53
42 -       automake-1.6.2
43 +       autoconf-2.54
44 +       automake-1.6.3
45  Simply edit this script to change the libtool/autoconf/automake versions
46  checked if you need to, as rpm should build (and has built) with all
47  recent versions of libtool/autoconf/automake.
48 Index: configure.ac
49 ===================================================================
50 RCS file: rpm/configure.ac,v
51 retrieving revision 2.6.2.2
52 retrieving revision 2.6.2.3
53 diff -u -u -r2.6.2.2 -r2.6.2.3
54 --- rpm/configure.ac    22 Aug 2002 19:18:56 -0000      2.6.2.2
55 +++ rpm/configure.ac    9 Oct 2002 19:05:38 -0000       2.6.2.3
56 @@ -1094,6 +1094,7 @@
57  dnl Determine the canonical arch-vendor-os for the build machine
58  case "${build_cpu}" in
59  *86)           RPMCANONARCH=i386 ;;
60 +x86_64*)       RPMCANONARCH=x86_64 ;;
61  alpha*)                RPMCANONARCH=alpha ;;
62  sparc*)                RPMCANONARCH=sparc ;;
63  ia64*)         RPMCANONARCH=ia64 ;;
64 Index: installplatform
65 ===================================================================
66 RCS file: rpm/installplatform,v
67 retrieving revision 2.34
68 retrieving revision 2.34.2.2
69 diff -u -u -r2.34 -r2.34.2.2
70 --- rpm/installplatform 30 Jul 2002 17:07:39 -0000      2.34
71 +++ rpm/installplatform 11 Oct 2002 17:23:27 -0000      2.34.2.2
72 @@ -34,6 +34,7 @@
73    alpha*) SUBSTS='s_alpha_alpha_ s_alpha_alphaev5_ s_alpha_alphaev56_ s_alpha_alphapca56_ s_alpha_alphaev6_ s_alpha_alphaev67_' ;;
74    sparc*) SUBSTS='s_sparc\(64\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
75    powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6]\|$\)_ppc64\1_' ;;
76 +  s390*) SUBSTS='s_s390x_s390_ s_s390\([^x]\|$\)_s390x\1_' ;;
77    *) SUBSTS=y___ ;;
78  esac
79  
80 @@ -60,6 +61,12 @@
81      sparc-linux) MULTILIBNO=1 ;;
82      sparcv9-linux) MULTILIBNO=1 ;;
83      sparc64-linux) ARCH_INSTALL_POST=${pkglibdir}/brp-sparc64-linux; LIB=lib64; MULTILIBNO=2 ;;
84 +    s390-linux) MULTILIBNO=1 ;;
85 +    s390x-linux) LIB=lib64; MULTILIBNO=2 ;;
86 +    ppc-linux) MULTILIBNO=1 ;;
87 +    ppc64-linux) LIB=lib64; MULTILIBNO=2 ;;
88 +    i?86-linux|athlon-linux) MULTILIBNO=1 ;;
89 +    x86_64-linux) LIB=lib64; MULTILIBNO=2 ;;
90    esac
91  
92    if [ -n "$MULTILIBNO" ]; then
93 Index: rpmqv.c
94 ===================================================================
95 RCS file: rpm/rpmqv.c,v
96 retrieving revision 1.98
97 retrieving revision 1.98.2.2
98 diff -u -u -r1.98 -r1.98.2.2
99 --- rpm/rpmqv.c 6 Aug 2002 01:41:46 -0000       1.98
100 +++ rpm/rpmqv.c 6 Nov 2002 17:28:19 -0000       1.98.2.2
101 @@ -271,6 +271,7 @@
102      freeSpecVec = freeSpec;
103      /*@=type@*/
104  
105 +#if defined(ENABLE_NLS)
106      /* set up the correct locale */
107      (void) setlocale(LC_ALL, "" );
108  
109 @@ -279,6 +280,7 @@
110  #endif
111      bindtextdomain(PACKAGE, LOCALEDIR);
112      textdomain(PACKAGE);
113 +#endif
114  
115      rpmSetVerbosity(RPMMESS_NORMAL);   /* XXX silly use by showrc */
116  
117 @@ -614,6 +616,8 @@
118         (void) close(p[1]);
119      }
120         
121 +    _noDirTokens = rpmExpandNumeric("%{?_noDirTokens}");
122 +
123      ts = rpmtsCreate();
124      (void) rpmtsSetRootDir(ts, rpmcliRootDir);
125      switch (bigMode) {
126 Index: beecrypt/base64.c
127 ===================================================================
128 RCS file: rpm/beecrypt/base64.c,v
129 retrieving revision 1.20
130 retrieving revision 1.20.2.1
131 diff -u -u -r1.20 -r1.20.2.1
132 --- rpm/beecrypt/base64.c       2 Jul 2002 23:54:35 -0000       1.20
133 +++ rpm/beecrypt/base64.c       9 Oct 2002 19:05:39 -0000       1.20.2.1
134 @@ -246,7 +246,7 @@
135  
136  /*@-boundswrite@*/
137  /*@-internalglobs -modfilesys @*/
138 -char * b64encode (const void * data, int ns)
139 +char * b64encode (const void * data, size_t ns)
140  {
141      static char b64enc[] =
142         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
143 @@ -275,7 +275,7 @@
144  
145      lc = 0;
146      if (te)
147 -    while (ns) {
148 +    while (ns > 0) {
149  
150  if (_debug)
151  fprintf(stderr, "%7u %02x %02x %02x -> %02x %02x %02x %02x\n",
152 @@ -335,7 +335,7 @@
153  #define CRC24_POLY 0x1864cfbL
154  
155  /*@-boundsread@*/
156 -char * b64crc (const unsigned char * data, int ns)
157 +char * b64crc (const unsigned char * data, size_t ns)
158  {
159      const unsigned char *s = data;
160      uint32 crc = CRC24_INIT;
161 @@ -367,7 +367,7 @@
162  
163  /*@-internalglobs -modfilesys @*/
164  /*@-boundswrite@*/
165 -int b64decode (const char * s, void ** datap, int *lenp)
166 +int b64decode (const char * s, void ** datap, size_t *lenp)
167  {
168      unsigned char b64dec[256];
169      const unsigned char *t;
170 Index: beecrypt/base64.h
171 ===================================================================
172 RCS file: rpm/beecrypt/base64.h,v
173 retrieving revision 1.14
174 retrieving revision 1.14.2.2
175 diff -u -u -r1.14 -r1.14.2.2
176 --- rpm/beecrypt/base64.h       13 May 2002 22:45:31 -0000      1.14
177 +++ rpm/beecrypt/base64.h       6 Nov 2002 17:28:19 -0000       1.14.2.2
178 @@ -68,17 +68,17 @@
179   * @return             (malloc'd) base64 string
180   */
181  BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
182 -char * b64encode (const void * data, int ns)
183 +char * b64encode (const void * data, size_t ns)
184         /*@*/;
185  
186  /**
187   * Encode crc of binary input data into 5 bytes of base64 output.
188   * @param data         binary data
189 - * @param ns           crc of data
190 + * @param ns           no. bytes of binary data
191   * @return             (malloc'd) base64 string
192   */
193  BEECRYPTAPI /*@only@*/ /*@null@*/ /*@unused@*/
194 -char * b64crc (const unsigned char * data, int ns)
195 +char * b64crc (const unsigned char * data, size_t ns)
196         /*@*/;
197  
198  /**
199 @@ -89,7 +89,7 @@
200   * @return             0 on success, 1: s == NULL, 2: bad length, 3: bad char
201   */
202  BEECRYPTAPI /*@unused@*/
203 -int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ int *lenp)
204 +int b64decode (const char * s, /*@out@*/ void ** datap, /*@out@*/ size_t *lenp)
205         /*@modifies *datap, *lenp @*/;
206  
207  /**
208 Index: db3/configure
209 ===================================================================
210 RCS file: rpm/db3/configure,v
211 retrieving revision 1.20
212 retrieving revision 1.20.2.1
213 diff -u -u -r1.20 -r1.20.2.1
214 --- rpm/db3/configure   30 Jul 2002 16:39:09 -0000      1.20
215 +++ rpm/db3/configure   6 Nov 2002 17:28:20 -0000       1.20.2.1
216 @@ -4,10 +4,6 @@
217  
218  rm -f config.cache
219  
220 -# XXX hacks to get db-3.3.4 to configure properly
221 -#ln -sf ../dist $db_dist/../db/dist
222 -#ln -sf ../dist $db_dist
223 -
224  # XXX edit CFLAGS= ... out of invocation args ???
225  ARGS="`echo $* | sed -e 's% [^ ]*CFLAGS=[^ ]*%%' -e 's% -[^-][^ ]*%%g' -e 's%--cache-file=.*$%%'`"
226  
227 @@ -15,18 +11,15 @@
228         --enable-shared --enable-static --enable-rpc \
229         --with-uniquename=_rpmdb --srcdir=$db_dist
230  
231 -# XXX hack to get db-3.3.4 to configure properly
232 -#rm -f $db_dist/../db/dist $db_dist/dist
233 -
234  mv Makefile Makefile.orig
235 -cat Makefile.orig | sed -e 's/ -g$/ -g -O2/' -e '/^install:/c\
236 +cat Makefile.orig | sed -e '/^install[:-]/c\
237  .PHONY: listobjs\
238  listobjs:\
239         @echo $(OBJS) $(C_OBJS) \
240  \
241  distdir install check:\
242  \
243 -db3_install: all install_setip' > Makefile
244 +db4_install: all install_setip' > Makefile
245  
246  mv db.h db.h.orig
247  cat db.h.orig | sed \
248 @@ -36,7 +29,7 @@
249  /*@=incondefs@*/' \
250         -e '/^#define   db_create/i\
251  /*@-declundef -noparams -fcnuse@*/' \
252 -       -e '/^#define db_xa_switch/a\
253 +       -e '/^int txn_commit __P((/a\
254  /*@=declundef =noparams =fcnuse =fielduse =enummemuse =typeuse @*/' > db.h
255  
256  # Generate manifest for rpmdb.
257 Index: lib/formats.c
258 ===================================================================
259 RCS file: rpm/lib/formats.c,v
260 retrieving revision 2.71.2.1
261 retrieving revision 2.71.2.2
262 diff -u -u -r2.71.2.1 -r2.71.2.2
263 --- rpm/lib/formats.c   19 Aug 2002 22:21:20 -0000      2.71.2.1
264 +++ rpm/lib/formats.c   9 Oct 2002 19:05:39 -0000       2.71.2.2
265 @@ -145,7 +145,8 @@
266      char * t;
267      char * val;
268      int atype;
269 -    int lc, ns, nt;
270 +    size_t ns, nt;
271 +    int lc;
272  
273      switch (type) {
274      case RPM_BIN_TYPE:
275 @@ -238,7 +239,7 @@
276         const char * enc;
277         char * t;
278         int lc;
279 -       int nt = ((element + 2) / 3) * 4;
280 +       size_t nt = ((element + 2) / 3) * 4;
281  
282  /*@-boundswrite@*/
283         /*@-globs@*/
284 Index: lib/package.c
285 ===================================================================
286 RCS file: rpm/lib/package.c,v
287 retrieving revision 2.112.2.10
288 retrieving revision 2.112.2.11
289 diff -u -u -r2.112.2.10 -r2.112.2.11
290 --- rpm/lib/package.c   17 Sep 2002 15:18:23 -0000      2.112.2.10
291 +++ rpm/lib/package.c   9 Oct 2002 19:05:39 -0000       2.112.2.11
292 @@ -360,7 +360,7 @@
293      if (uc > 0 && pvlen != uc) {
294         (void) snprintf(buf, sizeof(buf),
295                 _("blob size(%d): BAD, 8 + 16 * il(%d) + dl(%d)\n"),
296 -               uc, il, dl);
297 +               (int)uc, (int)il, (int)dl);
298         goto exit;
299      }
300  
301 @@ -652,7 +652,7 @@
302      memset(block, 0, sizeof(block));
303      if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
304         (void) snprintf(buf, sizeof(buf),
305 -               _("hdr size(%d): BAD, read returned %d\n"), sizeof(block), xx);
306 +               _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
307         goto exit;
308      }
309      if (memcmp(block, header_magic, sizeof(header_magic))) {
310 Index: lib/poptALL.c
311 ===================================================================
312 RCS file: rpm/lib/poptALL.c,v
313 retrieving revision 2.10.2.2
314 retrieving revision 2.10.2.3
315 diff -u -u -r2.10.2.2 -r2.10.2.3
316 --- rpm/lib/poptALL.c   27 Aug 2002 20:42:17 -0000      2.10.2.2
317 +++ rpm/lib/poptALL.c   25 Oct 2002 17:31:37 -0000      2.10.2.3
318 @@ -332,9 +332,12 @@
319      }
320  /*@=globs =mods@*/
321  
322 -#if !defined(__LCLINT__)
323 +#if defined(ENABLE_NLS)
324      (void) setlocale(LC_ALL, "" );
325  
326 +#ifdef __LCLINT__
327 +#define LOCALEDIR      "/usr/share/locale"
328 +#endif
329      (void) bindtextdomain(PACKAGE, LOCALEDIR);
330      (void) textdomain(PACKAGE);
331  #endif
332 Index: lib/psm.c
333 ===================================================================
334 RCS file: rpm/lib/psm.c,v
335 retrieving revision 2.126.2.7
336 retrieving revision 2.126.2.9
337 diff -u -u -r2.126.2.7 -r2.126.2.9
338 --- rpm/lib/psm.c       17 Sep 2002 15:18:23 -0000      2.126.2.7
339 +++ rpm/lib/psm.c       9 Oct 2002 19:05:39 -0000       2.126.2.9
340 @@ -695,15 +695,19 @@
341         (void) sigaddset(&caught, signum);
342         switch (signum) {
343         case SIGCHLD:
344 -       {   int status = 0;
345 -           pid_t reaped = waitpid(0, &status, WNOHANG);
346 -           int i;
347 -
348 -           if (psmtbl.psms)
349 -           for (i = 0; i < psmtbl.npsms; i++) {
350 -               rpmpsm psm = psmtbl.psms[i];
351 -               if (psm->child != reaped)
352 -                   /*@innercontinue@*/ continue;
353 +           while (1) {
354 +               int status = 0;
355 +               pid_t reaped = waitpid(0, &status, WNOHANG);
356 +               int i;
357 +
358 +               if (reaped <= 0)
359 +                   /*@innerbreak@*/ break;
360 +
361 +               if (psmtbl.psms)
362 +               for (i = 0; i < psmtbl.npsms; i++) {
363 +                   rpmpsm psm = psmtbl.psms[i];
364 +                   if (psm->child != reaped)
365 +                       /*@innercontinue@*/ continue;
366  
367  #if _PSM_DEBUG
368  /*@-modfilesys@*/
369 @@ -712,11 +716,12 @@
370  /*@=modfilesys@*/
371  #endif
372  
373 -               psm->reaped = reaped;
374 -               psm->status = status;
375 -               /*@innerbreak@*/ break;
376 +                   psm->reaped = reaped;
377 +                   psm->status = status;
378 +                   /*@innerbreak@*/ break;
379 +               }
380             }
381 -       }   /*@switchbreak@*/ break;
382 +           /*@switchbreak@*/ break;
383         default:
384             /*@switchbreak@*/ break;
385         }
386 @@ -782,26 +787,6 @@
387  }
388  
389  /**
390 - * Fork a new process.
391 - * @param psm          package state machine data
392 - * @return             fork(2) pid
393 - */
394 -static pid_t psmFork(rpmpsm psm)
395 -       /*@globals fileSystem, internalState @*/
396 -       /*@modifies fileSystem, internalState @*/
397 -{
398 -    pid_t pid;
399 -
400 -    if ((pid = fork()) != 0) {
401 -/*@-modfilesys@*/
402 -if (_psm_debug)
403 -fprintf(stderr, "      Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, pid);
404 -/*@=modfilesys@*/
405 -    }
406 -    return pid;
407 -}
408 -
409 -/**
410   * Register a child reaper, then fork a child.
411   * @param psm          package state machine data
412   * @return             fork(2) pid
413 @@ -835,7 +820,6 @@
414         }
415         empty = psmtbl.npsms++;
416      }
417 -    psm->reaped = 0;
418      if (psmtbl.psms)   /* XXX can't happen */
419         psmtbl.psms[empty] = rpmpsmLink(psm, "psmRegister");
420  /*@-modfilesys@*/
421 @@ -844,15 +828,24 @@
422  /*@=modfilesys@*/
423  
424      (void) enableSignal(SIGCHLD);
425 +
426 +    psm->reaped = 0;
427 +    if ((psm->child = fork()) != 0) {
428 +/*@-modfilesys@*/
429 +if (_psm_debug)
430 +fprintf(stderr, "      Fork: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
431 +/*@=modfilesys@*/
432 +    }
433 +
434      (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
435  
436 -    return psmFork(psm);
437 +    return psm->child;
438  }
439  
440  /**
441   * Unregister a child reaper.
442   */
443 -static int psmUnregister(rpmpsm psm, pid_t child)
444 +static int psmWaitUnregister(rpmpsm psm, pid_t child)
445         /*@globals psmtbl, fileSystem, internalState @*/
446         /*@modifies psmtbl, fileSystem, internalState @*/
447  {
448 @@ -862,6 +855,19 @@
449      (void) sigfillset(&newMask);               /* block all signals */
450      (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
451      
452 +    /*@-infloops@*/
453 +    while (psm->reaped != psm->child) {
454 +       (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
455 +       sleep(1);       /* XXX sleep guarantees loop traversal. */
456 +       (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
457 +    }
458 +    /*@=infloops@*/
459 +
460 +/*@-modfilesys@*/
461 +if (_psm_debug)
462 +fprintf(stderr, "      Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
463 +/*@=modfilesys@*/
464 +
465      if (psmtbl.psms)
466      for (i = 0; i < psmtbl.npsms; i++) {
467         if (psmtbl.psms[i] == NULL)
468 @@ -893,25 +899,6 @@
469  }
470  
471  /**
472 - * Return reaped pid safely (i.e. with signals blocked).
473 - * @param psm          package state machine data
474 - * @return             
475 - */
476 -static inline pid_t psmGetReaped(rpmpsm psm)
477 -       /*@globals fileSystem @*/
478 -       /*@modifies fileSystem @*/
479 -{
480 -    sigset_t newMask, oldMask;
481 -    pid_t reaped;
482 -
483 -    (void) sigfillset(&newMask);               /* block all signals */
484 -    (void) sigprocmask(SIG_BLOCK, &newMask, &oldMask);
485 -    reaped = psm->reaped;
486 -    (void) sigprocmask(SIG_SETMASK, &oldMask, NULL);
487 -    return reaped;
488 -}
489 -
490 -/**
491   * Wait for child process to be reaped.
492   * @param psm          package state machine data
493   * @return             
494 @@ -921,15 +908,7 @@
495         /*@modifies psm, fileSystem, internalState @*/
496  {
497      if (psm->reaper) {
498 -       /*@-infloops@*/
499 -       while (psmGetReaped(psm) == 0)
500 -           (void) pause();
501 -       /*@=infloops@*/
502 -/*@-modfilesys@*/
503 -if (_psm_debug)
504 -fprintf(stderr, "      Wait: %p[%d:%d:%d] = %p child %d\n", psmtbl.psms, 0, psmtbl.npsms, psmtbl.nalloced, psm, psm->child);
505 -/*@=modfilesys@*/
506 -       (void) psmUnregister(psm, psm->child);
507 +       (void) psmWaitUnregister(psm, psm->child);
508      } else {
509         do {
510             psm->reaped = waitpid(psm->child, &psm->status, 0);
511 @@ -997,7 +976,6 @@
512      FD_t out;
513      rpmRC rc = RPMRC_OK;
514      const char *n, *v, *r;
515 -    pid_t pid;
516  
517      if (progArgv == NULL && script == NULL)
518         return rc;
519 @@ -1119,8 +1097,7 @@
520      if (out == NULL) return RPMRC_FAIL;        /* XXX can't happen */
521      
522      /*@-branchstate@*/
523 -    pid = psmRegisterFork(psm);
524 -    psm->child = pid;
525 +    (void) psmRegisterFork(psm);
526      if (psm->child == 0) {
527         const char * rootDir;
528         int pipes[2];
529 Index: lib/query.c
530 ===================================================================
531 RCS file: rpm/lib/query.c,v
532 retrieving revision 2.138.2.8
533 retrieving revision 2.138.2.9
534 diff -u -u -r2.138.2.8 -r2.138.2.9
535 --- rpm/lib/query.c     17 Sep 2002 15:18:23 -0000      2.138.2.8
536 +++ rpm/lib/query.c     9 Oct 2002 19:05:39 -0000       2.138.2.9
537 @@ -266,7 +266,7 @@
538  /*@=boundswrite@*/
539  
540         if (qva->qva_flags & QUERY_FOR_DUMPFILES) {
541 -           sprintf(te, "%s %d %d %s 0%o ", fn, fsize, fmtime, fmd5, fmode);
542 +           sprintf(te, "%s %d %d %s 0%o ", fn, (int)fsize, fmtime, fmd5, fmode);
543             te += strlen(te);
544  
545             if (fuser && fgroup) {
546 Index: lib/rpmcli.h
547 ===================================================================
548 RCS file: rpm/lib/rpmcli.h,v
549 retrieving revision 2.47.2.2
550 retrieving revision 2.47.2.3
551 diff -u -u -r2.47.2.2 -r2.47.2.3
552 --- rpm/lib/rpmcli.h    17 Sep 2002 15:18:24 -0000      2.47.2.2
553 +++ rpm/lib/rpmcli.h    9 Oct 2002 19:05:39 -0000       2.47.2.3
554 @@ -557,7 +557,7 @@
555   * @param argv         array of package file names (NULL terminated)
556   * @return             0 on success
557   */
558 -int rpmErase(rpmts ts, const struct rpmInstallArguments_s * ia,
559 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
560                 /*@null@*/ const char ** argv)
561         /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
562         /*@modifies ts, ia, rpmGlobalMacroContext,
563 Index: lib/rpmds.h
564 ===================================================================
565 RCS file: rpm/lib/rpmds.h,v
566 retrieving revision 2.36
567 retrieving revision 2.36.2.1
568 diff -u -u -r2.36 -r2.36.2.1
569 --- rpm/lib/rpmds.h     3 Aug 2002 22:31:39 -0000       2.36
570 +++ rpm/lib/rpmds.h     6 Nov 2002 17:28:20 -0000       2.36.2.1
571 @@ -232,6 +232,7 @@
572  /**
573   * Set "Don't promote Epoch:" flag.
574   * @param ds           dependency set
575 + * @param nopromote    Should an unspecified Epoch: be treated as Epoch: 0?
576   * @return             previous "Don't promote Epoch:" flag
577   */
578  int rpmdsSetNoPromote(/*@null@*/ rpmds ds, int nopromote)
579 Index: lib/rpminstall.c
580 ===================================================================
581 RCS file: rpm/lib/rpminstall.c,v
582 retrieving revision 1.118.2.5
583 retrieving revision 1.118.2.6
584 diff -u -u -r1.118.2.5 -r1.118.2.6
585 --- rpm/lib/rpminstall.c        31 Aug 2002 22:30:22 -0000      1.118.2.5
586 +++ rpm/lib/rpminstall.c        9 Oct 2002 19:05:39 -0000       1.118.2.6
587 @@ -723,8 +723,7 @@
588  }
589  /*@=bounds@*/
590  
591 -int rpmErase(rpmts ts,
592 -               const struct rpmInstallArguments_s * ia,
593 +int rpmErase(rpmts ts, struct rpmInstallArguments_s * ia,
594                 const char ** argv)
595  {
596      int count;
597 Index: lib/signature.c
598 ===================================================================
599 RCS file: rpm/lib/signature.c,v
600 retrieving revision 2.139.2.7
601 retrieving revision 2.139.2.8
602 diff -u -u -r2.139.2.7 -r2.139.2.8
603 --- rpm/lib/signature.c 17 Sep 2002 15:18:24 -0000      2.139.2.7
604 +++ rpm/lib/signature.c 9 Oct 2002 19:05:39 -0000       2.139.2.8
605 @@ -178,7 +178,7 @@
606      memset(block, 0, sizeof(block));
607      if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) {
608         (void) snprintf(buf, sizeof(buf),
609 -               _("sigh size(%d): BAD, read returned %d\n"), sizeof(block), xx);
610 +               _("sigh size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx);
611         goto exit;
612      }
613      if (memcmp(block, header_magic, sizeof(header_magic))) {
614 @@ -215,7 +215,7 @@
615      dataStart = (unsigned char *) (pe + il);
616      if ((xx = timedRead(fd, (char *)pe, nb)) != nb) {
617         (void) snprintf(buf, sizeof(buf),
618 -               _("sigh blob(%d): BAD, read returned %d\n"), nb, xx);
619 +               _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx);
620         goto exit;
621      }
622      
623 @@ -985,11 +985,11 @@
624      if (size != dig->nbytes) {
625         res = RPMRC_FAIL;
626         t = stpcpy(t, rpmSigString(res));
627 -       sprintf(t, " Expected(%d) != (%d)\n", size, dig->nbytes);
628 +       sprintf(t, " Expected(%d) != (%d)\n", (int)size, (int)dig->nbytes);
629      } else {
630         res = RPMRC_OK;
631         t = stpcpy(t, rpmSigString(res));
632 -       sprintf(t, " (%d)", dig->nbytes);
633 +       sprintf(t, " (%d)", (int)dig->nbytes);
634      }
635  
636  exit:
637 Index: lib/transaction.c
638 ===================================================================
639 RCS file: rpm/lib/transaction.c,v
640 retrieving revision 1.274.2.6
641 retrieving revision 1.274.2.7
642 diff -u -u -r1.274.2.6 -r1.274.2.7
643 --- rpm/lib/transaction.c       31 Aug 2002 22:30:22 -0000      1.274.2.6
644 +++ rpm/lib/transaction.c       25 Oct 2002 17:31:38 -0000      1.274.2.7
645 @@ -1018,7 +1018,7 @@
646       * - count files.
647       */
648  
649 -rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elments\n"), rpmtsNElements(ts));
650 +rpmMessage(RPMMESS_DEBUG, _("sanity checking %d elements\n"), rpmtsNElements(ts));
651      ps = rpmtsProblems(ts);
652      /* The ordering doesn't matter here */
653      pi = rpmtsiInit(ts);
654 Index: python/_rpmdb.c
655 ===================================================================
656 RCS file: rpm/python/_rpmdb.c,v
657 retrieving revision 1.4
658 retrieving revision 1.4.2.1
659 diff -u -u -r1.4 -r1.4.2.1
660 --- rpm/python/_rpmdb.c 7 Jun 2002 13:12:34 -0000       1.4
661 +++ rpm/python/_rpmdb.c 6 Nov 2002 16:47:02 -0000       1.4.2.1
662 @@ -90,9 +90,9 @@
663  /* 40 = 4.0, 33 = 3.3; this will break if the second number is > 9 */
664  #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR)
665  
666 -#define PY_BSDDB_VERSION "3.3.1"
667 +#define PY_BSDDB_VERSION "3.4.2"
668  
669 -static char *rcs_id = "$Id$";
670 +static char *rcs_id = "$Id$";
671  
672  
673  #ifdef WITH_THREAD
674 @@ -410,6 +410,7 @@
675      switch (err) {
676          case 0:                     /* successful, no error */      break;
677  
678 +#if (DBVER < 41)
679          case DB_INCOMPLETE:
680  #if INCOMPLETE_IS_WARNING
681              strcpy(errTxt, db_strerror(err));
682 @@ -429,6 +430,7 @@
683          errObj = DBIncompleteError;
684  #endif
685          break;
686 +#endif
687  
688          case DB_KEYEMPTY:           errObj = DBKeyEmptyError;       break;
689          case DB_KEYEXIST:           errObj = DBKeyExistError;       break;
690 @@ -1023,12 +1025,29 @@
691      secondaryDB->associateCallback = callback;
692      secondaryDB->primaryDBType = _DB_get_type(self);
693  
694 -
695 +    /* PyEval_InitThreads is called here due to a quirk in python 1.5
696 +     * - 2.2.1 (at least) according to Russell Williamson <merel@wt.net>:
697 +     * The global interepreter lock is not initialized until the first
698 +     * thread is created using thread.start_new_thread() or fork() is
699 +     * called.  that would cause the ALLOW_THREADS here to segfault due
700 +     * to a null pointer reference if no threads or child processes
701 +     * have been created.  This works around that and is a no-op if
702 +     * threads have already been initialized.
703 +     *  (see pybsddb-users mailing list post on 2002-08-07)
704 +     */
705 +    PyEval_InitThreads();
706      MYDB_BEGIN_ALLOW_THREADS;
707 +#if (DBVER >= 41)
708 +    err = self->db->associate(self->db, NULL,
709 +                              secondaryDB->db,
710 +                              _db_associateCallback,
711 +                              flags);
712 +#else
713      err = self->db->associate(self->db,
714                                secondaryDB->db,
715                                _db_associateCallback,
716                                flags);
717 +#endif
718      MYDB_END_ALLOW_THREADS;
719  
720      if (err) {
721 @@ -1498,7 +1517,11 @@
722      }
723  
724      MYDB_BEGIN_ALLOW_THREADS;
725 +#if (DBVER >= 41)
726 +    err = self->db->open(self->db, NULL, filename, dbname, type, flags, mode);
727 +#else
728      err = self->db->open(self->db, filename, dbname, type, flags, mode);
729 +#endif
730      MYDB_END_ALLOW_THREADS;
731      if (makeDBError(err)) {
732          self->db = NULL;
733 @@ -1851,7 +1874,9 @@
734          MAKE_HASH_ENTRY(nkeys);
735          MAKE_HASH_ENTRY(ndata);
736          MAKE_HASH_ENTRY(pagesize);
737 +#if (DBVER < 41)
738          MAKE_HASH_ENTRY(nelem);
739 +#endif
740          MAKE_HASH_ENTRY(ffactor);
741          MAKE_HASH_ENTRY(buckets);
742          MAKE_HASH_ENTRY(free);
743 @@ -1896,7 +1921,7 @@
744          MAKE_QUEUE_ENTRY(re_len);
745          MAKE_QUEUE_ENTRY(re_pad);
746          MAKE_QUEUE_ENTRY(pgfree);
747 -#if (DBVER >= 31) && (DBVER < 40)
748 +#if (DBVER == 31)
749          MAKE_QUEUE_ENTRY(start);
750  #endif
751          MAKE_QUEUE_ENTRY(first_recno);
752 @@ -2334,8 +2359,6 @@
753      if (!PyArg_ParseTuple(args, ":close"))
754          return NULL;
755  
756 -    CHECK_CURSOR_NOT_CLOSED(self);
757 -
758      if (self->dbc != NULL) {
759          MYDB_BEGIN_ALLOW_THREADS;
760          err = self->dbc->c_close(self->dbc);
761 @@ -2424,7 +2447,7 @@
762  static PyObject*
763  DBC_get(DBCursorObject* self, PyObject* args, PyObject *kwargs)
764  {
765 -    int err, flags;
766 +    int err, flags=0;
767      PyObject* keyobj = NULL;
768      PyObject* dataobj = NULL;
769      PyObject* retval = NULL;
770 @@ -3309,7 +3332,7 @@
771      int err;
772      DB_LOCK_STAT* sp;
773      PyObject* d = NULL;
774 -    u_int32_t flags;
775 +    u_int32_t flags = 0;
776  
777      if (!PyArg_ParseTuple(args, "|i:lock_stat", &flags))
778          return NULL;
779 @@ -3337,7 +3360,9 @@
780  
781  #define MAKE_ENTRY(name)  _addIntToDict(d, #name, sp->st_##name)
782  
783 +#if (DBVER < 41)
784      MAKE_ENTRY(lastid);
785 +#endif
786      MAKE_ENTRY(nmodes);
787  #if (DBVER >= 32)
788      MAKE_ENTRY(maxlocks);
789 @@ -3421,7 +3446,7 @@
790      int err;
791      DB_TXN_STAT* sp;
792      PyObject* d = NULL;
793 -    u_int32_t flags;
794 +    u_int32_t flags=0;
795  
796      if (!PyArg_ParseTuple(args, "|i:txn_stat", &flags))
797          return NULL;
798 @@ -4116,7 +4141,9 @@
799      ADD_INT(d, DB_APPEND);
800      ADD_INT(d, DB_BEFORE);
801      ADD_INT(d, DB_CACHED_COUNTS);
802 +#if (DBVER < 41)
803      ADD_INT(d, DB_CHECKPOINT);
804 +#endif
805  #if (DBVER >= 33)
806      ADD_INT(d, DB_COMMIT);
807  #endif
808 @@ -4124,7 +4151,9 @@
809  #if (DBVER >= 32)
810      ADD_INT(d, DB_CONSUME_WAIT);
811  #endif
812 +#if (DBVER < 41)
813      ADD_INT(d, DB_CURLSN);
814 +#endif
815      ADD_INT(d, DB_CURRENT);
816  #if (DBVER >= 33)
817      ADD_INT(d, DB_FAST_STAT);
818 @@ -4164,7 +4193,9 @@
819      ADD_INT(d, DB_DONOTINDEX);
820  #endif
821  
822 +#if (DBVER < 41)
823      ADD_INT(d, DB_INCOMPLETE);
824 +#endif
825      ADD_INT(d, DB_KEYEMPTY);
826      ADD_INT(d, DB_KEYEXIST);
827      ADD_INT(d, DB_LOCK_DEADLOCK);
828 Index: python/header-py.c
829 ===================================================================
830 RCS file: rpm/python/header-py.c,v
831 retrieving revision 1.20
832 retrieving revision 1.20.2.1
833 diff -u -u -r1.20 -r1.20.2.1
834 --- rpm/python/header-py.c      7 Aug 2002 23:19:10 -0000       1.20
835 +++ rpm/python/header-py.c      15 Oct 2002 19:03:22 -0000      1.20.2.1
836 @@ -336,6 +336,11 @@
837      return rpmVersionCompare(a->h, b->h);
838  }
839  
840 +static long hdr_hash(hdrObject *h)
841 +{
842 +    return h;
843 +}
844 +
845  /** \ingroup python
846   */
847  /*@unchecked@*/ /*@observer@*/
848 @@ -594,7 +599,7 @@
849         0,                              /* tp_as_number */
850         0,                              /* tp_as_sequence */
851         &hdr_as_mapping,                /* tp_as_mapping */
852 -       0,                              /* tp_hash */
853 +       hdr_hash,                       /* tp_hash */
854         0,                              /* tp_call */
855         0,                              /* tp_str */
856         0,                              /* tp_getattro */
857 Index: python/rpmdb/__init__.py
858 ===================================================================
859 RCS file: rpm/python/rpmdb/__init__.py,v
860 retrieving revision 1.2
861 retrieving revision 1.2.2.1
862 diff -u -u -r1.2 -r1.2.2.1
863 --- rpm/python/rpmdb/__init__.py        3 Jun 2002 20:44:08 -0000       1.2
864 +++ rpm/python/rpmdb/__init__.py        6 Nov 2002 16:47:02 -0000       1.2.2.1
865 @@ -152,7 +152,7 @@
866      flags = _checkflag(flag)
867      d = _db.DB()
868      d.set_flags(hflags)
869 -    if cachesize is not None: d.set_cachesize(cachesize)
870 +    if cachesize is not None: d.set_cachesize(0, cachesize)
871      if pgsize is not None:    d.set_pagesize(pgsize)
872      if lorder is not None:    d.set_lorder(lorder)
873      if ffactor is not None:   d.set_h_ffactor(ffactor)
874 @@ -168,7 +168,7 @@
875  
876      flags = _checkflag(flag)
877      d = _db.DB()
878 -    if cachesize is not None: d.set_cachesize(cachesize)
879 +    if cachesize is not None: d.set_cachesize(0, cachesize)
880      if pgsize is not None: d.set_pagesize(pgsize)
881      if lorder is not None: d.set_lorder(lorder)
882      d.set_flags(btflags)
883 @@ -186,7 +186,7 @@
884  
885      flags = _checkflag(flag)
886      d = _db.DB()
887 -    if cachesize is not None: d.set_cachesize(cachesize)
888 +    if cachesize is not None: d.set_cachesize(0, cachesize)
889      if pgsize is not None: d.set_pagesize(pgsize)
890      if lorder is not None: d.set_lorder(lorder)
891      d.set_flags(rnflags)
892 Index: python/rpmdb/dbshelve.py
893 ===================================================================
894 RCS file: rpm/python/rpmdb/dbshelve.py,v
895 retrieving revision 1.2
896 retrieving revision 1.2.2.1
897 diff -u -u -r1.2 -r1.2.2.1
898 --- rpm/python/rpmdb/dbshelve.py        5 Jun 2002 20:28:03 -0000       1.2
899 +++ rpm/python/rpmdb/dbshelve.py        6 Nov 2002 16:47:02 -0000       1.2.2.1
900 @@ -53,7 +53,7 @@
901      if type(flags) == type(''):
902          sflag = flags
903          if sflag == 'r':
904 -            flags = db.DB_READONLY
905 +            flags = db.DB_RDONLY
906          elif sflag == 'rw':
907              flags = 0
908          elif sflag == 'w':
909 Index: python/rpmdb/dbtables.py
910 ===================================================================
911 RCS file: rpm/python/rpmdb/dbtables.py,v
912 retrieving revision 1.1
913 retrieving revision 1.1.2.1
914 diff -u -u -r1.1 -r1.1.2.1
915 --- rpm/python/rpmdb/dbtables.py        3 Jun 2002 20:44:08 -0000       1.1
916 +++ rpm/python/rpmdb/dbtables.py        6 Nov 2002 16:47:02 -0000       1.1.2.1
917 @@ -1,6 +1,7 @@
918  #-----------------------------------------------------------------------
919  #
920  # Copyright (C) 2000, 2001 by Autonomous Zone Industries
921 +# Copyright (C) 2002 Gregory P. Smith
922  #
923  # License:      This is free software.  You may use this software for any
924  #               purpose including modification/redistribution, so long as
925 @@ -54,6 +55,13 @@
926      def __call__(self, s):
927          return s[:len(self.prefix)] == self.prefix
928  
929 +class PostfixCond(Cond):
930 +    """Acts as a condition function for matching a string postfix"""
931 +    def __init__(self, postfix):
932 +        self.postfix = postfix
933 +    def __call__(self, s):
934 +        return s[-len(self.postfix):] == self.postfix
935 +
936  class LikeCond(Cond):
937      """
938      Acts as a function that will match using an SQL 'LIKE' style
939 @@ -523,17 +531,10 @@
940                          # if no condition was specified or the condition
941                          # succeeds, add row to our match list.
942                          if not condition or condition(data) :
943 -                            # only create new entries in matcing_rowids on
944 -                            # the first pass, otherwise reject the
945 -                            # rowid as it must not have matched
946 -                            # the previous passes
947 -                            if column_num == 0 :
948 -                                if not matching_rowids.has_key(rowid) :
949 -                                    matching_rowids[rowid] = {}
950 -                                if savethiscolumndata :
951 -                                    matching_rowids[rowid][column] = data
952 -                            else :
953 -                                rejected_rowids[rowid] = rowid
954 +                            if not matching_rowids.has_key(rowid) :
955 +                                matching_rowids[rowid] = {}
956 +                            if savethiscolumndata :
957 +                                matching_rowids[rowid][column] = data
958                          else :
959                              if matching_rowids.has_key(rowid) :
960                                  del matching_rowids[rowid]
961 Index: python/rpmdb/dbutils.py
962 ===================================================================
963 RCS file: rpm/python/rpmdb/dbutils.py,v
964 retrieving revision 1.1
965 retrieving revision 1.1.2.1
966 diff -u -u -r1.1 -r1.1.2.1
967 --- rpm/python/rpmdb/dbutils.py 3 Jun 2002 20:44:08 -0000       1.1
968 +++ rpm/python/rpmdb/dbutils.py 6 Nov 2002 16:47:02 -0000       1.1.2.1
969 @@ -1,11 +1,5 @@
970  #------------------------------------------------------------------------
971  #
972 -# In my performance tests, using this (as in dbtest.py test4) is
973 -# slightly slower than simply compiling _db.c with MYDB_THREAD
974 -# undefined to prevent multithreading support in the C module.
975 -# Using NoDeadlockDb also prevent deadlocks from mutliple processes
976 -# accessing the same database.
977 -#
978  # Copyright (C) 2000 Autonomous Zone Industries
979  #
980  # License:      This is free software.  You may use this software for any
981 @@ -18,7 +12,7 @@
982  # Author: Gregory P. Smith <greg@electricrain.com>
983  #
984  # Note: I don't know how useful this is in reality since when a
985 -#       DBDeadlockError happens the current transaction is supposed to be
986 +#       DBLockDeadlockError happens the current transaction is supposed to be
987  #       aborted.  If it doesn't then when the operation is attempted again
988  #       the deadlock is still happening...
989  #       --Robin
990 @@ -36,33 +30,45 @@
991  
992  import _rpmdb as _db
993  
994 -_deadlock_MinSleepTime = 1.0/64  # always sleep at least N seconds between retrys
995 -_deadlock_MaxSleepTime = 1.0     # never sleep more than N seconds between retrys
996 +_deadlock_MinSleepTime = 1.0/64   # always sleep at least N seconds between retrys
997 +_deadlock_MaxSleepTime = 3.14159  # never sleep more than N seconds between retrys
998  
999 +_deadlock_VerboseFile = None      # Assign a file object to this for a "sleeping"
1000 +                                  # message to be written to it each retry
1001  
1002  def DeadlockWrap(function, *_args, **_kwargs):
1003      """DeadlockWrap(function, *_args, **_kwargs) - automatically retries
1004      function in case of a database deadlock.
1005  
1006 -    This is a DeadlockWrapper method which DB calls can be made using to
1007 -    preform infinite retrys with sleeps in between when a DBLockDeadlockError
1008 -    exception is raised in a database call:
1009 +    This is a function intended to be used to wrap database calls such
1010 +    that they perform retrys with exponentially backing off sleeps in
1011 +    between when a DBLockDeadlockError exception is raised.
1012 +
1013 +    A 'max_retries' parameter may optionally be passed to prevent it
1014 +    from retrying forever (in which case the exception will be reraised).
1015  
1016          d = DB(...)
1017          d.open(...)
1018          DeadlockWrap(d.put, "foo", data="bar")  # set key "foo" to "bar"
1019      """
1020      sleeptime = _deadlock_MinSleepTime
1021 -    while (1) :
1022 +    max_retries = _kwargs.get('max_retries', -1)
1023 +    if _kwargs.has_key('max_retries'):
1024 +        del _kwargs['max_retries']
1025 +    while 1:
1026          try:
1027              return apply(function, _args, _kwargs)
1028          except _db.DBLockDeadlockError:
1029 -            print 'DeadlockWrap sleeping ', sleeptime
1030 +            if _deadlock_VerboseFile:
1031 +                _deadlock_VerboseFile.write('dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
1032              _sleep(sleeptime)
1033              # exponential backoff in the sleep time
1034              sleeptime = sleeptime * 2
1035              if sleeptime > _deadlock_MaxSleepTime :
1036                  sleeptime = _deadlock_MaxSleepTime
1037 +            max_retries = max_retries - 1
1038 +            if max_retries == -1:
1039 +                raise
1040  
1041  
1042  #------------------------------------------------------------------------
1043 Index: python/test/test_dbshelve.py
1044 ===================================================================
1045 RCS file: rpm/python/test/test_dbshelve.py,v
1046 retrieving revision 1.1
1047 retrieving revision 1.1.2.1
1048 diff -u -u -r1.1 -r1.1.2.1
1049 --- rpm/python/test/test_dbshelve.py    3 Jun 2002 20:44:08 -0000       1.1
1050 +++ rpm/python/test/test_dbshelve.py    6 Nov 2002 16:47:02 -0000       1.1.2.1
1051 @@ -210,7 +210,7 @@
1052  
1053  
1054  class HashShelveTestCase(BasicShelveTestCase):
1055 -    dbtype = db.DB_BTREE
1056 +    dbtype = db.DB_HASH
1057      dbflags = db.DB_CREATE
1058  
1059  
1060 @@ -220,7 +220,7 @@
1061  
1062  
1063  class ThreadHashShelveTestCase(BasicShelveTestCase):
1064 -    dbtype = db.DB_BTREE
1065 +    dbtype = db.DB_HASH
1066      dbflags = db.DB_CREATE | db.DB_THREAD
1067  
1068  
1069 @@ -261,7 +261,7 @@
1070  
1071  class EnvHashShelveTestCase(BasicEnvShelveTestCase):
1072      envflags = 0
1073 -    dbtype = db.DB_BTREE
1074 +    dbtype = db.DB_HASH
1075      dbflags = db.DB_CREATE
1076  
1077  
1078 @@ -273,7 +273,7 @@
1079  
1080  class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
1081      envflags = db.DB_THREAD
1082 -    dbtype = db.DB_BTREE
1083 +    dbtype = db.DB_HASH
1084      dbflags = db.DB_CREATE | db.DB_THREAD
1085  
1086  
1087 Index: python/test/test_dbtables.py
1088 ===================================================================
1089 RCS file: rpm/python/test/test_dbtables.py,v
1090 retrieving revision 1.1
1091 retrieving revision 1.1.2.1
1092 diff -u -u -r1.1 -r1.1.2.1
1093 --- rpm/python/test/test_dbtables.py    3 Jun 2002 20:44:08 -0000       1.1
1094 +++ rpm/python/test/test_dbtables.py    6 Nov 2002 16:47:02 -0000       1.1.2.1
1095 @@ -5,6 +5,7 @@
1096  #-----------------------------------------------------------------------
1097  #
1098  # Copyright (C) 2000, 2001 by Autonomous Zone Industries
1099 +# Copyright (C) 2002 Gregory P. Smith
1100  #
1101  # March 20, 2000
1102  #
1103 @@ -157,6 +158,40 @@
1104              conditions={'c': lambda c: c == 'meep'})
1105          assert len(values) == 1
1106          assert values[0]['b'] == "bad"
1107 +
1108 +
1109 +    def test04_MultiCondSelect(self):
1110 +        tabname = "test04_MultiCondSelect"
1111 +        try:
1112 +            self.tdb.Drop(tabname)
1113 +        except dbtables.TableDBError:
1114 +            pass
1115 +        self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
1116 +
1117 +        try:
1118 +            self.tdb.Insert(tabname, {'a': "", 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1), 'f': "Zero"})
1119 +            assert 0
1120 +        except dbtables.TableDBError:
1121 +            pass
1122 +
1123 +        self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D", 'e': "E"})
1124 +        self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D", 'e': "-E"})
1125 +        self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-", 'e': "E-"})
1126 +
1127 +        if verbose:
1128 +            self.tdb._db_print()
1129 +
1130 +        # This select should return 0 rows.  it is designed to test
1131 +        # the bug identified and fixed in sourceforge bug # 590449
1132 +        # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
1133 +        # and supplying a fix!!  This one caused many headaches to say
1134 +        # the least...)
1135 +        values = self.tdb.Select(tabname, ['b', 'a', 'd'],
1136 +            conditions={'e': dbtables.ExactCond('E'),
1137 +                        'a': dbtables.ExactCond('A'),
1138 +                        'd': dbtables.PrefixCond('-')
1139 +                       } )
1140 +        assert len(values) == 0, values
1141  
1142  
1143      def test_CreateOrExtend(self):
1144 Index: python/test/test_thread.py
1145 ===================================================================
1146 RCS file: rpm/python/test/test_thread.py,v
1147 retrieving revision 1.1
1148 retrieving revision 1.1.2.1
1149 diff -u -u -r1.1 -r1.1.2.1
1150 --- rpm/python/test/test_thread.py      3 Jun 2002 20:44:08 -0000       1.1
1151 +++ rpm/python/test/test_thread.py      6 Nov 2002 16:47:02 -0000       1.1.2.1
1152 @@ -18,7 +18,7 @@
1153  import unittest
1154  from test_all import verbose
1155  
1156 -from rpmdb import db
1157 +from rpmdb import db, dbutils
1158  
1159  
1160  #----------------------------------------------------------------------
1161 @@ -31,6 +31,9 @@
1162  
1163  
1164      def setUp(self):
1165 +        if verbose:
1166 +            dbutils._deadlock_VerboseFile = sys.stdout
1167 +
1168          homeDir = os.path.join(os.path.dirname(sys.argv[0]), 'db_home')
1169          self.homeDir = homeDir
1170          try: os.mkdir(homeDir)
1171 @@ -109,7 +112,7 @@
1172  
1173          for x in range(start, stop):
1174              key = '%04d' % x
1175 -            d.put(key, self.makeData(key))
1176 +            dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1177              if verbose and x % 100 == 0:
1178                  print "%s: records %d - %d finished" % (name, start, x)
1179  
1180 @@ -212,7 +215,7 @@
1181          # create a bunch of records
1182          for x in xrange(start, stop):
1183              key = '%04d' % x
1184 -            d.put(key, self.makeData(key))
1185 +            dbutils.DeadlockWrap(d.put, key, self.makeData(key), max_retries=12)
1186  
1187              if verbose and x % 100 == 0:
1188                  print "%s: records %d - %d finished" % (name, start, x)
1189 @@ -221,12 +224,12 @@
1190              if random() <= 0.05:
1191                  for y in xrange(start, x):
1192                      key = '%04d' % x
1193 -                    data = d.get(key)
1194 +                    data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1195                      assert data == self.makeData(key)
1196  
1197          # flush them
1198          try:
1199 -            d.sync()
1200 +            dbutils.DeadlockWrap(d.sync, max_retries=12)
1201          except db.DBIncompleteError, val:
1202              if verbose:
1203                  print "could not complete sync()..."
1204 @@ -234,12 +237,12 @@
1205          # read them back, deleting a few
1206          for x in xrange(start, stop):
1207              key = '%04d' % x
1208 -            data = d.get(key)
1209 +            data = dbutils.DeadlockWrap(d.get, key, max_retries=12)
1210              if verbose and x % 100 == 0:
1211                  print "%s: fetched record (%s, %s)" % (name, key, data)
1212 -            assert data == self.makeData(key)
1213 +            assert data == self.makeData(key), (key, data, self.makeData(key))
1214              if random() <= 0.10:
1215 -                d.delete(key)
1216 +                dbutils.DeadlockWrap(d.delete, key, max_retries=12)
1217                  if verbose:
1218                      print "%s: deleted record %s" % (name, key)
1219  
1220 @@ -273,7 +276,7 @@
1221  
1222  
1223  class HashSimpleThreaded(SimpleThreadedBase):
1224 -    dbtype = db.DB_BTREE
1225 +    dbtype = db.DB_HASH
1226  
1227  
1228  #----------------------------------------------------------------------
1229 Index: rpmdb/db3.c
1230 ===================================================================
1231 RCS file: rpm/rpmdb/db3.c,v
1232 retrieving revision 1.45
1233 retrieving revision 1.45.2.1
1234 diff -u -u -r1.45 -r1.45.2.1
1235 --- rpm/rpmdb/db3.c     13 Aug 2002 20:42:39 -0000      1.45
1236 +++ rpm/rpmdb/db3.c     6 Nov 2002 17:29:34 -0000       1.45.2.1
1237 @@ -266,11 +266,22 @@
1238  
1239    { int xx;
1240      /*@-noeffectuncon@*/ /* FIX: annotate db3 methods */
1241 +
1242 + /* 4.1: dbenv->set_app_dispatch(???) */
1243 + /* 4.1: dbenv->set_alloc(???) */
1244 + /* 4.1: dbenv->set_data_dir(???) */
1245 + /* 4.1: dbenv->set_encrypt(???) */
1246 +
1247      dbenv->set_errcall(dbenv, rpmdb->db_errcall);
1248      dbenv->set_errfile(dbenv, rpmdb->db_errfile);
1249      dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
1250      /*@=noeffectuncon@*/
1251 +
1252 + /* 4.1: dbenv->set_feedback(???) */
1253 + /* 4.1: dbenv->set_flags(???) */
1254 +
1255   /* dbenv->set_paniccall(???) */
1256 +
1257      xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
1258                 (dbi->dbi_verbose & DB_VERB_CHKPOINT));
1259      xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
1260 @@ -279,16 +290,35 @@
1261                 (dbi->dbi_verbose & DB_VERB_RECOVERY));
1262      xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
1263                 (dbi->dbi_verbose & DB_VERB_WAITSFOR));
1264 - /* dbenv->set_lg_max(???) */
1265 +
1266   /* dbenv->set_lk_conflicts(???) */
1267   /* dbenv->set_lk_detect(???) */
1268 - /* dbenv->set_lk_max(???) */
1269 -    xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mp_mmapsize);
1270 -    xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1271 -    xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_mp_size, 0);
1272 -    xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1273 + /* 4.1: dbenv->set_lk_max_lockers(???) */
1274 + /* 4.1: dbenv->set_lk_max_locks(???) */
1275 + /* 4.1: dbenv->set_lk_max_objects(???) */
1276 +
1277 + /* 4.1: dbenv->set_lg_bsize(???) */
1278 + /* 4.1: dbenv->set_lg_dir(???) */
1279 + /* 4.1: dbenv->set_lg_max(???) */
1280 + /* 4.1: dbenv->set_lg_regionmax(???) */
1281 +
1282 +    if (dbi->dbi_mmapsize) {
1283 +       xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mmapsize);
1284 +       xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
1285 +    }
1286 +    if (dbi->dbi_cachesize) {
1287 +       xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_cachesize, 0);
1288 +       xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
1289 +    }
1290 +
1291 + /* 4.1 dbenv->set_timeout(???) */
1292   /* dbenv->set_tx_max(???) */
1293 + /* 4.1: dbenv->set_tx_timestamp(???) */
1294   /* dbenv->set_tx_recover(???) */
1295 +
1296 + /* dbenv->set_rep_transport(???) */
1297 + /* dbenv->set_rep_limit(???) */
1298 +
1299      if (dbi->dbi_no_fsync) {
1300  #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
1301         xx = db_env_set_func_fsync(db3_fsync_disable);
1302 @@ -366,7 +396,11 @@
1303      if (db != NULL)
1304         rc = db->sync(db, flags);
1305      /* XXX DB_INCOMPLETE is returned occaisionally with multiple access. */
1306 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1307 +    _printit = _debug;
1308 +#else
1309      _printit = (rc == DB_INCOMPLETE ? 0 : _debug);
1310 +#endif
1311      rc = cvtdberr(dbi, "db->sync", rc, _printit);
1312      return rc;
1313  }
1314 @@ -599,10 +633,17 @@
1315  {
1316      DB * db = dbi->dbi_db;
1317      DB * secondary = dbisecondary->dbi_db;
1318 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1319 +    DB_TXN * txnid = NULL;
1320 +#endif
1321      int rc;
1322  
1323  /*@-moduncon@*/ /* FIX: annotate db3 methods */
1324 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1325 +    rc = db->associate(db, txnid, secondary, callback, flags);
1326 +#else
1327      rc = db->associate(db, secondary, callback, flags);
1328 +#endif
1329  /*@=moduncon@*/
1330      rc = cvtdberr(dbi, "db->associate", rc, _debug);
1331      return rc;
1332 @@ -789,6 +830,9 @@
1333  
1334      DB * db = NULL;
1335      DB_ENV * dbenv = NULL;
1336 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1337 +    DB_TXN * txnid = NULL;
1338 +#endif
1339      u_int32_t oflags;
1340      int _printit;
1341  
1342 @@ -981,18 +1025,7 @@
1343         /*@=moduncon@*/
1344         rc = cvtdberr(dbi, "db_create", rc, _debug);
1345         if (rc == 0 && db != NULL) {
1346 -           if (rc == 0 && dbi->dbi_lorder) {
1347 -               rc = db->set_lorder(db, dbi->dbi_lorder);
1348 -               rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1349 -           }
1350 -           if (rc == 0 && dbi->dbi_cachesize) {
1351 -               rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1352 -               rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1353 -           }
1354 -           if (rc == 0 && dbi->dbi_pagesize) {
1355 -               rc = db->set_pagesize(db, dbi->dbi_pagesize);
1356 -               rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1357 -           }
1358 +
1359  /* XXX 3.3.4 change. */
1360  #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
1361             if (rc == 0 &&
1362 @@ -1008,6 +1041,27 @@
1363                 rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
1364             }
1365  #endif
1366 +
1367 +/* 4.1: db->set_cache_priority(???) */
1368 +           if (rc == 0 && !dbi->dbi_use_dbenv && dbi->dbi_cachesize) {
1369 +               rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
1370 +               rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
1371 +           }
1372 +/* 4.1: db->set_encrypt(???) */
1373 +/* 4.1: db->set_errcall(dbenv, rpmdb->db_errcall); */
1374 +/* 4.1: db->set_errfile(dbenv, rpmdb->db_errfile); */
1375 +/* 4.1: db->set_errpfx(dbenv, rpmdb->db_errpfx); */
1376 + /* 4.1: db->set_feedback(???) */
1377 +
1378 +           if (rc == 0 && dbi->dbi_lorder) {
1379 +               rc = db->set_lorder(db, dbi->dbi_lorder);
1380 +               rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
1381 +           }
1382 +           if (rc == 0 && dbi->dbi_pagesize) {
1383 +               rc = db->set_pagesize(db, dbi->dbi_pagesize);
1384 +               rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
1385 +           }
1386 + /* 4.1: db->set_paniccall(???) */
1387             if (rc == 0 && oflags & DB_CREATE) {
1388                 switch(dbi->dbi_type) {
1389                 default:
1390 @@ -1042,6 +1096,7 @@
1391  #endif
1392                     break;
1393                 case DB_BTREE:
1394 +/* 4.1: db->set_append_recno(???) */
1395                     if (dbi->dbi_bt_flags) {
1396                         rc = db->set_flags(db, dbi->dbi_bt_flags);
1397                         rc = cvtdberr(dbi, "db->set_bt_flags", rc, _debug);
1398 @@ -1073,6 +1128,7 @@
1399                     break;
1400                 case DB_RECNO:
1401                     if (dbi->dbi_re_delim) {
1402 +/* 4.1: db->set_append_recno(???) */
1403                         rc = db->set_re_delim(db, dbi->dbi_re_delim);
1404                         rc = cvtdberr(dbi, "db->set_re_selim", rc, _debug);
1405                         if (rc) break;
1406 @@ -1124,8 +1180,13 @@
1407                         ? dbfullpath : dbfile;
1408  #endif
1409  
1410 +#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1)
1411 +               rc = db->open(db, txnid, dbpath, dbsubfile,
1412 +                   dbi->dbi_type, oflags, dbi->dbi_perms);
1413 +#else
1414                 rc = db->open(db, dbpath, dbsubfile,
1415                     dbi->dbi_type, oflags, dbi->dbi_perms);
1416 +#endif
1417  
1418                 if (rc == 0 && dbi->dbi_type == DB_UNKNOWN) {
1419  #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11) \
1420 Index: rpmdb/dbconfig.c
1421 ===================================================================
1422 RCS file: rpm/rpmdb/dbconfig.c,v
1423 retrieving revision 1.33
1424 retrieving revision 1.33.2.1
1425 diff -u -u -r1.33 -r1.33.2.1
1426 --- rpm/rpmdb/dbconfig.c        3 Aug 2002 22:31:39 -0000       1.33
1427 +++ rpm/rpmdb/dbconfig.c        6 Nov 2002 17:29:34 -0000       1.33.2.1
1428 @@ -190,9 +190,11 @@
1429   { "lorder",   0,POPT_ARG_INT,         &db3dbi.dbi_lorder, 0,
1430         NULL, NULL },
1431  
1432 - { "mp_mmapsize", 0,POPT_ARG_INT,      &db3dbi.dbi_mp_mmapsize, 0,
1433 + { "mmapsize", 0,POPT_ARG_INT,         &db3dbi.dbi_mmapsize, 0,
1434         NULL, NULL },
1435 - { "mp_size",  0,POPT_ARG_INT,         &db3dbi.dbi_mp_size, 0,
1436 + { "mp_mmapsize", 0,POPT_ARG_INT,      &db3dbi.dbi_mmapsize, 0,
1437 +       NULL, NULL },
1438 + { "mp_size",  0,POPT_ARG_INT,         &db3dbi.dbi_cachesize, 0,
1439         NULL, NULL },
1440   { "pagesize", 0,POPT_ARG_INT,         &db3dbi.dbi_pagesize, 0,
1441         NULL, NULL },
1442 @@ -259,7 +261,7 @@
1443  /** @todo Set a reasonable "last gasp" default db config. */
1444  /*@observer@*/ /*@unchecked@*/
1445  static const char *db3_config_default =
1446 -    "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:mp_size=512Kb:pagesize=512:perms=0644";
1447 +    "db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:cachesize=512Kb:pagesize=512:perms=0644";
1448  
1449  /*@-bounds@*/
1450  dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
1451 @@ -432,8 +434,8 @@
1452      if (!dbi->dbi_use_dbenv) {         /* db3 dbenv is always used now. */
1453         dbi->dbi_use_dbenv = 1;
1454         dbi->dbi_eflags |= (DB_INIT_MPOOL|DB_JOINENV);
1455 -       dbi->dbi_mp_mmapsize = 16 * 1024 * 1024;
1456 -       dbi->dbi_mp_size = 1 * 1024 * 1024;
1457 +       dbi->dbi_mmapsize = 16 * 1024 * 1024;
1458 +       dbi->dbi_cachesize = 1 * 1024 * 1024;
1459      }
1460  
1461      if ((dbi->dbi_bt_flags | dbi->dbi_h_flags) & DB_DUP)
1462 Index: rpmdb/header.c
1463 ===================================================================
1464 RCS file: rpm/rpmdb/header.c,v
1465 retrieving revision 1.17.2.11
1466 retrieving revision 1.17.2.12
1467 diff -u -u -r1.17.2.11 -r1.17.2.12
1468 --- rpm/rpmdb/header.c  17 Sep 2002 15:19:45 -0000      1.17.2.11
1469 +++ rpm/rpmdb/header.c  6 Nov 2002 17:29:34 -0000       1.17.2.12
1470 @@ -2825,6 +2825,7 @@
1471      }
1472      
1473      /*@-branchstate@*/
1474 +    if (data)
1475      switch (type) {
1476      case RPM_STRING_ARRAY_TYPE:
1477         strarray = (const char **)data;
1478 Index: rpmdb/header.h
1479 ===================================================================
1480 RCS file: rpm/rpmdb/header.h,v
1481 retrieving revision 1.6
1482 retrieving revision 1.6.2.1
1483 diff -u -u -r1.6 -r1.6.2.1
1484 --- rpm/rpmdb/header.h  13 Jul 2002 19:10:02 -0000      1.6
1485 +++ rpm/rpmdb/header.h  6 Nov 2002 17:29:34 -0000       1.6.2.1
1486 @@ -78,7 +78,7 @@
1487  /* RPM - Copyright (C) 1995-2001 Red Hat Software */
1488  
1489  #include <stdio.h>
1490 -#include <rpmio.h>
1491 +#include "rpmio.h"
1492  
1493  #ifdef __cplusplus
1494  extern "C" {
1495 @@ -717,7 +717,7 @@
1496  }
1497  
1498  #if !defined(__HEADER_PROTOTYPES__)
1499 -#include <hdrinline.h>
1500 +#include "hdrinline.h"
1501  #endif
1502  
1503  #ifdef __cplusplus
1504 Index: rpmdb/rpmdb.h
1505 ===================================================================
1506 RCS file: rpm/rpmdb/rpmdb.h,v
1507 retrieving revision 1.46.2.2
1508 retrieving revision 1.46.2.3
1509 diff -u -u -r1.46.2.2 -r1.46.2.3
1510 --- rpm/rpmdb/rpmdb.h   17 Sep 2002 15:19:46 -0000      1.46.2.2
1511 +++ rpm/rpmdb/rpmdb.h   6 Nov 2002 17:29:34 -0000       1.46.2.3
1512 @@ -8,8 +8,8 @@
1513   */
1514  
1515  #include <assert.h>
1516 -#include <rpmlib.h>
1517 -#include <db.h>
1518 +#include "rpmlib.h"
1519 +#include "db.h"
1520  
1521  /*@-exportlocal@*/
1522  /*@unchecked@*/
1523 @@ -321,8 +321,8 @@
1524      int        dbi_region_init;
1525      int        dbi_tas_spins;
1526         /* mpool sub-system parameters */
1527 -    int        dbi_mp_mmapsize;        /*!< (10Mb) */
1528 -    int        dbi_mp_size;    /*!< (128Kb) */
1529 +    int        dbi_mmapsize;   /*!< (10Mb) */
1530 +    int        dbi_cachesize;  /*!< (128Kb) */
1531         /* lock sub-system parameters */
1532      unsigned int dbi_lk_max;
1533      unsigned int dbi_lk_detect;
1534 @@ -340,7 +340,6 @@
1535         /*@modifies fileSystem @*/;
1536  #endif
1537         /* dbinfo parameters */
1538 -    int        dbi_cachesize;          /*!< */
1539      int        dbi_pagesize;           /*!< (fs blksize) */
1540  /*@unused@*/ /*@null@*/
1541      void * (*dbi_malloc) (size_t nbytes)
1542 Index: rpmio/rpmlog.c
1543 ===================================================================
1544 RCS file: rpm/rpmio/rpmlog.c,v
1545 retrieving revision 2.27
1546 retrieving revision 2.27.2.1
1547 diff -u -u -r2.27 -r2.27.2.1
1548 --- rpm/rpmio/rpmlog.c  2 Jul 2002 23:54:38 -0000       2.27
1549 +++ rpm/rpmio/rpmlog.c  20 Sep 2002 16:33:49 -0000      2.27.2.1
1550 @@ -179,6 +179,7 @@
1551         else                    /* glibc 2.0 */
1552             msgnb *= 2;
1553         msgbuf = xrealloc(msgbuf, msgnb);
1554 +       va_end(apc);
1555      }
1556      msgbuf[msgnb - 1] = '\0';
1557      msg = msgbuf;
1558 Index: rpmio/rpmrpc.c
1559 ===================================================================
1560 RCS file: rpm/rpmio/rpmrpc.c,v
1561 retrieving revision 2.27.2.2
1562 retrieving revision 2.27.2.3
1563 diff -u -u -r2.27.2.2 -r2.27.2.3
1564 --- rpm/rpmio/rpmrpc.c  17 Sep 2002 15:19:46 -0000      2.27.2.2
1565 +++ rpm/rpmio/rpmrpc.c  9 Oct 2002 19:06:24 -0000       2.27.2.3
1566 @@ -1023,7 +1023,7 @@
1567         (unsigned)st->st_dev,
1568         (unsigned)st->st_ino,
1569         st->st_mode,
1570 -       st->st_nlink,
1571 +       (unsigned)st->st_nlink,
1572         st->st_uid,
1573         st->st_gid,
1574         (unsigned)st->st_rdev,
1575 Index: tools/sections.c
1576 ===================================================================
1577 RCS file: rpm/tools/sections.c,v
1578 retrieving revision 1.1.2.2
1579 retrieving revision 1.1.2.4
1580 diff -u -u -r1.1.2.2 -r1.1.2.4
1581 --- rpm/tools/sections.c        22 Aug 2002 19:19:47 -0000      1.1.2.2
1582 +++ rpm/tools/sections.c        9 Oct 2002 19:06:24 -0000       1.1.2.4
1583 @@ -24,38 +24,168 @@
1584  } UnstripInfo32;
1585  
1586  typedef struct {
1587 -  Elf32_Off orig_e_shoff;
1588 -  Elf32_Off n_sections;
1589 +  Elf64_Off orig_e_shoff;
1590 +  Elf64_Off n_sections;
1591    UnstripInfoSection64 sections[1];
1592  } UnstripInfo64;
1593  
1594 +static uint32_t
1595 +elf_32_to_file (uint32_t x, int file_is_little_endian)
1596 +{
1597 +  volatile uint32_t out;
1598 +  unsigned char *outbytes;
1599 +
1600 +  outbytes = (unsigned char *)&out;
1601 +  if (file_is_little_endian)
1602 +    {
1603 +      outbytes[0] = (x >> 0) & 0xff;
1604 +      outbytes[1] = (x >> 8) & 0xff;
1605 +      outbytes[2] = (x >> 16) & 0xff;
1606 +      outbytes[3] = (x >> 24) & 0xff;
1607 +    }
1608 +  else /* big endian */
1609 +    {
1610 +      outbytes[0] = (x >> 24) & 0xff;
1611 +      outbytes[1] = (x >> 16) & 0xff;
1612 +      outbytes[2] = (x >> 8) & 0xff;
1613 +      outbytes[3] = (x >> 0) & 0xff;
1614 +    }
1615 +  
1616 +  return out;
1617 +}
1618 +
1619 +static uint64_t
1620 +elf_64_to_file (uint64_t x, int file_is_little_endian)
1621 +{
1622 +  volatile uint64_t out;
1623 +  unsigned char *outbytes;
1624 +  int i;
1625 +
1626 +  outbytes = (unsigned char *)&out;
1627 +  if (file_is_little_endian)
1628 +    {
1629 +      for (i = 0; i < 8; i++)
1630 +       outbytes[i] = (x >> (8*i)) & 0xff;
1631 +    }
1632 +  else /* big endian */
1633 +    {
1634 +      for (i = 0; i < 8; i++)
1635 +       outbytes[7-i] = (x >> (8*i)) & 0xff;
1636 +    }
1637 +  
1638 +  return out;
1639 +}
1640  
1641  static Elf32_Word
1642  word32_to_file (Elf32_Word x, Elf *elf)
1643  {
1644 -  /* FIXME: implement */
1645 -  return x;
1646 +  Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1647 +  return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1648  }
1649  
1650  static Elf32_Off
1651  off32_to_file (Elf32_Off x, Elf *elf)
1652  {
1653 -  /* FIXME: implement */
1654 -  return x;
1655 +  Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1656 +  return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1657 +}
1658 +
1659 +static Elf64_Word
1660 +word64_to_file (Elf64_Word x, Elf *elf)
1661 +{
1662 +  Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1663 +  return elf_32_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1664 +}
1665 +
1666 +static Elf64_Off
1667 +off64_to_file (Elf64_Off x, Elf *elf)
1668 +{
1669 +  Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1670 +  return elf_64_to_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1671 +}
1672 +
1673 +static uint32_t
1674 +elf_32_from_file (uint32_t x, int file_is_little_endian)
1675 +{
1676 +  unsigned char *inbytes;
1677 +
1678 +  inbytes = (unsigned char *)&x;
1679 +  if (file_is_little_endian)
1680 +    {
1681 +      return 
1682 +       (inbytes[0] << 0) |
1683 +       (inbytes[1] << 8) |
1684 +       (inbytes[2] << 16) |
1685 +       (inbytes[3] << 24);
1686 +    }
1687 +  else /* big endian */
1688 +    {
1689 +      return 
1690 +       (inbytes[0] << 24) |
1691 +       (inbytes[1] << 16) |
1692 +       (inbytes[2] << 8) |
1693 +       (inbytes[3] << 0);
1694 +    }
1695 +}
1696 +
1697 +static uint64_t
1698 +elf_64_from_file (uint64_t x, int file_is_little_endian)
1699 +{
1700 +  unsigned char *inbytes;
1701 +
1702 +  inbytes = (unsigned char *)&x;
1703 +  if (file_is_little_endian)
1704 +    {
1705 +      return 
1706 +       ((uint64_t)inbytes[0] << 0) |
1707 +       ((uint64_t)inbytes[1] << 8) |
1708 +       ((uint64_t)inbytes[2] << 16) |
1709 +       ((uint64_t)inbytes[3] << 24) |
1710 +       ((uint64_t)inbytes[4] << 32) |
1711 +       ((uint64_t)inbytes[5] << 40) |
1712 +       ((uint64_t)inbytes[6] << 48) |
1713 +       ((uint64_t)inbytes[7] << 56);
1714 +    }
1715 +  else /* big endian */
1716 +    {
1717 +      return 
1718 +       ((uint64_t)inbytes[0] << 56) |
1719 +       ((uint64_t)inbytes[1] << 48) |
1720 +       ((uint64_t)inbytes[2] << 40) |
1721 +       ((uint64_t)inbytes[3] << 32) |
1722 +       ((uint64_t)inbytes[4] << 24) |
1723 +       ((uint64_t)inbytes[5] << 16) |
1724 +       ((uint64_t)inbytes[6] << 8) |
1725 +       ((uint64_t)inbytes[7] << 0);
1726 +    }
1727  }
1728  
1729  static Elf32_Word
1730  word32_from_file (Elf32_Word x, Elf *elf)
1731  {
1732 -  /* FIXME: implement */
1733 -  return x;
1734 +  Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1735 +  return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1736  }
1737  
1738  static Elf32_Off
1739  off32_from_file (Elf32_Off x, Elf *elf)
1740  {
1741 -  /* FIXME: implement */
1742 -  return x;
1743 +  Elf32_Ehdr *ehdr = elf32_getehdr (elf);
1744 +  return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1745 +}
1746 +
1747 +static Elf64_Word
1748 +word64_from_file (Elf64_Word x, Elf *elf)
1749 +{
1750 +  Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1751 +  return elf_32_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1752 +}
1753 +
1754 +static Elf64_Off
1755 +off64_from_file (Elf64_Off x, Elf *elf)
1756 +{
1757 +  Elf64_Ehdr *ehdr = elf64_getehdr (elf);
1758 +  return elf_64_from_file (x, ehdr->e_ident[EI_DATA] & ELFDATA2LSB);
1759  }
1760  
1761  static void
1762 @@ -93,7 +223,29 @@
1763                         Elf *elf,
1764                         Elf_Data *data)
1765  {
1766 +  UnstripInfo64 *info64;
1767 +  int i;
1768 +  
1769    data->d_align = 8;
1770 +  
1771 +  data->d_size =
1772 +    /* orig_e_shoff */ sizeof (Elf64_Off) +
1773 +    /* n_sections */ sizeof (Elf64_Off) +
1774 +    /* sections */ info->n_sections * sizeof (UnstripInfoSection64);
1775 +
1776 +  data->d_buf = calloc (1, data->d_size);
1777 +
1778 +  info64 = (UnstripInfo64 *) data->d_buf;
1779 +
1780 +  info64->orig_e_shoff = off64_to_file (info->orig_e_shoff, elf);
1781 +  info64->n_sections = off64_to_file (info->n_sections, elf);
1782 +
1783 +  for (i = 0; i < info->n_sections; i++)
1784 +    {
1785 +      info64->sections[i].debug_section = word64_to_file (info->sections[i].debug_section, elf);
1786 +      info64->sections[i].name = word64_to_file (info->sections[i].name, elf);
1787 +      info64->sections[i].orig_offset = off64_to_file (info->sections[i].orig_offset, elf);
1788 +    }
1789  }
1790  
1791  void
1792 @@ -101,14 +253,21 @@
1793                       Elf *elf,
1794                       Elf_Data *data)
1795  {
1796 +  GElf_Ehdr ehdr;
1797 +  
1798    data->d_type = ELF_T_BYTE;
1799    data->d_off = 0;
1800  
1801 -  /* FIXME: use right version */
1802 -  unstrip_info_to_data32 (info, elf, data);
1803 +  gelf_getehdr (elf, &ehdr);
1804 +  if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1805 +    unstrip_info_to_data32 (info, elf, data);
1806 +  else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1807 +    unstrip_info_to_data64 (info, elf, data);
1808 +  else
1809 +    fprintf (stderr, "Warning. unsupported elf class\n");
1810  }
1811  
1812 -void
1813 +static void
1814  unstrip_info_from_data32 (UnstripInfo *info,
1815                           Elf *elf,
1816                           Elf_Data *data)
1817 @@ -130,23 +289,49 @@
1818      }
1819  }
1820  
1821 +static void
1822 +unstrip_info_from_data64 (UnstripInfo *info,
1823 +                         Elf *elf,
1824 +                         Elf_Data *data)
1825 +{
1826 +  UnstripInfo64 *info64;
1827 +  int i;
1828 +  
1829 +  info64 = (UnstripInfo64 *) data->d_buf;
1830 +  
1831 +  info->orig_e_shoff = off64_from_file (info64->orig_e_shoff, elf);
1832 +  info->n_sections = off64_from_file (info64->n_sections, elf);
1833 +
1834 +  info->sections = calloc (info->n_sections, sizeof (UnstripInfoSection));
1835 +  for (i = 0; i < info->n_sections; i++)
1836 +    {
1837 +      info->sections[i].debug_section = word64_from_file (info64->sections[i].debug_section, elf);
1838 +      info->sections[i].name = word64_from_file (info64->sections[i].name, elf);
1839 +      info->sections[i].orig_offset = off64_from_file (info64->sections[i].orig_offset, elf);
1840 +    }
1841 +}
1842 +
1843  UnstripInfo *
1844  unstrip_info_from_data (Elf *elf,
1845                         Elf_Data *data)
1846  {
1847 +  GElf_Ehdr ehdr;
1848 +  
1849    UnstripInfo *info;
1850  
1851    info = malloc (sizeof (UnstripInfo));
1852  
1853 -  /* FIXME: use right version */
1854 -  unstrip_info_from_data32 (info,
1855 -                           elf,
1856 -                           data);
1857 +  gelf_getehdr (elf, &ehdr);
1858 +  if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1859 +    unstrip_info_from_data32 (info, elf, data);
1860 +  else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1861 +    unstrip_info_from_data64 (info, elf, data);
1862 +  else
1863 +    fprintf (stderr, "Warning. unsupported elf class\n");
1864    
1865    return info;
1866  }
1867  
1868 -
1869  static void
1870  debug_link_to_data32 (DebugLink *debuglink,
1871                       Elf *elf,
1872 @@ -166,23 +351,53 @@
1873    data->d_buf = calloc (1, data->d_size);
1874  
1875    strcpy (data->d_buf, debuglink->filename);
1876 -  p = data->d_buf + namelen_aligned;
1877 +  p = ((char *)data->d_buf) + namelen_aligned;
1878    
1879    *(Elf32_Word *)p = word32_to_file (debuglink->checksum, elf);
1880 -  p += sizeof (Elf32_Word);
1881 +}
1882 +
1883 +static void
1884 +debug_link_to_data64 (DebugLink *debuglink,
1885 +                     Elf *elf,
1886 +                     Elf_Data *data)
1887 +{
1888 +  size_t namelen_aligned;
1889 +  char *p;
1890 +  
1891 +  data->d_align = 4;
1892 +
1893 +  namelen_aligned = align_up (strlen(debuglink->filename) + 1, 4);
1894 +
1895 +  data->d_size =
1896 +    /* name */ namelen_aligned +
1897 +    /* checksum */ sizeof (Elf64_Word);
1898 +
1899 +  data->d_buf = calloc (1, data->d_size);
1900 +
1901 +  strcpy (data->d_buf, debuglink->filename);
1902 +  p = ((char *)data->d_buf) + namelen_aligned;
1903 +  
1904 +  *(Elf64_Word *)p = word64_to_file (debuglink->checksum, elf);
1905  }
1906  
1907  void
1908  debug_link_to_data (DebugLink *debuglink, Elf *elf, Elf_Data *data)
1909  {
1910 +  GElf_Ehdr ehdr;
1911 +  
1912    data->d_type = ELF_T_BYTE;
1913    data->d_off = 0;
1914  
1915 -  /* FIXME: use right version */
1916 -  debug_link_to_data32 (debuglink, elf, data);
1917 +  gelf_getehdr (elf, &ehdr);
1918 +  if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1919 +    debug_link_to_data32 (debuglink, elf, data);
1920 +  else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1921 +    debug_link_to_data64 (debuglink, elf, data);
1922 +  else
1923 +    fprintf (stderr, "Warning. unsupported elf class\n");
1924  }
1925  
1926 -void
1927 +static void
1928  debug_link_from_data32 (DebugLink *debuglink,
1929                         Elf *elf,
1930                         Elf_Data *data)
1931 @@ -194,24 +409,44 @@
1932  
1933    namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1934  
1935 -  p = data->d_buf + namelen_aligned;
1936 +  p = ((char *)data->d_buf) + namelen_aligned;
1937    
1938    debuglink->checksum = word32_from_file (*(Elf32_Word *)p, elf);
1939 -  p += sizeof (Elf32_Word);
1940 +}
1941 +
1942 +static void
1943 +debug_link_from_data64 (DebugLink *debuglink,
1944 +                       Elf *elf,
1945 +                       Elf_Data *data)
1946 +{
1947 +  size_t namelen_aligned;
1948 +  char *p;
1949 +  
1950 +  debuglink->filename = strdup (data->d_buf);
1951 +
1952 +  namelen_aligned = align_up (strlen (debuglink->filename) + 1, 4);
1953 +
1954 +  p = ((char *)data->d_buf) + namelen_aligned;
1955 +  
1956 +  debuglink->checksum = word64_from_file (*(Elf64_Word *)p, elf);
1957  }
1958  
1959  
1960  DebugLink *
1961  debug_link_from_data (Elf *elf, Elf_Data *data)
1962  {
1963 +  GElf_Ehdr ehdr;
1964    DebugLink *debuglink;
1965  
1966    debuglink = malloc (sizeof (DebugLink));
1967  
1968 -  /* FIXME: use right version */
1969 -  debug_link_from_data32 (debuglink,
1970 -                         elf,
1971 -                         data);
1972 +  gelf_getehdr (elf, &ehdr);
1973 +  if (ehdr.e_ident[EI_CLASS] == ELFCLASS32)
1974 +    debug_link_from_data32 (debuglink, elf, data);
1975 +  else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64)
1976 +    debug_link_from_data64 (debuglink, elf, data);
1977 +  else
1978 +    fprintf (stderr, "Warning. unsupported elf class\n");
1979    
1980    return debuglink;
1981  }
1982 Index: tools/striptofile.c
1983 ===================================================================
1984 RCS file: rpm/tools/striptofile.c,v
1985 retrieving revision 1.1.2.2
1986 retrieving revision 1.1.2.4
1987 diff -u -u -r1.1.2.2 -r1.1.2.4
1988 --- rpm/tools/striptofile.c     22 Aug 2002 19:19:47 -0000      1.1.2.2
1989 +++ rpm/tools/striptofile.c     9 Oct 2002 19:06:24 -0000       1.1.2.4
1990 @@ -15,7 +15,8 @@
1991  int keep_all_section_headers = 1;
1992  int add_unstrip_info = 0;
1993  
1994 -void
1995 +#if defined(NhUNUSED)
1996 +static void
1997  copy_to_file(Elf *elf, Elf *out_elf)
1998  {
1999    GElf_Ehdr ehdr;
2000 @@ -67,8 +68,9 @@
2001         }
2002      }
2003  }
2004 +#endif
2005  
2006 -void
2007 +static void
2008  strip_to_file(Elf *elf, Elf *out_elf, DebugLink *debuglink)
2009  {
2010    GElf_Ehdr ehdr;
2011 @@ -82,7 +84,8 @@
2012    int keep_section;
2013    int changed_offsets;
2014    GElf_Off last_offset;
2015 -  int i, debuglink_name;
2016 +  int i;
2017 +  int debuglink_name = 0;
2018  
2019    elf_flagelf (out_elf, ELF_C_SET, ELF_F_LAYOUT);
2020    
2021 @@ -201,7 +204,7 @@
2022    /* Update section header stringtab ref */
2023    gelf_getehdr (out_elf, &out_ehdr);
2024    out_ehdr.e_shstrndx = section_map[out_ehdr.e_shstrndx];
2025 -  out_ehdr.e_shoff = align_up (last_offset, 4);
2026 +  out_ehdr.e_shoff = align_up (last_offset, 8);
2027    gelf_update_ehdr(out_elf, &out_ehdr);
2028  
2029    /* Update section header links */
2030 @@ -220,7 +223,7 @@
2031      }
2032  }
2033  
2034 -void
2035 +static void
2036  copy_debuginfo_to_file(Elf *elf, Elf *out_elf)
2037  {
2038    GElf_Ehdr ehdr;
2039 @@ -231,7 +234,7 @@
2040    unsigned char *section_strtab;
2041    int keep_section;
2042    UnstripInfo *info;
2043 -  int unstripinfo_name;
2044 +  int unstripinfo_name = 0;
2045  
2046    info = malloc (sizeof (UnstripInfo));
2047    
2048 @@ -402,6 +405,7 @@
2049    Elf *elf, *out_elf;
2050    int fd, out;
2051    const char *origname;
2052 +  char *origname_base;
2053    char *debugname, *strippedname;
2054    DebugLink *debuglink;
2055    poptContext optCon;   /* context for parsing command-line options */
2056 @@ -433,14 +437,13 @@
2057    
2058    origname = args[0];
2059  
2060 -  if (output_dir) {
2061 -    const char * bn = strrchr(origname, '/');
2062 -    if ((bn = strrchr(origname, '/')) != NULL)
2063 -       bn++;
2064 -    else
2065 -       bn = origname;
2066 -    debugname = strconcat (output_dir, "/", bn, ".debug", NULL);
2067 -  } else
2068 +  if (output_dir)
2069 +    {
2070 +      origname_base = path_basename (origname);
2071 +      debugname = strconcat (output_dir, "/", origname_base, ".debug", NULL);
2072 +      free (origname_base);
2073 +    }
2074 +  else
2075      debugname = strconcat (origname, ".debug", NULL);
2076    
2077    strippedname = strconcat (origname, ".XXXXXX", NULL);
2078 Index: tools/unstripfile.c
2079 ===================================================================
2080 RCS file: rpm/tools/unstripfile.c,v
2081 retrieving revision 1.1.2.2
2082 retrieving revision 1.1.2.3
2083 diff -u -u -r1.1.2.2 -r1.1.2.3
2084 --- rpm/tools/unstripfile.c     22 Aug 2002 19:19:47 -0000      1.1.2.2
2085 +++ rpm/tools/unstripfile.c     9 Oct 2002 19:06:24 -0000       1.1.2.3
2086 @@ -9,7 +9,7 @@
2087  
2088  #include "debug.h"
2089  
2090 -DebugLink *
2091 +static DebugLink *
2092  read_debuglink (Elf *elf)
2093  {
2094    GElf_Ehdr ehdr;
2095 @@ -47,7 +47,7 @@
2096    return NULL;
2097  }
2098  
2099 -Elf_Scn *
2100 +static Elf_Scn *
2101  find_section (Elf *elf, const unsigned char *name, const unsigned char *strtab)
2102  {
2103    Elf_Scn *section;
2104 @@ -69,7 +69,7 @@
2105    return section;
2106  }
2107  
2108 -size_t
2109 +static size_t
2110  find_in_strtab (char *name, char *strtab, size_t strtab_len)
2111  {
2112    int name_len, i;
2113 @@ -82,7 +82,7 @@
2114    return 0;
2115  }
2116  
2117 -void
2118 +static void
2119  unstrip_file (Elf *elf, Elf *debug_elf, Elf *out_elf)
2120  {
2121    UnstripInfo *info;
2122 Index: tools/utils.c
2123 ===================================================================
2124 RCS file: rpm/tools/utils.c,v
2125 retrieving revision 1.1.2.3
2126 retrieving revision 1.1.2.4
2127 diff -u -u -r1.1.2.3 -r1.1.2.4
2128 --- rpm/tools/utils.c   4 Sep 2002 18:13:35 -0000       1.1.2.3
2129 +++ rpm/tools/utils.c   9 Oct 2002 19:06:24 -0000       1.1.2.4
2130 @@ -6,7 +6,7 @@
2131  
2132  #include "debug.h"
2133  
2134 -char *
2135 +static char *
2136  my_stpcpy (char       *dest,
2137            const char *src)
2138  {
2139 @@ -146,7 +146,7 @@
2140    0x2d02ef8d
2141  };
2142  
2143 -unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2144 +static unsigned int crc32 (unsigned int crc, unsigned char *buf, size_t len)
2145  {
2146    unsigned char *end;
2147  
2148 Index: xmlspec/Makefile
2149 ===================================================================
2150 RCS file: rpm/xmlspec/Makefile,v
2151 retrieving revision 1.5.2.2
2152 retrieving revision 1.5.2.3
2153 diff -u -u -r1.5.2.2 -r1.5.2.3
2154 --- rpm/xmlspec/Makefile        28 Aug 2002 10:53:03 -0000      1.5.2.2
2155 +++ rpm/xmlspec/Makefile        10 Oct 2002 22:47:59 -0000      1.5.2.3
2156 @@ -7,7 +7,9 @@
2157  CFLAGS        = -O2 -Wall -Wpointer-arith -Wno-char-subscripts
2158  INCDIR        = -I. -I.. -I../build -I../lib -I../misc -I../popt -I../rpmdb -I../rpmio
2159  RPMDIR        = ..
2160 -DESTDIR       = /usr/local
2161 +
2162 +prefix        = /usr
2163 +DESTDIR       = 
2164  
2165  XMLBUILD      = rpmxmlbuild
2166  XMLBUILD_SRC  = rpmxmlbuild.c
2167 @@ -21,6 +23,7 @@
2168  LIBS          = $(XMLLIB) $(RPMDIR)/build/.libs/librpmbuild.a \
2169                 $(RPMDIR)/lib/.libs/librpm.a $(RPMDIR)/rpmdb/.libs/librpmdb.a \
2170                 $(RPMDIR)/rpmio/.libs/librpmio.a $(RPMDIR)/popt/.libs/libpopt.a \
2171 +               $(RPMDIR)/libelf/lib/.libs/libelf.a \
2172                 -lz -lexpat -lbz2
2173  LIBDIR        = -L. -L$(RPMDIR)/.libs -L/usr/lib
2174  
2175 @@ -33,9 +36,9 @@
2176         $(STRIP) $(XMLBUILD)
2177  
2178  install:
2179 -       @(cp $(XMLBUILD) $(DESTDIR)/bin)
2180 -       @(cp $(XMLLIB) $(DESTDIR)/lib)
2181 -       @(cp $(XMLLIB_H) $(DESTDIR)/include)
2182 +       @(install -m 755 $(XMLBUILD) $(DESTDIR)$(prefix)/bin)
2183 +       @(install -m 644 $(XMLLIB) $(DESTDIR)$(prefix)/lib)
2184 +       @(install -m 644 $(XMLLIB_H) $(DESTDIR)$(prefix)/include/rpm)
2185  
2186  $(XMLLIB): $(XMLLIB_OBJ)
2187         $(AR) $(ARFLAGS) $(XMLLIB) $(XMLLIB_OBJ)
2188 Index: xmlspec/XMLAttrs.cpp
2189 ===================================================================
2190 RCS file: xmlspec/XMLAttrs.cpp
2191 diff -N xmlspec/XMLAttrs.cpp
2192 --- /dev/null   1 Jan 1970 00:00:00 -0000
2193 +++ rpm/xmlspec/XMLAttrs.cpp    28 Aug 2002 10:52:43 -0000      1.3.2.1
2194 @@ -0,0 +1,168 @@
2195 +// standard C++ includes
2196 +#include <string>
2197 +
2198 +// standard includes
2199 +#include <string.h>
2200 +
2201 +// our includes
2202 +#include "XMLAttrs.h"
2203 +#include "XMLMisc.h"
2204 +#include "XMLSpec.h"
2205 +
2206 +using namespace std;
2207 +
2208 +XMLAttr::XMLAttr(const char* szName,
2209 +                               const char* szValue)
2210 +       : XMLBase()
2211 +{
2212 +       if (szName)
2213 +               m_sName.assign(szName);
2214 +       if (szValue)
2215 +               m_sValue.assign(szValue);
2216 +}
2217 +
2218 +XMLAttr::XMLAttr(const XMLAttr& rAttr)
2219 +       : XMLBase()
2220 +{
2221 +       m_sName.assign(rAttr.m_sName);
2222 +       m_sValue.assign(rAttr.m_sValue);
2223 +}
2224 +
2225 +XMLAttr::~XMLAttr()
2226 +{
2227 +}
2228 +
2229 +XMLAttr XMLAttr::operator=(XMLAttr attr)
2230 +{
2231 +       m_sName.assign(attr.m_sName);
2232 +       m_sValue.assign(attr.m_sValue);
2233 +}
2234 +
2235 +XMLAttrs::XMLAttrs(const char** szAttrs)
2236 +       : XMLBase()
2237 +{
2238 +       for (int i = 0; szAttrs && szAttrs[i]; i += 2) {
2239 +               XMLAttr attr(szAttrs[i], szAttrs[i+1]);
2240 +               m_vAttrs.push_back(attr);
2241 +       }
2242 +}
2243 +
2244 +XMLAttrs::XMLAttrs(const XMLAttrs& rAttrs)
2245 +       : XMLBase()
2246 +{
2247 +       m_vAttrs = rAttrs.m_vAttrs;
2248 +}
2249 +
2250 +XMLAttrs::~XMLAttrs()
2251 +{
2252 +}
2253 +
2254 +bool validateAttr(structValidAttrs& rAttr,
2255 +                                 const char* szValue)
2256 +{
2257 +       switch (rAttr.m_nType) {
2258 +               case XATTRTYPE_STRING:
2259 +                       return findStr(rAttr.m_szaMatches, szValue) != -1 ? true : false;
2260 +                       break;
2261 +               case XATTRTYPE_INTEGER:
2262 +                       return isInteger(szValue);
2263 +                       break;
2264 +               case XATTRTYPE_BOOL:
2265 +                       return isBool(szValue);
2266 +                       break;
2267 +               case XATTRTYPE_DATE:
2268 +                       return isDate(szValue);
2269 +                       break;
2270 +               case XATTRTYPE_MAIL:
2271 +                       return isEmail(szValue);
2272 +                       break;
2273 +               case XATTRTYPE_NONE:
2274 +               default:
2275 +                       return true;
2276 +                       break;
2277 +       }
2278 +       return false;
2279 +}
2280 +
2281 +static char* szaTypeDesc[] = { "string",
2282 +                                                          "integer",
2283 +                                                          "bool [Values: true|false]",
2284 +                                                          "date [Format: DDD MMM DD YYYY]",
2285 +                                                          "e-mail" };
2286 +
2287 +bool XMLAttrs::validate(structValidAttrs* paValids,
2288 +                                               XMLBase* pError)
2289 +{
2290 +       // nothing found at present
2291 +       for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++)
2292 +               paValids[i].m_bFound = false;
2293 +
2294 +       // test everything we have
2295 +       for (unsigned int i = 0; i < num(); i++) {
2296 +               bool bInvalid = true;
2297 +               for (unsigned int j = 0; paValids[j].m_nValue != XATTR_END; j++) {
2298 +                       if (strcasecmp(paValids[j].m_szName, get(i).getName()) == 0) {
2299 +                               paValids[j].m_bFound = true;
2300 +                               if (!validateAttr(paValids[j], get(i).asString())) {
2301 +                                       char szTmp[1024];
2302 +                                       sprintf(szTmp, "Attribute value '%s' is not a valid %s.",
2303 +                                                                       get(i).asString(), szaTypeDesc[paValids[j].m_nType]);
2304 +                                       pError->setError(szTmp);
2305 +                                       return false;
2306 +                               }
2307 +                               else
2308 +                                       bInvalid = false;
2309 +                               break;
2310 +                       }
2311 +               }
2312 +               if (bInvalid) {
2313 +                       char szTmp[1024];
2314 +                       sprintf(szTmp, "Unknown attribute '%s'", get(i).getName());
2315 +                       pError->setWarning(szTmp);
2316 +               }
2317 +       }
2318 +
2319 +       // see if we have mandator tags that are not there
2320 +       for (unsigned int i = 0; paValids[i].m_nValue != XATTR_END; i++) {
2321 +               if (paValids[i].m_bMandatory && !paValids[i].m_bFound) {
2322 +                       char szTmp[1024];
2323 +                       sprintf(szTmp, "Mandatory attribute '%s' not found",
2324 +                                                       paValids[i].m_szName);
2325 +                       pError->setError(szTmp);
2326 +                       return false;
2327 +               }
2328 +       }
2329 +
2330 +       // if we got this far, everything is ok
2331 +       return true;
2332 +}
2333 +
2334 +unsigned int getPos(const char* szName,
2335 +                                       XMLAttrs* pAttrs)
2336 +{
2337 +       if (szName) {
2338 +               for (unsigned int i = 0; i < pAttrs->num(); i++) {
2339 +                       if (strcasecmp(szName, pAttrs->get(i).getName()) == 0)
2340 +                               return i;
2341 +               }
2342 +       }
2343 +       return XATTR_END;
2344 +}
2345 +
2346 +const char* XMLAttrs::asString(const char* szName)
2347 +{
2348 +       unsigned int nPos = getPos(szName, this);
2349 +       return (nPos == XATTR_END) ? NULL : get(nPos).asString();
2350 +}
2351 +
2352 +unsigned int XMLAttrs::asInteger(const char* szName)
2353 +{
2354 +       unsigned int nPos = getPos(szName, this);
2355 +       return (nPos == XATTR_END) ? 0 : get(nPos).asInteger();
2356 +}
2357 +
2358 +bool XMLAttrs::asBool(const char* szName)
2359 +{
2360 +       unsigned int nPos = getPos(szName, this);
2361 +       return (nPos == XATTR_END) ? true : get(nPos).asBool();
2362 +}
2363 Index: xmlspec/XMLAttrs.h
2364 ===================================================================
2365 RCS file: xmlspec/XMLAttrs.h
2366 diff -N xmlspec/XMLAttrs.h
2367 --- /dev/null   1 Jan 1970 00:00:00 -0000
2368 +++ rpm/xmlspec/XMLAttrs.h      28 Aug 2002 10:52:43 -0000      1.2.2.1
2369 @@ -0,0 +1,255 @@
2370 +#ifndef _H_XMLATTRS_
2371 +#define _H_XMLATTRS_
2372 +
2373 +// standard C++ includes
2374 +#include <string>
2375 +#include <vector>
2376 +
2377 +// standard C includes
2378 +#include <string.h>
2379 +
2380 +// our includes
2381 +#include "XMLBase.h"
2382 +
2383 +using namespace std;
2384 +
2385 +// definition for the end of the attributes
2386 +#define XATTR_END        0xFFFF
2387 +#define XATTR_NUM_VALSTR 5
2388 +
2389 +enum eAttrType
2390 +{
2391 +       XATTRTYPE_STRING = 0,
2392 +       XATTRTYPE_INTEGER,
2393 +       XATTRTYPE_BOOL,
2394 +       XATTRTYPE_DATE,
2395 +       XATTRTYPE_MAIL,
2396 +       XATTRTYPE_NONE = XATTR_END
2397 +};
2398 +
2399 +struct structValidAttrs
2400 +{
2401 +       unsigned int m_nValue;
2402 +       bool         m_bMandatory;
2403 +       bool         m_bFound;
2404 +       char*        m_szName;
2405 +       unsigned int m_nType;
2406 +       char*        m_szaMatches[XATTR_NUM_VALSTR+1];
2407 +};
2408 +
2409 +// forward class definitions
2410 +class XMLSpec;
2411 +
2412 +class XMLAttr : public XMLBase
2413 +{
2414 +//
2415 +// contructors/destructor
2416 +//
2417 +public:
2418 +       /**
2419 +        * Default constructor
2420 +        * .
2421 +        * @param szName The name of the attribute
2422 +        * @param szValue The attribute value
2423 +        * @return none
2424 +        **/
2425 +       XMLAttr(const char* szName,
2426 +                       const char* szValue);
2427 +
2428 +       /**
2429 +        * Copy constructor
2430 +        * .
2431 +        * @param rAttr Reference to the attribute to copy
2432 +        * @return none
2433 +        **/
2434 +       XMLAttr(const XMLAttr& rAttr);
2435 +
2436 +       /**
2437 +        * Destructor
2438 +        * .
2439 +        * @param none
2440 +        * @return none
2441 +        **/
2442 +       ~XMLAttr();
2443 +
2444 +//
2445 +// operators
2446 +//
2447 +public:
2448 +       /**
2449 +        * Assignment operator
2450 +        * .
2451 +        * @param attr The attribute to copy
2452 +        * @return the assigned obkect
2453 +        **/
2454 +       XMLAttr operator=(XMLAttr attr);
2455 +
2456 +//
2457 +// get/set functions
2458 +//
2459 +public:
2460 +       /**
2461 +        * Returns the attribute name
2462 +        * .
2463 +        * @param none
2464 +        * @return string containing the attribute name
2465 +        **/
2466 +       const char* getName()
2467 +       {
2468 +               return m_sName.c_str();
2469 +       }
2470 +
2471 +       /**
2472 +        * Returns the attribute value (as string)
2473 +        * .
2474 +        * @param none
2475 +        * @return string containing the attribute value
2476 +        **/
2477 +       const char* asString()
2478 +       {
2479 +               return m_sValue.c_str();
2480 +       }
2481 +
2482 +       /**
2483 +        * Returns the attribute value (as integer)
2484 +        * .
2485 +        * @param none
2486 +        * @return the attribute as an integer
2487 +        **/
2488 +       unsigned int asInteger()
2489 +       {
2490 +               return atoi(m_sValue.c_str());
2491 +       }
2492 +
2493 +       /**
2494 +        * Returns the attribute value as a boolean
2495 +        * .
2496 +        * @param none
2497 +        * @return true if set, false otherwise
2498 +        **/
2499 +       bool asBool()
2500 +       {
2501 +               bool isSet = true;
2502 +               if (strcasecmp(m_sValue.c_str(), "no") == 0 ||
2503 +                       strcasecmp(m_sValue.c_str(), "0") == 0 ||
2504 +                       strcasecmp(m_sValue.c_str(), "false") == 0)
2505 +                       isSet = false;
2506 +               return isSet;
2507 +       }
2508 +
2509 +//
2510 +// member variables
2511 +//
2512 +public:
2513 +       string m_sName;
2514 +       string m_sValue;
2515 +};
2516 +
2517 +class XMLAttrs : public XMLBase
2518 +{
2519 +//
2520 +// constructors/destructor
2521 +//
2522 +public:
2523 +       /**
2524 +        * The default attribute constructor
2525 +        * .
2526 +        * @param szAttrs Pointer to an array of attributes, terminated by NULL
2527 +        * @return none
2528 +        **/
2529 +       XMLAttrs(const char** szAttrs);
2530 +
2531 +       /**
2532 +        * Copy constructor
2533 +        * .
2534 +        * @param rAttrs The attribute object to copy
2535 +        * @return none
2536 +        **/
2537 +        XMLAttrs(const XMLAttrs& rAttrs);
2538 +
2539 +       /**
2540 +        * The default destructor
2541 +        * .
2542 +        * @param none
2543 +        * @return none
2544 +        **/
2545 +       ~XMLAttrs();
2546 +
2547 +//
2548 +// member functions
2549 +//
2550 +public:
2551 +       /**
2552 +        * Validates an attribute object against the valid attributes. This
2553 +        * checks for mandatory attributes (error) as well as unexpected
2554 +        * attributes. (warnings)
2555 +        * .
2556 +        * @param paValids Pointer to the array of valid attributes
2557 +        * @param pError   The class in which we will set the errors
2558 +        *                 and/or warnings.
2559 +        * @return true on valid attributes, false otherwise
2560 +        **/
2561 +       bool validate(structValidAttrs* paValids,
2562 +                                 XMLBase* pError);
2563 +
2564 +//
2565 +// member variables get/set functions
2566 +//
2567 +public:
2568 +       /**
2569 +        * Gets the number of attributes contained in this object
2570 +        * .
2571 +        * @param none
2572 +        * @returns The number of attributes
2573 +        **/
2574 +       unsigned int num()
2575 +       {
2576 +               return m_vAttrs.size();
2577 +       }
2578 +
2579 +       /**
2580 +        * Returns a specific attribute by number
2581 +        * .
2582 +        * @param nNum The number of the attribute to return
2583 +        * @return The attribute or NULL if it doesn't exist
2584 +        **/
2585 +       XMLAttr& get(unsigned int nNum)
2586 +       {
2587 +               return m_vAttrs[nNum];
2588 +       }
2589 +
2590 +       /**
2591 +        * Returns the attribute as specified by the name
2592 +        * .
2593 +        * @param szName The name of the attribute whose value we are
2594 +        *               to return
2595 +        * @return The attribute as a string
2596 +        **/
2597 +       const char* asString(const char* szName);
2598 +
2599 +       /**
2600 +        * Returns the attribute as specified by the name
2601 +        * .
2602 +        * @param szName The name of the attribute whose value we are
2603 +        *               to return
2604 +        * @return The attribute as an integer
2605 +        **/
2606 +       unsigned int asInteger(const char* szName);
2607 +
2608 +       /**
2609 +        * Returns the attribute as specified by the name
2610 +        * .
2611 +        * @param szName The name of the attribute whose value we are
2612 +        *               to return
2613 +        * @return The attribute as a bool
2614 +        **/
2615 +       bool asBool(const char* szName);
2616 +
2617 +//
2618 +// protected data members
2619 +//
2620 +protected:
2621 +       vector<XMLAttr> m_vAttrs;
2622 +};
2623 +
2624 +#endif
2625 Index: xmlspec/XMLBase.h
2626 ===================================================================
2627 RCS file: xmlspec/XMLBase.h
2628 diff -N xmlspec/XMLBase.h
2629 --- /dev/null   1 Jan 1970 00:00:00 -0000
2630 +++ rpm/xmlspec/XMLBase.h       28 Aug 2002 10:52:43 -0000      1.1.1.1.2.1
2631 @@ -0,0 +1,134 @@
2632 +#ifndef _H_XMLBASE_
2633 +#define _H_XMLBASE_
2634 +
2635 +// standard C++ includes
2636 +#include <string>
2637 +
2638 +// standard include
2639 +#include <stdio.h>
2640 +
2641 +using namespace std;
2642 +
2643 +class XMLBase
2644 +{
2645 +//
2646 +// constructors/destructor methods
2647 +//
2648 +public:
2649 +       /**
2650 +        * Default class constructor
2651 +        * .
2652 +        * param none
2653 +        * @return none
2654 +        **/
2655 +       XMLBase()
2656 +       {
2657 +               m_bHasError = false;
2658 +               m_bHasWarning = false;
2659 +       }
2660 +
2661 +       /**
2662 +        * Default class destructor
2663 +        * .
2664 +        * param none
2665 +        * @return none
2666 +        **/
2667 +       ~XMLBase()
2668 +       {
2669 +       }
2670 +
2671 +//
2672 +// member variable get and set functions
2673 +//
2674 +public:
2675 +       /**
2676 +        * Tests if the object has an error set.
2677 +        * .
2678 +        * @param none
2679 +        * @return true if we have an error, false otherwise
2680 +        **/
2681 +       bool hasError()
2682 +       {
2683 +               return m_bHasError;
2684 +       }
2685 +
2686 +       /**
2687 +        * Sets the error message that can be retrieved from this
2688 +        * object instance
2689 +        * .
2690 +        * @param szError The error string
2691 +        * @return none
2692 +        **/
2693 +       void setError(const char* szError = NULL)
2694 +       {
2695 +               if (szError) {
2696 +                       m_bHasError = true;
2697 +                       m_sError.assign(szError);
2698 +               }
2699 +               else
2700 +                       m_bHasError = false;
2701 +       }
2702 +
2703 +       /**
2704 +        * Returns the currently set error value
2705 +        * .
2706 +        * @param none
2707 +        * @return pointer to the error string
2708 +        **/
2709 +       const char* getError()
2710 +       {
2711 +               m_bHasError = false;
2712 +               return m_sError.c_str();
2713 +       }
2714 +
2715 +       /**
2716 +        * Tests if the object has a warning set.
2717 +        * .
2718 +        * @param none
2719 +        * @return true if we have a warning, false otherwise
2720 +        **/
2721 +       bool hasWarning()
2722 +       {
2723 +               return m_bHasWarning;
2724 +       }
2725 +
2726 +       /**
2727 +        * Sets the warning message that can be retrieved from this
2728 +        * object instance
2729 +        * .
2730 +        * @param szWarning The warning string
2731 +        * @return none
2732 +        **/
2733 +       void setWarning(const char* szWarning = NULL)
2734 +       {
2735 +               if (szWarning) {
2736 +                       m_bHasWarning = true;
2737 +                       m_sWarning.assign(szWarning);
2738 +               }
2739 +               else
2740 +                       m_bHasWarning = false;
2741 +       }
2742 +
2743 +       /**
2744 +        * Returns the currently set warning value
2745 +        * .
2746 +        * @param none
2747 +        * @return pointer to the warning string
2748 +        **/
2749 +       const char* getWarning()
2750 +       {
2751 +               m_bHasWarning = false;
2752 +               return m_sWarning.c_str();
2753 +       }
2754 +
2755 +//
2756 +// protected internal variables
2757 +//
2758 +protected:
2759 +       bool   m_bHasError;
2760 +       string m_sError;
2761 +       bool   m_bHasWarning;
2762 +       string m_sWarning;
2763 +};
2764 +
2765 +#endif
2766 Index: xmlspec/XMLChangelog.cpp
2767 ===================================================================
2768 RCS file: xmlspec/XMLChangelog.cpp
2769 diff -N xmlspec/XMLChangelog.cpp
2770 --- /dev/null   1 Jan 1970 00:00:00 -0000
2771 +++ rpm/xmlspec/XMLChangelog.cpp        28 Aug 2002 10:52:43 -0000      1.3.2.1
2772 @@ -0,0 +1,237 @@
2773 +// standard C++ includes
2774 +#include <string>
2775 +
2776 +// our includes
2777 +#include "XMLChangelog.h"
2778 +#include "XMLMisc.h"
2779 +#include "XMLRPMWrap.h"
2780 +#include "XMLSpec.h"
2781 +
2782 +using namespace std;
2783 +
2784 +bool XMLChangelogEntry::parseCreate(XMLAttrs* pAttrs,
2785 +                                                                       const char* szChange,
2786 +                                                                       XMLSpec* pSpec)
2787 +{
2788 +       if (!pSpec)
2789 +               return false;
2790 +       XMLChangelogEntry change(szChange);
2791 +       pSpec->getChangelog().lastDate().addEntry(change);
2792 +       return true;
2793 +}
2794 +
2795 +bool XMLChangelogEntry::structCreate(const char* szEntries,
2796 +                                                                        XMLSpec* pXSpec)
2797 +{
2798 +       if (!pXSpec || !szEntries)
2799 +               return false;
2800 +       char* szIn = (char*)szEntries;
2801 +       char* szOut = NULL;
2802 +       int nLen = -1;
2803 +       string sChange;
2804 +       while (nLen != 0) {
2805 +               szOut = splitStr(szIn, '\n', nLen);
2806 +               if (strncmp(szIn, "- ", 2) == 0) {
2807 +                       szIn += 2;
2808 +                       nLen -= 2;
2809 +                       if (sChange.length()) {
2810 +                               XMLChangelogEntry change(sChange.c_str());
2811 +                               pXSpec->getChangelog().lastDate().addEntry(change);
2812 +                       }
2813 +                       sChange.assign("");
2814 +               }
2815 +               sChange.append(szIn, nLen);
2816 +               szIn = szOut;
2817 +       }
2818 +       if (sChange.length()) {
2819 +               XMLChangelogEntry change(sChange.c_str());
2820 +               pXSpec->getChangelog().lastDate().addEntry(change);
2821 +       }
2822 +       return true;
2823 +}
2824 +
2825 +XMLChangelogEntry::XMLChangelogEntry(const char* szChange)
2826 +       : XMLBase()
2827 +{
2828 +       m_sChange.assign(szChange);
2829 +}
2830 +
2831 +XMLChangelogEntry::XMLChangelogEntry(const XMLChangelogEntry& rEntry)
2832 +       : XMLBase()
2833 +{
2834 +       m_sChange.assign(rEntry.m_sChange);
2835 +}
2836 +
2837 +XMLChangelogEntry::~XMLChangelogEntry()
2838 +{
2839 +}
2840 +
2841 +void XMLChangelogEntry::toSpecFile(ostream& rOut)
2842 +{
2843 +       rOut << endl << "- " << getChange();
2844 +}
2845 +
2846 +void XMLChangelogEntry::toXMLFile(ostream& rOut)
2847 +{
2848 +       rOut << endl << "\t\t\t<change>" << getChange() << "</change>";
2849 +}
2850 +
2851 +// attribute structure for XMLChangelogDate
2852 +structValidAttrs g_paChangelogDateAttrs[] =
2853 +{
2854 +       {0x0000,    true,  false, "date",         XATTRTYPE_DATE,   {NULL}},
2855 +       {0x0001,    true,  false, "author",       XATTRTYPE_STRING, {"*", NULL}},
2856 +       {0x0002,    false, false, "author-email", XATTRTYPE_MAIL,   {NULL}},
2857 +       {0x0003,    false, false, "version",      XATTRTYPE_STRING, {"*", NULL}},
2858 +       {XATTR_END, false, false, "end",          XATTRTYPE_NONE,   {NULL}}
2859 +};
2860 +
2861 +bool XMLChangelogDate::parseCreate(XMLAttrs* pAttrs,
2862 +                                                                  XMLSpec* pSpec)
2863 +{
2864 +       // validate our attributes
2865 +       if (!pAttrs->validate(g_paChangelogDateAttrs, (XMLBase*)pSpec))
2866 +               return false;
2867 +
2868 +       XMLChangelogDate date(pAttrs->asString("date"),
2869 +                                                 pAttrs->asString("author"),
2870 +                                                 pAttrs->asString("author-email"),
2871 +                                                 pAttrs->asString("version"));
2872 +       pSpec->getChangelog().addDate(date);
2873 +       return true;
2874 +}
2875 +
2876 +bool XMLChangelogDate::structCreate(const char* szDate,
2877 +                                                                       const char* szName,
2878 +                                                                       const char* szEntries,
2879 +                                                                       XMLSpec* pXSpec)
2880 +{
2881 +       if (!szDate || !szName || !szEntries || ! pXSpec)
2882 +               return false;
2883 +       time_t tTime = (time_t)(atol(szDate)) - timezone;
2884 +       struct tm *sTime = gmtime(&tTime);
2885 +       sTime->tm_year += 1900;
2886 +       char szTmp[32];
2887 +       sprintf(szTmp,"%s %s %d %d", g_szaDays[sTime->tm_wday],
2888 +                                                                 g_szaMonths[sTime->tm_mon],
2889 +                                                                 sTime->tm_mday, sTime->tm_year);
2890 +       XMLChangelogDate date(szTmp, szName, NULL, NULL);
2891 +       pXSpec->getChangelog().addDate(date);
2892 +       XMLChangelogEntry::structCreate(szEntries, pXSpec);
2893 +       return true;
2894 +}
2895 +
2896 +XMLChangelogDate::XMLChangelogDate(const char* szDate,
2897 +                                                                  const char* szAuthor,
2898 +                                                                  const char* szEmail,
2899 +                                                                  const char* szVersion)
2900 +       : XMLBase()
2901 +{
2902 +       if (szDate)
2903 +               m_sDate.assign(szDate);
2904 +       if (szAuthor)
2905 +               m_sAuthor.assign(szAuthor);
2906 +       if (szEmail)
2907 +               m_sEmail.assign(szEmail);
2908 +       if (szVersion)
2909 +               m_sVersion.assign(szVersion);
2910 +}
2911 +
2912 +XMLChangelogDate::XMLChangelogDate(const XMLChangelogDate& rDate)
2913 +       : XMLBase()
2914 +{
2915 +       m_sDate.assign(rDate.m_sDate);
2916 +       m_sAuthor.assign(rDate.m_sAuthor);
2917 +       m_sEmail.assign(rDate.m_sEmail);
2918 +       m_sVersion.assign(rDate.m_sVersion);
2919 +       m_vEntries = rDate.m_vEntries;
2920 +}
2921 +
2922 +XMLChangelogDate::~XMLChangelogDate()
2923 +{
2924 +}
2925 +
2926 +void XMLChangelogDate::toSpecFile(ostream& rOut)
2927 +{
2928 +       rOut << endl << "* " << getDate() << " " << getAuthor();
2929 +       if (hasEmail())
2930 +               rOut << " <" << getEmail() << ">";
2931 +       if (hasVersion())
2932 +               rOut << " " << getVersion();
2933 +       for (unsigned int i = 0; i < numEntries(); i++)
2934 +               getEntry(i).toSpecFile(rOut);
2935 +       rOut << endl;
2936 +}
2937 +
2938 +void XMLChangelogDate::toXMLFile(ostream& rOut)
2939 +{
2940 +       rOut << endl << "\t\t<changes date=\"" << getDate() << "\"";
2941 +       rOut << endl << "\t\t         author=\"" << getAuthor() << "\"";
2942 +       if (hasEmail())
2943 +               rOut << endl << "\t\t         author-email=\"" << getEmail() << "\"";
2944 +       if (hasVersion())
2945 +               rOut << endl << "\t\t         version=\"" << getVersion() << "\"";
2946 +       rOut << ">";
2947 +       for (unsigned int i = 0; i < numEntries(); i++)
2948 +               getEntry(i).toXMLFile(rOut);
2949 +       rOut << endl << "\t\t</changes>";
2950 +}
2951 +
2952 +bool XMLChangelog::structCreate(Spec pSpec,
2953 +                                                               XMLSpec* pXSpec)
2954 +{
2955 +       if (!pXSpec || !pSpec || !pSpec->packages || !pSpec->packages->header)
2956 +               return false;
2957 +       // FIXME: it looks like RPM only stores the tomost date in the
2958 +       // spec file so we are only allowed to get that one instead of an
2959 +       // array of time_t's
2960 +       string sDates;
2961 +       t_StrVector svChanges;
2962 +       t_StrVector svNames;
2963 +       getRPMHeader(pSpec->packages->header, RPMTAG_CHANGELOGTIME, sDates);
2964 +       getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGNAME, svNames);
2965 +       getRPMHeaderArray(pSpec->packages->header, RPMTAG_CHANGELOGTEXT, svChanges);
2966 +       for (unsigned int i = 0; i < svNames.size(); i++)
2967 +               XMLChangelogDate::structCreate(sDates.c_str(), svNames[i].c_str(),
2968 +                                                                          svChanges[i].c_str(), pXSpec);
2969 +       return true;
2970 +}
2971 +
2972 +XMLChangelog::XMLChangelog()
2973 +       : XMLBase()
2974 +{
2975 +}
2976 +
2977 +XMLChangelog::XMLChangelog(const XMLChangelog& rChangelog)
2978 +       : XMLBase()
2979 +{
2980 +       m_vDates = rChangelog.m_vDates;
2981 +}
2982 +
2983 +XMLChangelog::~XMLChangelog()
2984 +{
2985 +}
2986 +
2987 +void XMLChangelog::toSpecFile(ostream& rOut)
2988 +{
2989 +       if (numDates()) {
2990 +               rOut << endl << "%changelog";
2991 +               for (unsigned int i = 0; i < numDates(); i++)
2992 +                       getDate(i).toSpecFile(rOut);
2993 +               rOut << endl;
2994 +       }
2995 +}
2996 +
2997 +void XMLChangelog::toXMLFile(ostream& rOut)
2998 +{
2999 +       if (numDates()) {
3000 +               rOut << endl << "\t<changelog>";
3001 +               for (unsigned int i = 0; i < numDates(); i++)
3002 +                       getDate(i).toXMLFile(rOut);
3003 +               rOut << endl << "\t</changelog>";
3004 +       }
3005 +}
3006 +
3007 +void XMLChangelog::toRPMStruct(Spec spec)
3008 +{
3009 +}
3010 Index: xmlspec/XMLChangelog.h
3011 ===================================================================
3012 RCS file: xmlspec/XMLChangelog.h
3013 diff -N xmlspec/XMLChangelog.h
3014 --- /dev/null   1 Jan 1970 00:00:00 -0000
3015 +++ rpm/xmlspec/XMLChangelog.h  28 Aug 2002 10:52:43 -0000      1.3.2.1
3016 @@ -0,0 +1,458 @@
3017 +#ifndef _H_XMLCHANGELOG_
3018 +#define _H_XMLCHANGELOG_
3019 +
3020 +// standard C++ includes
3021 +#include <iostream>
3022 +#include <string>
3023 +#include <vector>
3024 +
3025 +// standard includes
3026 +#include <stdio.h>
3027 +
3028 +// our includes
3029 +#include "XMLAttrs.h"
3030 +#include "XMLBase.h"
3031 +
3032 +// rpm includes
3033 +#include <rpmbuild.h>
3034 +
3035 +// forward class definitions
3036 +class XMLSpec;
3037 +class XMLChangelog;
3038 +
3039 +using namespace std;
3040 +
3041 +class XMLChangelogEntry : public XMLBase
3042 +{
3043 +//
3044 +// factory functions
3045 +//
3046 +public:
3047 +       /**
3048 +        * Adds a changelog entry
3049 +        * .
3050 +        * @param pAttrs  The XML attributes
3051 +        * @param szEntry The entry to create
3052 +        * @param pSpec   Pointer to our spec
3053 +        * @return true on success, false othersise
3054 +        */
3055 +       static bool parseCreate(XMLAttrs* pAttrs,
3056 +                                                       const char* szEntry,
3057 +                                                       XMLSpec* pSpec);
3058 +
3059 +
3060 +       /**
3061 +        * Creates changelog entries from the data provided to us by RPM
3062 +        * @param szEntries The netries we are to evaluate
3063 +        * @param pXSpec pointer to the XML spec we are working with
3064 +        * @return true on success,. false otherwise
3065 +        **/
3066 +       static bool structCreate(const char* szEntries,
3067 +                                                        XMLSpec* pXSpec);
3068 +
3069 +//
3070 +// constructors/destructor
3071 +//
3072 +public:
3073 +       /**
3074 +        * Default contructor
3075 +        * .
3076 +        * @param szChange The change entry
3077 +        * @return none
3078 +        **/
3079 +        XMLChangelogEntry(const char* szChange);
3080 +
3081 +        /**
3082 +         * Copy constructor
3083 +         * .
3084 +         * @param rEntry Reference to the entry to copy
3085 +         * @return none
3086 +         **/
3087 +         XMLChangelogEntry(const XMLChangelogEntry& rEntry);
3088 +
3089 +        /**
3090 +         * Destructor
3091 +         * .
3092 +         * @param none
3093 +         * @return none
3094 +         **/
3095 +         ~XMLChangelogEntry();
3096 +
3097 +//
3098 +// member functions
3099 +//
3100 +public:
3101 +       /**
3102 +        * Outputs the object into a spec file
3103 +        * .
3104 +        * @param rOut Reference to our output stream
3105 +        * @return none
3106 +        **/
3107 +       void toSpecFile(ostream& rOut);
3108 +
3109 +       /**
3110 +        * Outputs the object into an XML spec file
3111 +        * .
3112 +        * @param rOut Reference to our output stream
3113 +        * @return none
3114 +        **/
3115 +        void toXMLFile(ostream& rOut);
3116 +
3117 +//
3118 +// member variable get/set functions
3119 +//
3120 +public:
3121 +       /**
3122 +        * Returns the enrty
3123 +        * .
3124 +        * @param none
3125 +        * @return string containing the entry
3126 +        **/
3127 +        const char* getChange()
3128 +        {
3129 +               return m_sChange.c_str();
3130 +        }
3131 +
3132 +//
3133 +// member variables
3134 +//
3135 +public:
3136 +       string m_sChange;
3137 +};
3138 +
3139 +class XMLChangelogDate : public XMLBase
3140 +{
3141 +//
3142 +// factory functions
3143 +//
3144 +public:
3145 +       /**
3146 +        * Creates a XMLChangelogDate object
3147 +        * .
3148 +        * @param pAttrs The XML attributes
3149 +        * @param pSpec The spec to add this object to
3150 +        * @return true on success, false otherwise
3151 +        **/
3152 +       static bool parseCreate(XMLAttrs* pAttrs,
3153 +                                                       XMLSpec* pSpec);
3154 +
3155 +       /**
3156 +        * Creates an XMLChangelogDate object from the information provided to
3157 +        * us by RPM
3158 +        * .
3159 +        * @param szDate The date to generate this for
3160 +        * @param szEntries The entries to add to this date
3161 +        * @param pXSpec The XML spec we are working with
3162 +        * @return true on success, false otherwise
3163 +        **/
3164 +       static bool structCreate(const char* szDate,
3165 +                                                        const char* szName,
3166 +                                                        const char* szEntries,
3167 +                                                        XMLSpec* pXSpec);
3168 +
3169 +//
3170 +// constructors/destructor
3171 +//
3172 +public:
3173 +       /**
3174 +        * Default contructor
3175 +        * .
3176 +        * @param szDate The date
3177 +        * @param szAuthor The author
3178 +        * @param szEmail The author's email
3179 +        * @param szVersion The version in which this change was made
3180 +        * @return none
3181 +        **/
3182 +       XMLChangelogDate(const char* szDate,
3183 +                                        const char* szAuthor,
3184 +                                        const char* szEmail,
3185 +                                        const char* szVersion);
3186 +
3187 +       /**
3188 +        * Copy contructor
3189 +        * .
3190 +        * @param rDate Reference to the date object to copy
3191 +        * @return none
3192 +        **/
3193 +       XMLChangelogDate(const XMLChangelogDate& rDate);
3194 +
3195 +       /**
3196 +        * Destructor
3197 +        * .
3198 +        * @param none
3199 +        * @return none
3200 +        **/
3201 +       ~XMLChangelogDate();
3202 +
3203 +//
3204 +// public member functions
3205 +//
3206 +public:
3207 +       /**
3208 +        * Outputs the object into a spec file
3209 +        * .
3210 +        * @param rOut Reference to our output stream
3211 +        * @return none
3212 +        **/
3213 +       void toSpecFile(ostream& rOut);
3214 +
3215 +       /**
3216 +        * Outputs the object into an XML spec file
3217 +        * .
3218 +        * @param rOut Reference to our output stream
3219 +        * @return none
3220 +        **/
3221 +        void toXMLFile(ostream& rOut);
3222 +
3223 +//
3224 +// member variables get/set functions
3225 +//
3226 +public:
3227 +       /**
3228 +        * Returns the date for the group of entries
3229 +        * .
3230 +        * @param none
3231 +        * @return string representation of the date
3232 +        **/
3233 +       const char* getDate()
3234 +       {
3235 +               return m_sDate.c_str();
3236 +       }
3237 +
3238 +       /**
3239 +        * Checks for an author
3240 +        * .
3241 +        * @param none
3242 +        * @return true if we have an author, false otherwise
3243 +        **/
3244 +       bool hasAuthor()
3245 +       {
3246 +               return m_sAuthor.length() ? true : false;
3247 +       }
3248 +
3249 +       /**
3250 +        * Returns the author's name
3251 +        * .
3252 +        * @param none
3253 +        * @return string containing the author's name
3254 +        **/
3255 +       const char* getAuthor()
3256 +       {
3257 +               return m_sAuthor.c_str();
3258 +       }
3259 +
3260 +       /**
3261 +        * Checks if we have an email address for the author
3262 +        * .
3263 +        * @param none
3264 +        * @return true if we hava an email, false otherwise
3265 +        **/
3266 +       bool hasEmail()
3267 +       {
3268 +               return m_sEmail.length() ? true : false;
3269 +       }
3270 +
3271 +       /**
3272 +        * Returns the author's email addresse
3273 +        * .
3274 +        * @param none
3275 +        * @return a string containing the author's email address
3276 +        **/
3277 +       const char* getEmail()
3278 +       {
3279 +               return m_sEmail.c_str();
3280 +       }
3281 +
3282 +       /**
3283 +        * Checks if we have a change version
3284 +        * .
3285 +        * @param none
3286 +        * @return true if we have a version, false otherwise
3287 +        **/
3288 +       bool hasVersion()
3289 +       {
3290 +               return m_sVersion.length() ? true : false;
3291 +       }
3292 +
3293 +       /**
3294 +        * Gets the change version
3295 +        * .
3296 +        * @param none
3297 +        * @return string containing the version
3298 +        **/
3299 +       const char* getVersion()
3300 +       {
3301 +               return m_sVersion.c_str();
3302 +       }
3303 +
3304 +       /**
3305 +        * Returns the number of entries for this date
3306 +        * .
3307 +        * @param none
3308 +        * @return the number of entries
3309 +        **/
3310 +       unsigned int numEntries()
3311 +       {
3312 +               return m_vEntries.size();
3313 +       }
3314 +
3315 +       /**
3316 +        * Returns a specific entry
3317 +        * .
3318 +        * @param nNum The number of the entry to return
3319 +        * @return the enrty
3320 +        **/
3321 +       XMLChangelogEntry& getEntry(unsigned int nNum)
3322 +       {
3323 +               return m_vEntries[nNum];
3324 +       }
3325 +
3326 +       /**
3327 +        * Adds an entry for this date
3328 +        * .
3329 +        * @param szEntry The entry to add
3330 +        * @return none
3331 +        **/
3332 +       void addEntry(XMLChangelogEntry& rEntry)
3333 +       {
3334 +               m_vEntries.push_back(rEntry);
3335 +       }
3336 +
3337 +//
3338 +// member variables
3339 +//
3340 +protected:
3341 +       string                    m_sDate;
3342 +       string                    m_sAuthor;
3343 +       string                    m_sEmail;
3344 +       string                    m_sVersion;
3345 +       vector<XMLChangelogEntry> m_vEntries;
3346 +};
3347 +
3348 +class XMLChangelog : public XMLBase
3349 +{
3350 +//
3351 +// static factory functions
3352 +//
3353 +public:
3354 +       /**
3355 +        * Creates changelog objects from an RPM Spec structure
3356 +        * .
3357 +        * @param pSpec Pointer to the RPM spec
3358 +        * @param pXSpec pointer to the XMLSpec object to populate
3359 +        * @return true on success, false otherwise
3360 +        **/
3361 +       static bool structCreate(Spec pSpec,
3362 +                                                        XMLSpec* pXSpec);
3363 +
3364 +//
3365 +// constructors/destructor
3366 +//
3367 +public:
3368 +       /**
3369 +        * Default constructor
3370 +        * .
3371 +        * @param none
3372 +        * @return none
3373 +        **/
3374 +       XMLChangelog();
3375 +
3376 +       /**
3377 +        * Copy constructor
3378 +        * .
3379 +        * @param rChangelog The object to copy
3380 +        * @return none
3381 +        **/
3382 +       XMLChangelog(const XMLChangelog& rChangelog);
3383 +
3384 +       /**
3385 +        * Destructor
3386 +        * .
3387 +        * @param none
3388 +        * @return none
3389 +        **/
3390 +       ~XMLChangelog();
3391 +
3392 +//
3393 +// public member functions
3394 +//
3395 +public:
3396 +       /**
3397 +        * Converts the object into a spec file
3398 +        * .
3399 +        * @param rOut Reference to the output stream
3400 +        * @return none
3401 +        **/
3402 +       void toSpecFile(ostream& rOut);
3403 +
3404 +       /**
3405 +        * Converts the object into an xML spec
3406 +        * .
3407 +        * @param rOut Reference to the output stream
3408 +        * @return none
3409 +        **/
3410 +        void toXMLFile(ostream& rOut);
3411 +
3412 +        /**
3413 +         * Converts the object into an RPM structure
3414 +         * .
3415 +         * @param spec RPM structure
3416 +         * @return none
3417 +         **/
3418 +         void toRPMStruct(Spec spec);
3419 +//
3420 +// variable get/set functions
3421 +//
3422 +public:
3423 +       /**
3424 +        * Adds a date to the changelog
3425 +        * .
3426 +        * @param rDate The date to add
3427 +        * @return none
3428 +        **/
3429 +       void addDate(XMLChangelogDate& rDate)
3430 +       {
3431 +               m_vDates.push_back(rDate);
3432 +       }
3433 +
3434 +       /**
3435 +        * Returns the number of dates in the changelog
3436 +        * .
3437 +        * @param none
3438 +        * @return the number of dates
3439 +        **/
3440 +       unsigned int numDates()
3441 +       {
3442 +               return m_vDates.size();
3443 +       }
3444 +
3445 +       /**
3446 +        * Gets a specific date
3447 +        * .
3448 +        * @param nNum The entry number
3449 +        * @return The requated date
3450 +        **/
3451 +       XMLChangelogDate& getDate(unsigned int nNum)
3452 +       {
3453 +               return m_vDates[nNum];
3454 +       }
3455 +
3456 +       /**
3457 +        * Gets the last date we have added
3458 +        * .
3459 +        * @param none
3460 +        * @return the last date
3461 +        **/
3462 +       XMLChangelogDate& lastDate()
3463 +       {
3464 +               return m_vDates[numDates()-1];
3465 +       }
3466 +
3467 +//
3468 +// member variables
3469 +//
3470 +protected:
3471 +       vector<XMLChangelogDate> m_vDates;
3472 +};
3473 +
3474 +#endif
3475 Index: xmlspec/XMLFiles.cpp
3476 ===================================================================
3477 RCS file: xmlspec/XMLFiles.cpp
3478 diff -N xmlspec/XMLFiles.cpp
3479 --- /dev/null   1 Jan 1970 00:00:00 -0000
3480 +++ rpm/xmlspec/XMLFiles.cpp    28 Aug 2002 10:52:43 -0000      1.3.2.1
3481 @@ -0,0 +1,200 @@
3482 +// standard includes
3483 +#include <stdio.h>
3484 +
3485 +// our includes
3486 +#include "XMLAttrs.h"
3487 +#include "XMLFiles.h"
3488 +#include "XMLPackage.h"
3489 +#include "XMLSpec.h"
3490 +
3491 +// rpm includes
3492 +#include <rpmlib.h>
3493 +#include <stringbuf.h>
3494 +
3495 +using namespace std;
3496 +
3497 +// attribute structure for XMLFile
3498 +structValidAttrs g_paFileAttrs[] =
3499 +{
3500 +       {0x0000,    false, false, "mode",   XATTRTYPE_INTEGER, {NULL}},
3501 +       {0x0001,    false, false, "group",  XATTRTYPE_STRING,  {"*", NULL}},
3502 +       {0x0002,    false, false, "user",   XATTRTYPE_STRING,  {"*", NULL}},
3503 +       {0x0003,    false, false, "config", XATTRTYPE_STRING,  {"noreplace",
3504 +                                                                                                                       "*", NULL}},
3505 +       {XATTR_END, false, false, "end",    XATTRTYPE_NONE,    {NULL}}
3506 +};
3507 +
3508 +bool XMLFile::parseCreate(XMLAttrs* pAttrs,
3509 +                                                 const char* szPath,
3510 +                                                 XMLSpec* pSpec)
3511 +{
3512 +       // validate the attributes
3513 +       if (!pSpec || !pAttrs->validate(g_paFileAttrs, (XMLBase*)pSpec))
3514 +               return false;
3515 +
3516 +       // create and return
3517 +       XMLFile file(pAttrs->asString("mode"), pAttrs->asString("user"),
3518 +                                pAttrs->asString("group"), pAttrs->asString("config"), szPath);
3519 +       pSpec->lastPackage().getFiles().addFile(file);
3520 +       return true;
3521 +}
3522 +
3523 +XMLFile::XMLFile(const char* szMode,
3524 +                                const char* szOwner,
3525 +                                const char* szGroup,
3526 +                                const char* szConfig,
3527 +                                const char* szPath)
3528 +       : XMLBase()
3529 +{
3530 +       if (szMode)
3531 +               m_sMode.assign(szMode);
3532 +       if (szOwner)
3533 +               m_sOwner.assign(szOwner);
3534 +       if (szGroup)
3535 +               m_sGroup.assign(szGroup);
3536 +       if (szConfig)
3537 +               m_sConfig.assign(szConfig);
3538 +       if (szPath)
3539 +               m_sPath.assign(szPath);
3540 +}
3541 +
3542 +XMLFile::XMLFile(const XMLFile& rFile)
3543 +       : XMLBase()
3544 +{
3545 +       setMode(rFile.m_sMode.c_str());
3546 +       setOwner(rFile.m_sOwner.c_str());
3547 +       setGroup(rFile.m_sGroup.c_str());
3548 +       setConfig(rFile.m_sConfig.c_str());
3549 +       setPath(rFile.m_sPath.c_str());
3550 +}
3551 +
3552 +XMLFile::~XMLFile()
3553 +{
3554 +}
3555 +
3556 +XMLFile XMLFile::operator=(XMLFile file)
3557 +{
3558 +       setMode(file.m_sMode.c_str());
3559 +       setOwner(file.m_sOwner.c_str());
3560 +       setGroup(file.m_sGroup.c_str());
3561 +       setConfig(file.m_sConfig.c_str());
3562 +       setPath(file.m_sPath.c_str());
3563 +}
3564 +
3565 +void XMLFile::toSpecFile(ostream& rOut)
3566 +{
3567 +       if (hasMode() || hasOwner() || hasGroup()) {
3568 +               rOut << "%attr(";
3569 +               rOut << (hasMode() ? getMode() : "-");
3570 +               rOut << "," << (hasOwner() ? getOwner() : "-");
3571 +               rOut << "," << (hasGroup() ? getGroup() : "-");
3572 +               rOut << ") ";
3573 +       }
3574 +       if (hasConfig()) {
3575 +               rOut << "%config(" << getConfig() << ") ";
3576 +       }
3577 +       rOut << getPath() << endl;
3578 +}
3579 +
3580 +void XMLFile::toXMLFile(ostream& rOut)
3581 +{
3582 +       rOut << endl << "\t\t\t<file";
3583 +       if (hasMode())
3584 +               rOut << " mode=\"" << getMode() << "\"";
3585 +       if (hasOwner())
3586 +               rOut << " user=\"" << getOwner() << "\"";
3587 +       if (hasGroup())
3588 +               rOut << " group=\"" << getGroup() << "\"";
3589 +       if (hasConfig())
3590 +               rOut << " config=\"" << getConfig() << "\"";
3591 +       rOut << ">";
3592 +       rOut << getPath() << "</file>";
3593 +}
3594 +
3595 +// attribute structure for XMLFiles
3596 +structValidAttrs g_paFilesAttrs[] =
3597 +{
3598 +       {0x0000,    false, false, "mode",  XATTRTYPE_INTEGER, {NULL}},
3599 +       {0x0001,    false, false, "group", XATTRTYPE_STRING,  {"*", NULL}},
3600 +       {0x0002,    false, false, "user",  XATTRTYPE_STRING,  {"*", NULL}},
3601 +       {XATTR_END, false, false, "end",   XATTRTYPE_NONE,    {NULL}}
3602 +};
3603 +
3604 +bool XMLFiles::parseCreate(XMLAttrs* pAttrs,
3605 +                                                  XMLSpec* pSpec)
3606 +{
3607 +       if (!pSpec || !pAttrs->validate(g_paFilesAttrs, (XMLBase*)pSpec))
3608 +               return false;
3609 +       pSpec->lastPackage().getFiles().setDefMode(pAttrs->asString("mode"));
3610 +       pSpec->lastPackage().getFiles().setDefOwner(pAttrs->asString("user"));
3611 +       pSpec->lastPackage().getFiles().setDefGroup(pAttrs->asString("group"));
3612 +       return true;
3613 +}
3614 +
3615 +bool XMLFiles::structCreate(PackageStruct* pPackage,
3616 +                                                       Spec pSpec,
3617 +                                                       XMLSpec* pXSpec)
3618 +{
3619 +       if (!pXSpec || !pSpec || !pPackage || !pPackage->fileList)
3620 +               return false;
3621 +       return true;
3622 +}
3623 +
3624 +XMLFiles::XMLFiles()
3625 +       : XMLBase()
3626 +{
3627 +}
3628 +
3629 +XMLFiles::XMLFiles(const XMLFiles& rFiles)
3630 +       : XMLBase()
3631 +{
3632 +       setDefMode(rFiles.m_sMode.c_str());
3633 +       setDefOwner(rFiles.m_sOwner.c_str());
3634 +       setDefGroup(rFiles.m_sGroup.c_str());
3635 +       m_vFiles = rFiles.m_vFiles;
3636 +}
3637 +
3638 +XMLFiles::~XMLFiles()
3639 +{
3640 +}
3641 +
3642 +XMLFiles XMLFiles::operator=(XMLFiles files)
3643 +{
3644 +       setDefMode(files.m_sMode.c_str());
3645 +       setDefOwner(files.m_sOwner.c_str());
3646 +       setDefGroup(files.m_sGroup.c_str());
3647 +       m_vFiles = files.m_vFiles;
3648 +       return *this;
3649 +}
3650 +
3651 +void XMLFiles::toSpecFile(ostream& rOut)
3652 +{
3653 +       if (numFiles()) {
3654 +               if (hasDefMode() || hasDefOwner() || hasDefGroup()) {
3655 +                       rOut << "%defattr(";
3656 +                       rOut << (hasDefMode() ? getDefMode() : "-");
3657 +                       rOut << "," << (hasDefOwner() ? getDefOwner() : "-");
3658 +                       rOut << "," << (hasDefGroup() ? getDefGroup() : "-");
3659 +                       rOut << ")" << endl;
3660 +               }
3661 +               for (unsigned int i = 0; i < numFiles(); i++)
3662 +                       getFile(i).toSpecFile(rOut);
3663 +       }
3664 +}
3665 +
3666 +void XMLFiles::toXMLFile(ostream& rOut)
3667 +{
3668 +       if (numFiles()) {
3669 +               rOut << endl << "\t\t<files";
3670 +               if (hasDefMode())
3671 +                       rOut << " mode=\"" << getDefMode() << "\"";
3672 +               if (hasDefOwner())
3673 +                       rOut << " user=\"" << getDefOwner() << "\"";
3674 +               if (hasDefGroup())
3675 +                       rOut << " group=\"" << getDefGroup() << "\"";
3676 +               rOut << ">";
3677 +               for (unsigned int i = 0; i < numFiles(); i++)
3678 +                       getFile(i).toXMLFile(rOut);
3679 +               rOut << endl << "\t\t</files>";
3680 +       }
3681 +}
3682 Index: xmlspec/XMLFiles.h
3683 ===================================================================
3684 RCS file: xmlspec/XMLFiles.h
3685 diff -N xmlspec/XMLFiles.h
3686 --- /dev/null   1 Jan 1970 00:00:00 -0000
3687 +++ rpm/xmlspec/XMLFiles.h      28 Aug 2002 10:52:43 -0000      1.3.2.1
3688 @@ -0,0 +1,526 @@
3689 +#ifndef _H_XMLFILES_
3690 +#define _H_XMLFILES_
3691 +
3692 +// standard C++ includes
3693 +#include <iostream>
3694 +#include <string>
3695 +#include <vector>
3696 +
3697 +// standard includes
3698 +#include <stdio.h>
3699 +
3700 +// our includes
3701 +#include "XMLAttrs.h"
3702 +#include "XMLBase.h"
3703 +
3704 +// rpm includes
3705 +#include <rpmbuild.h>
3706 +
3707 +// forward class definitions
3708 +class XMLPackage;
3709 +class XMLFiles;
3710 +class XMLSpec;
3711 +
3712 +using namespace std;
3713 +
3714 +// <file ...>
3715 +class XMLFile : public XMLBase
3716 +{
3717 +//
3718 +// object creation static functions
3719 +//
3720 +public:
3721 +       /**
3722 +        * Creates a file object and add it to the correct XMLFiles
3723 +        * container.
3724 +        * .
3725 +        * @param pAttrs The attributes in the XML tag
3726 +        * @param szPath The file path
3727 +        * @param pSpec The spec to which these files belong
3728 +        * @return true on success, false otherwise
3729 +        **/
3730 +       static bool parseCreate(XMLAttrs* pAttrs,
3731 +                                                       const char* szPath,
3732 +                                                       XMLSpec* pSpec);
3733 +
3734 +//
3735 +// constructors/destructor
3736 +//
3737 +public:
3738 +       /**
3739 +        * Default contructor
3740 +        * .
3741 +        * @param szMode The file's mode (NULL if default)
3742 +        * @param szOwner The file's owner (NULL if default)
3743 +        * @param szGroup The file's group (NULL if default)
3744 +        * @param szConfig The configuration parameter
3745 +        * @param szPath The file path
3746 +        * @return none
3747 +        **/
3748 +       XMLFile(const char* szMode,
3749 +                       const char* szUser,
3750 +                       const char* szGroup,
3751 +                       const char* szConfig,
3752 +                       const char* szPath);
3753 +
3754 +       /**
3755 +        * Copy constructire
3756 +        * .
3757 +        * @param rFile Reference to the object to copy
3758 +        * @return none
3759 +        **/
3760 +        XMLFile(const XMLFile& rFile);
3761 +
3762 +       /**
3763 +        * Default destructor
3764 +        * .
3765 +        * @param none
3766 +        * @return none
3767 +        **/
3768 +       ~XMLFile();
3769 +
3770 +//
3771 +// operators
3772 +//
3773 +public:
3774 +       /**
3775 +        * Assignment operator
3776 +        * .
3777 +        * @param file The file that we wish to copy
3778 +        * @return a copy of the original
3779 +        **/
3780 +       XMLFile operator=(XMLFile file);
3781 +
3782 +//
3783 +// member functions
3784 +//
3785 +public:
3786 +       /**
3787 +        * Outputs the obkect to an RPM spec file
3788 +        * .
3789 +        * @param rOut Reference to the output stream
3790 +        * @return none
3791 +        **/
3792 +       void toSpecFile(ostream& rOut);
3793 +
3794 +       /**
3795 +        * Outputs the object to an XML spec file
3796 +        * .
3797 +        * @param rOut Reference to the output stream
3798 +        * @return none
3799 +        **/
3800 +        void toXMLFile(ostream& rOut);
3801 +
3802 +//
3803 +// member variable get/set functions
3804 +//
3805 +public:
3806 +       /**
3807 +        * Returns the file path
3808 +        * .
3809 +        * @param none
3810 +        * @return string containing the path
3811 +        **/
3812 +       const char* getPath()
3813 +       {
3814 +               return m_sPath.c_str();
3815 +       }
3816 +
3817 +       /**
3818 +        * Sets the file path
3819 +        * .
3820 +        * @param szPath The path to set
3821 +        * @return none
3822 +        **/
3823 +       void setPath(const char* szPath)
3824 +       {
3825 +               if (szPath)
3826 +                       m_sPath.assign(szPath);
3827 +       }
3828 +
3829 +       /**
3830 +        * Checks for a file mode
3831 +        * .
3832 +        * @param none
3833 +        * @return true if we have one, false otherwise
3834 +        **/
3835 +       bool hasMode()
3836 +       {
3837 +               return m_sMode.length() ? true : false;
3838 +       }
3839 +
3840 +       /**
3841 +        * Returns the file mode
3842 +        * .
3843 +        * @param none
3844 +        * @return the mode string
3845 +        **/
3846 +       const char* getMode()
3847 +       {
3848 +               return m_sMode.c_str();
3849 +       }
3850 +
3851 +       /**
3852 +        * Sets the file mode
3853 +        * .
3854 +        * @param szMode The mode to set
3855 +        * @return none
3856 +        **/
3857 +       void setMode(const char* szMode)
3858 +       {
3859 +               if (szMode)
3860 +                       m_sMode.assign(szMode);
3861 +       }
3862 +
3863 +       /**
3864 +        * Checks if we have a file owner
3865 +        * .
3866 +        * @param none
3867 +        * @return true if we have an owner, false otherwise
3868 +        **/
3869 +       bool hasOwner()
3870 +       {
3871 +               return m_sOwner.length() ? true : false;
3872 +       }
3873 +
3874 +       /**
3875 +        * Returns the file owner
3876 +        * .
3877 +        * @param none
3878 +        * @return the owner as a string
3879 +        **/
3880 +       const char* getOwner()
3881 +       {
3882 +               return m_sOwner.c_str();
3883 +       }
3884 +
3885 +       /**
3886 +        * Sets the file owner
3887 +        * .
3888 +        * @param szOwner The file owner
3889 +        * @return none
3890 +        **/
3891 +       void setOwner(const char* szOwner)
3892 +       {
3893 +               if (szOwner)
3894 +                       m_sOwner.assign(szOwner);
3895 +       }
3896 +
3897 +       /**
3898 +        * Checks for a file group
3899 +        * .
3900 +        * @param none
3901 +        * @return true if we have a group, false otherwise
3902 +        **/
3903 +       bool hasGroup()
3904 +       {
3905 +               return m_sGroup.length() ? true : false;
3906 +       }
3907 +
3908 +       /**
3909 +        * Returns the file group
3910 +        * .
3911 +        * @param none
3912 +        * @return string containing the group
3913 +        **/
3914 +       const char* getGroup()
3915 +       {
3916 +               return m_sGroup.c_str();
3917 +       }
3918 +
3919 +       /**
3920 +        * Sets the file group
3921 +        * .
3922 +        * @param szGroup The group to set
3923 +        * @return none
3924 +        **/
3925 +       void setGroup(const char* szGroup)
3926 +       {
3927 +               if (szGroup)
3928 +                       m_sGroup.assign(szGroup);
3929 +       }
3930 +
3931 +       /**
3932 +        * Checks for config directives
3933 +        * .
3934 +        * @param none
3935 +        * @return true if we have one, false otherwise
3936 +        **/
3937 +       bool hasConfig()
3938 +       {
3939 +               return m_sConfig.length() ? true : false;
3940 +       }
3941 +
3942 +       /**
3943 +        * Returns the config attribute
3944 +        * .
3945 +        * @param none
3946 +        * @return the sttribute string
3947 +        **/
3948 +       const char* getConfig()
3949 +       {
3950 +               return m_sConfig.c_str();
3951 +       }
3952 +
3953 +       /**
3954 +        * Sets the config attribute
3955 +        * .
3956 +        * @param szConfig The configuration
3957 +        * @return none
3958 +        **/
3959 +       void setConfig(const char* szConfig)
3960 +       {
3961 +               if (szConfig)
3962 +                       m_sConfig.assign(szConfig);
3963 +       }
3964 +
3965 +//
3966 +// member variables
3967 +//
3968 +protected:
3969 +       string m_sPath;
3970 +       string m_sMode;
3971 +       string m_sOwner;
3972 +       string m_sGroup;
3973 +       string m_sConfig;
3974 +};
3975 +
3976 +// <files ...>
3977 +class XMLFiles : public XMLBase
3978 +{
3979 +//
3980 +// object creation static functions
3981 +//
3982 +public:
3983 +       /**
3984 +        * Creates an object as parsed from an XML spec
3985 +        * .
3986 +        * @param pAttrs XML atrtributes to use
3987 +        * @param pSpec The spec to which we are adding this object to
3988 +        * @return true on success, false otherwise
3989 +        **/
3990 +       static bool parseCreate(XMLAttrs* pAttrs,
3991 +                                                       XMLSpec* pSpec);
3992 +
3993 +       /**
3994 +        * Creates file objects from an RPM Spec structure
3995 +        * .
3996 +        * @param pPackage Pointer to the package
3997 +        * @param pSpec Pointer to the RPM spec
3998 +        * @param pXSpec pointer to the XMLSpec object to populate
3999 +        * @return true on success, false otherwise
4000 +        **/
4001 +       static bool structCreate(PackageStruct* pPackage,
4002 +                                                        Spec pSpec,
4003 +                                                        XMLSpec* pXSpec);
4004 +
4005 +//
4006 +// constructors/destructor
4007 +//
4008 +public:
4009 +       /**
4010 +        * Default constructor
4011 +        * .
4012 +        * @param none
4013 +        * @return none
4014 +        **/
4015 +       XMLFiles();
4016 +
4017 +       /**
4018 +        * Copy constructor
4019 +        * .
4020 +        * @param rFiles Reference to the object to copy
4021 +        * @return none
4022 +        **/
4023 +       XMLFiles(const XMLFiles& rFiles);
4024 +
4025 +       /**
4026 +        * Destructor
4027 +        * .
4028 +        * @param none
4029 +        * @return none
4030 +        **/
4031 +       ~XMLFiles();
4032 +
4033 +//
4034 +// member functions
4035 +//
4036 +public:
4037 +       /**
4038 +        * Converts the object into an RPM spec
4039 +        * .
4040 +        * @param rOut Output stream
4041 +        * @return none
4042 +        **/
4043 +       void toSpecFile(ostream& rOut);
4044 +
4045 +       /**
4046 +        * Converts the object into an XML spec
4047 +        * .
4048 +        * @param rOut Output stream
4049 +        * @return none
4050 +        **/
4051 +       void toXMLFile(ostream& rOut);
4052 +
4053 +//
4054 +// operators
4055 +//
4056 +public:
4057 +       /**
4058 +        * Assignment operator
4059 +        * .
4060 +        * @param files XMLFiles object to copy
4061 +        * @return copied object
4062 +        **/
4063 +       XMLFiles operator=(XMLFiles files);
4064 +
4065 +//
4066 +// member variable get/set functions
4067 +//
4068 +public:
4069 +       /**
4070 +        * Adds a file to our file list
4071 +        * .
4072 +        * @param rFile File to add
4073 +        * @return none
4074 +        **/
4075 +       void addFile(XMLFile& rFile)
4076 +       {
4077 +               m_vFiles.push_back(rFile);
4078 +       }
4079 +
4080 +       /**
4081 +        * Returns the number of files in our list
4082 +        * .
4083 +        * @param none
4084 +        * @return none
4085 +        **/
4086 +       unsigned int numFiles()
4087 +       {
4088 +               return m_vFiles.size();
4089 +       }
4090 +
4091 +       /**
4092 +        * Returns a specific file
4093 +        * .
4094 +        * @param nNum Number of the file to return
4095 +        * @return the file object
4096 +        **/
4097 +       XMLFile& getFile(unsigned int nNum)
4098 +       {
4099 +               return m_vFiles[nNum];
4100 +       }
4101 +
4102 +       /**
4103 +        * Checks for a default mode
4104 +        * .
4105 +        * @param none
4106 +        * @return true if we have a default mode, false otherwise
4107 +        **/
4108 +       bool hasDefMode()
4109 +       {
4110 +               return m_sMode.length() ? true : false;
4111 +       }
4112 +
4113 +       /**
4114 +        * Sets the default mode
4115 +        * .
4116 +        * @param szMode The mode value
4117 +        * @return none
4118 +        **/
4119 +       void setDefMode(const char* szMode)
4120 +       {
4121 +               if (szMode)
4122 +                       m_sMode.assign(szMode);
4123 +       }
4124 +
4125 +       /**
4126 +        * Returns the default mode
4127 +        * .
4128 +        * @param none
4129 +        * @return string containing the mode
4130 +        **/
4131 +       const char* getDefMode()
4132 +       {
4133 +               return m_sMode.c_str();
4134 +       }
4135 +
4136 +       /**
4137 +        * Check if we have a default owner
4138 +        * .
4139 +        * @param none
4140 +        * @return true if we have an owner, false otherwise
4141 +        **/
4142 +       bool hasDefOwner()
4143 +       {
4144 +               return m_sOwner.length() ? true : false;
4145 +       }
4146 +
4147 +       /**
4148 +        * Sets the default owner
4149 +        * .
4150 +        * @param szOwner The owner
4151 +        * @return none
4152 +        **/
4153 +       void setDefOwner(const char* szOwner)
4154 +       {
4155 +               if (szOwner)
4156 +                       m_sOwner.assign(szOwner);
4157 +       }
4158 +
4159 +       /**
4160 +        * Returns the default owner
4161 +        * .
4162 +        * @param none
4163 +        * @return the owner string
4164 +        **/
4165 +       const char* getDefOwner()
4166 +       {
4167 +               return m_sOwner.c_str();
4168 +       }
4169 +
4170 +       /**
4171 +        * Checks if we have a default group
4172 +        * .
4173 +        * @param none
4174 +        * @return true if we have an owner, false otherwise
4175 +        **/
4176 +       bool hasDefGroup()
4177 +       {
4178 +               return m_sGroup.length() ? true : false;
4179 +       }
4180 +
4181 +       /**
4182 +        * Sets the default group
4183 +        * .
4184 +        * @param szGroup The group to set
4185 +        * @return none
4186 +        **/
4187 +       void setDefGroup(const char* szGroup)
4188 +       {
4189 +               if (szGroup)
4190 +                       m_sGroup.assign(szGroup);
4191 +       }
4192 +
4193 +       /**
4194 +        * Gets the default group
4195 +        * .
4196 +        * @param none
4197 +        * @return string representation of the group
4198 +        **/
4199 +       const char* getDefGroup()
4200 +       {
4201 +               return m_sGroup.c_str();
4202 +       }
4203 +
4204 +//
4205 +// member variables
4206 +//
4207 +protected:
4208 +       string          m_sMode;
4209 +       string          m_sOwner;
4210 +       string          m_sGroup;
4211 +       vector<XMLFile> m_vFiles;
4212 +};
4213 +
4214 +#endif
4215 Index: xmlspec/XMLMacro.cpp
4216 ===================================================================
4217 RCS file: xmlspec/XMLMacro.cpp
4218 diff -N xmlspec/XMLMacro.cpp
4219 --- /dev/null   1 Jan 1970 00:00:00 -0000
4220 +++ rpm/xmlspec/XMLMacro.cpp    28 Aug 2002 10:52:43 -0000      1.2.2.1
4221 @@ -0,0 +1,61 @@
4222 +// our includes
4223 +#include "XMLMacro.h"
4224 +#include "XMLSpec.h"
4225 +
4226 +using namespace std;
4227 +
4228 +// attribute structure for XMLMacro
4229 +structValidAttrs g_paMacroAttrs[] =
4230 +{
4231 +       {0x0000,    true,  false, "name", XATTRTYPE_STRING, {"*", NULL}},
4232 +       {XATTR_END, false, false, "end",  XATTRTYPE_NONE,   {NULL}}
4233 +};
4234 +
4235 +bool XMLMacro::parseCreate(XMLAttrs* pAttrs,
4236 +                                                  const char* szMacro,
4237 +                                                  XMLSpec* pSpec)
4238 +{
4239 +       if (!pSpec || !szMacro || !pAttrs->validate(g_paMacroAttrs, (XMLBase*)pAttrs))
4240 +               return false;
4241 +       XMLMacro macro(pAttrs->asString("name"), szMacro);
4242 +       pSpec->addXMacro(macro);
4243 +       return true;
4244 +}
4245 +
4246 +XMLMacro::XMLMacro(const char* szName,
4247 +                                  const char* szMacro)
4248 +       : XMLBase()
4249 +{
4250 +       if (szName)
4251 +               m_sName.assign(szName);
4252 +       if (szMacro)
4253 +               m_sValue.assign(szMacro);
4254 +}
4255 +
4256 +XMLMacro::XMLMacro(const XMLMacro& rMacro)
4257 +       : XMLBase()
4258 +{
4259 +       m_sName.assign(rMacro.m_sName);
4260 +       m_sValue.assign(rMacro.m_sValue);
4261 +}
4262 +
4263 +XMLMacro::~XMLMacro()
4264 +{
4265 +}
4266 +
4267 +XMLMacro XMLMacro::operator=(XMLMacro macro)
4268 +{
4269 +       m_sName.assign(macro.m_sName);
4270 +       m_sValue.assign(macro.m_sValue);
4271 +}
4272 +
4273 +void XMLMacro::toSpecFile(ostream& rOut)
4274 +{
4275 +       rOut << "%define " << getName() << " " << getValue() << endl;
4276 +}
4277 +
4278 +void XMLMacro::toXMLFile(ostream& rOut)
4279 +{
4280 +       rOut << endl << "\t<macro name=\"" << getName() << "\">";
4281 +       rOut << getValue() << "</macro>";
4282 +}
4283 Index: xmlspec/XMLMacro.h
4284 ===================================================================
4285 RCS file: xmlspec/XMLMacro.h
4286 diff -N xmlspec/XMLMacro.h
4287 --- /dev/null   1 Jan 1970 00:00:00 -0000
4288 +++ rpm/xmlspec/XMLMacro.h      28 Aug 2002 10:52:43 -0000      1.1.1.1.2.1
4289 @@ -0,0 +1,131 @@
4290 +#ifndef _H_XMLMACRO_
4291 +#define _H_XMLMACRO_
4292 +
4293 +// standard C++ includes
4294 +#include <iostream>
4295 +#include <string>
4296 +
4297 +// our includes
4298 +#include "XMLAttrs.h"
4299 +
4300 +// forward class definitions
4301 +class XMLSpec;
4302 +
4303 +using namespace std;
4304 +
4305 +//<macro ...>
4306 +class XMLMacro : public XMLBase
4307 +{
4308 +//
4309 +// factory functions
4310 +//
4311 +public:
4312 +       /**
4313 +        * Creates an XMLMacro object
4314 +        * .
4315 +        * @param pAttrs XML tag attributes
4316 +        * @param szMacro The macro contents
4317 +        * @param pSpec the spec to add the macro to
4318 +        * @return true on success, false otherwise
4319 +        **/
4320 +       static bool parseCreate(XMLAttrs* pAttrs,
4321 +                                                       const char* szMacro,
4322 +                                                       XMLSpec* pSpec);
4323 +
4324 +//
4325 +// constructors/destructor
4326 +//
4327 +public:
4328 +       /**
4329 +        * Default constructor
4330 +        * .
4331 +        * @param szName The name of the macro
4332 +        * @param szMacro The expanded macro
4333 +        * @return none
4334 +        **/
4335 +       XMLMacro(const char* szName,
4336 +                        const char* szMacro);
4337 +
4338 +       /**
4339 +        * Copy constructor
4340 +        * .
4341 +        * @param rMacro the macro to copy
4342 +        * @return none
4343 +        **/
4344 +       XMLMacro(const XMLMacro& rMacro);
4345 +
4346 +       /**
4347 +        * Destructor
4348 +        * .
4349 +        * @param none
4350 +        * @return none
4351 +        **/
4352 +       ~XMLMacro();
4353 +
4354 +//
4355 +// operators
4356 +//
4357 +public:
4358 +       /**
4359 +        * Assignment operator
4360 +        * .
4361 +        * @param macro The macro to copy
4362 +        * @return our copied object
4363 +        **/
4364 +       XMLMacro operator=(XMLMacro macro);
4365 +
4366 +//
4367 +// member functions
4368 +//
4369 +public:
4370 +       /**
4371 +        * Outputs the macro into an RPM spec
4372 +        * .
4373 +        * @param rOut Output stream
4374 +        * @return none
4375 +        **/
4376 +       void toSpecFile(ostream& rOut);
4377 +
4378 +       /**
4379 +        * Outputs the macro into an XML spec
4380 +        * .
4381 +        * @param rOut Output stream
4382 +        * @return none
4383 +        **/
4384 +       void toXMLFile(ostream& rOut);
4385 +
4386 +//
4387 +// member get/set functions
4388 +//
4389 +public:
4390 +       /**
4391 +        * Gets the macro name
4392 +        * .
4393 +        * @param none
4394 +        * @return string containing the macro name
4395 +        **/
4396 +       const char* getName()
4397 +       {
4398 +               return m_sName.c_str();
4399 +       }
4400 +
4401 +       /**
4402 +        * Gets tha macro value
4403 +        * .
4404 +        * @param none
4405 +        * @return string contatining the macro value
4406 +        **/
4407 +       const char* getValue()
4408 +       {
4409 +               return m_sValue.c_str();
4410 +       }
4411 +
4412 +//
4413 +// member variables
4414 +//
4415 +protected:
4416 +       string m_sName;
4417 +       string m_sValue;
4418 +};
4419 +
4420 +#endif
4421 Index: xmlspec/XMLMirror.cpp
4422 ===================================================================
4423 RCS file: xmlspec/XMLMirror.cpp
4424 diff -N xmlspec/XMLMirror.cpp
4425 --- /dev/null   1 Jan 1970 00:00:00 -0000
4426 +++ rpm/xmlspec/XMLMirror.cpp   28 Aug 2002 10:52:43 -0000      1.2.2.1
4427 @@ -0,0 +1,78 @@
4428 +// our includes
4429 +#include "XMLMirror.h"
4430 +#include "XMLSpec.h"
4431 +
4432 +using namespace std;
4433 +
4434 +// attribute structure for XMLMirror
4435 +structValidAttrs g_paMirrorAttrs[] =
4436 +{
4437 +       {0x0000,    true,  false, "path",        XATTRTYPE_STRING, {"*", NULL}},
4438 +       {0x0001,    false, false, "description", XATTRTYPE_STRING, {"*", NULL}},
4439 +       {0x0002,    false, false, "country",     XATTRTYPE_STRING, {"*", NULL}},
4440 +       {XATTR_END, false, false, "end",         XATTRTYPE_NONE,   {NULL}}
4441 +};
4442 +
4443 +bool XMLMirror::parseCreate(XMLAttrs* pAttrs,
4444 +                                                       XMLSpec* pSpec,
4445 +                                                       bool bPatch)
4446 +{
4447 +       // validate the attributes
4448 +       if (!pAttrs->validate(g_paMirrorAttrs, (XMLBase*)pSpec))
4449 +               return false;
4450 +
4451 +       XMLMirror mirror(pAttrs->asString("path"),
4452 +                                        pAttrs->asString("description"),
4453 +                                        pAttrs->asString("country"));
4454 +       if (bPatch && pSpec->numPatches())
4455 +               pSpec->lastPatch().addMirror(mirror);
4456 +       else if (!bPatch && pSpec->numSources())
4457 +               pSpec->lastSource().addMirror(mirror);
4458 +       return true;
4459 +}
4460 +
4461 +XMLMirror::XMLMirror(const char* szPath,
4462 +                                        const char* szDescription,
4463 +                                        const char* szCountry) : XMLBase()
4464 +{
4465 +       if (szPath)
4466 +               m_sPath.assign(szPath);
4467 +       if (szDescription)
4468 +               m_sDescription.assign(szDescription);
4469 +       if (szCountry)
4470 +               m_sCountry.assign(szCountry);
4471 +}
4472 +
4473 +XMLMirror::XMLMirror(const XMLMirror& rMirror)
4474 +       : XMLBase()
4475 +{
4476 +       m_sPath.assign(rMirror.m_sPath);
4477 +       m_sDescription.assign(rMirror.m_sDescription);
4478 +       m_sCountry.assign(rMirror.m_sCountry);
4479 +}
4480 +
4481 +XMLMirror::~XMLMirror()
4482 +{
4483 +}
4484 +
4485 +XMLMirror XMLMirror::operator=(XMLMirror mirror)
4486 +{
4487 +       m_sPath.assign(mirror.m_sPath);
4488 +       m_sDescription.assign(mirror.m_sDescription);
4489 +       m_sCountry.assign(mirror.m_sCountry);
4490 +}
4491 +
4492 +void XMLMirror::toSpecFile(ostream& rOut)
4493 +{
4494 +       rOut << endl << "# mirror: " << getPath();
4495 +}
4496 +
4497 +void XMLMirror::toXMLFile(ostream& rOut)
4498 +{
4499 +       rOut << endl << "\t\t<mirror path=\"" << getPath() << "\"";
4500 +       if (hasDescription())
4501 +               rOut << endl << "\t\t        description=\"" << getDescription() << "\"";
4502 +       if (hasCountry())
4503 +               rOut << endl << "\t\t        country=\"" << getCountry() << "\"";
4504 +       rOut << " />";
4505 +}
4506 Index: xmlspec/XMLMirror.h
4507 ===================================================================
4508 RCS file: xmlspec/XMLMirror.h
4509 diff -N xmlspec/XMLMirror.h
4510 --- /dev/null   1 Jan 1970 00:00:00 -0000
4511 +++ rpm/xmlspec/XMLMirror.h     28 Aug 2002 10:52:43 -0000      1.1.1.1.2.1
4512 @@ -0,0 +1,181 @@
4513 +#ifndef _H_XMLMIRROR_
4514 +#define _H_XMLMIRROR_
4515 +
4516 +// standard C++ includes
4517 +#include <string>
4518 +#include <vector>
4519 +#include <iostream>
4520 +
4521 +// our includes
4522 +#include "XMLAttrs.h"
4523 +#include "XMLBase.h"
4524 +
4525 +// forward declaration
4526 +class XMLSpec;
4527 +
4528 +using namespace std;
4529 +
4530 +// <mirror ...>
4531 +class XMLMirror : public XMLBase
4532 +{
4533 +//
4534 +// static object creation functions
4535 +//
4536 +public:
4537 +       /**
4538 +        * static function for creation of an XMLMirror object
4539 +        * .
4540 +        * @param pAttrs Pointer to our attribute structure
4541 +        * @param pSpec Pointer to our spec that is to ultimately
4542 +        *              contain the object
4543 +        * @param bPatch true if we are handling the mirror for a patch
4544 +        * @return true on success, false otherwise
4545 +        **/
4546 +       static bool parseCreate(XMLAttrs* pAttrs,
4547 +                                                       XMLSpec* pSpec,
4548 +                                                       bool bPatch = false);
4549 +
4550 +//
4551 +// constructors/destructor
4552 +//
4553 +public:
4554 +       /**
4555 +        * Default constructor for the XMLMirror object
4556 +        * .
4557 +        * @param szPath        Full path for the mirror
4558 +        * @param szDescription Full mirror description
4559 +        * @param szCoutry      Country code for the mirror
4560 +        * @return none
4561 +        **/
4562 +       XMLMirror(const char* szPath,
4563 +                         const char* szDescription,
4564 +                         const char* szCountry);
4565 +
4566 +       /**
4567 +        * Copy contructor
4568 +        * .
4569 +        * @param rMirror Reference to the object to copy
4570 +        * @return none
4571 +        **/
4572 +       XMLMirror(const XMLMirror& rMirror);
4573 +
4574 +       /**
4575 +        * Destructor for an XMLMirror object
4576 +        * .
4577 +        * @param none
4578 +        * @return none
4579 +        **/
4580 +       ~XMLMirror();
4581 +
4582 +//
4583 +// operators
4584 +//
4585 +public:
4586 +       /**
4587 +        * Assignment operator
4588 +        * .
4589 +        * @param mirror The mirror to get the values from
4590 +        * @return The modified object
4591 +        **/
4592 +       XMLMirror operator=(XMLMirror mirror);
4593 +
4594 +//
4595 +// public member functions
4596 +//
4597 +public:
4598 +       /**
4599 +        * Converts an XMLMirror object to a RPM spec file
4600 +        * .
4601 +        * @param rOut File stream
4602 +        * @return none
4603 +        **/
4604 +       void toSpecFile(ostream& rOut);
4605 +
4606 +       /**
4607 +        * Converts an XMLMirror object to an XML spec file
4608 +        * .
4609 +        * @param rOut File stream
4610 +        * @return none
4611 +        **/
4612 +       void toXMLFile(ostream& rOut);
4613 +
4614 +//
4615 +// member variable get/set functions
4616 +//
4617 +public:
4618 +       /**
4619 +        * Checks if we have a path
4620 +        * .
4621 +        * @param none
4622 +        * @return true if we have a path, false otherise
4623 +        **/
4624 +       bool hasPath()
4625 +       {
4626 +               return m_sPath.length() ? true : false;
4627 +       }
4628 +
4629 +       /**
4630 +        * Returns the path
4631 +        * .
4632 +        * @param none
4633 +        * @return The path strinbg
4634 +        **/
4635 +       const char* getPath()
4636 +       {
4637 +               return m_sPath.c_str();
4638 +       }
4639 +
4640 +       /**
4641 +        * Checks if we have a description set
4642 +        * .
4643 +        * @param none
4644 +        * @return true is we have a description, false otherwise
4645 +        **/
4646 +       bool hasDescription()
4647 +       {
4648 +               return m_sDescription.length() ? true : false;
4649 +       }
4650 +
4651 +       /**
4652 +        * Returns the description
4653 +        * .
4654 +        * @param none
4655 +        * @return the description string
4656 +        **/
4657 +       const char* getDescription()
4658 +       {
4659 +               return m_sDescription.c_str();
4660 +       }
4661 +
4662 +       /**
4663 +        * Checks if we have a country set
4664 +        * .
4665 +        * @param none
4666 +        * @return true if we have a country, false otherwise
4667 +        **/
4668 +       bool hasCountry()
4669 +       {
4670 +               return m_sCountry.length() ? true : false;
4671 +       }
4672 +
4673 +       /**
4674 +        * Gets the country
4675 +        * .
4676 +        * @param none
4677 +        * @return The country string
4678 +        **/
4679 +       const char* getCountry()
4680 +       {
4681 +               return m_sCountry.c_str();
4682 +       }
4683 +
4684 +//
4685 +// member variables
4686 +//
4687 +protected:
4688 +       string     m_sPath;
4689 +       string     m_sDescription;
4690 +       string     m_sCountry;
4691 +};
4692 +
4693 +#endif
4694 Index: xmlspec/XMLMisc.cpp
4695 ===================================================================
4696 RCS file: xmlspec/XMLMisc.cpp
4697 diff -N xmlspec/XMLMisc.cpp
4698 --- /dev/null   1 Jan 1970 00:00:00 -0000
4699 +++ rpm/xmlspec/XMLMisc.cpp     28 Aug 2002 10:52:43 -0000      1.1.2.1
4700 @@ -0,0 +1,96 @@
4701 +// standard c includes
4702 +#include <stdio.h>
4703 +#include <stdlib.h>
4704 +#include <string.h>
4705 +
4706 +using namespace std;
4707 +
4708 +char* g_szaDays[]   = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL };
4709 +char* g_szaMonths[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
4710 +                             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL };
4711 +int g_naLengths[]   = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
4712 +char* g_szaBools[]  = { "no", "yes", "false", "true", "0", "1", NULL };
4713 +
4714 +char* splitStr(const char* szInput,
4715 +                          char cTerm,
4716 +                          int& nLen)
4717 +{
4718 +       nLen = 0;
4719 +       while (szInput[nLen] != cTerm && szInput[nLen] != '\0') {
4720 +               nLen++;
4721 +       }
4722 +       char* szTemp = ((char*)szInput)+nLen;
4723 +       while (*szTemp == cTerm && *szTemp != '\0')
4724 +               szTemp++;
4725 +       return szTemp;
4726 +}
4727 +
4728 +int findStr(char* szaMatches[],
4729 +                       const char* szValue,
4730 +                       int nLen = -1)
4731 +{
4732 +       for (unsigned int i = 0; szaMatches[i] != NULL; i++) {
4733 +               if (strcmp(szaMatches[i], "*") == 0)
4734 +                       return i;
4735 +               else if (nLen == -1) {
4736 +                       if (strcasecmp(szaMatches[i], szValue) == 0)
4737 +                               return i;
4738 +               }
4739 +               else if (strncasecmp(szaMatches[i], szValue, nLen) == 0)
4740 +                       return i;
4741 +       }
4742 +       return -1;
4743 +}
4744 +
4745 +bool isInteger(const char* szValue,
4746 +                          int nLen = -1)
4747 +{
4748 +       if (nLen == -1)
4749 +               nLen = strlen(szValue);
4750 +       for (unsigned int i = 0; i < strlen(szValue); i++) {
4751 +               if (szValue[i] < '0' || szValue[i] > '9')
4752 +                       return false;
4753 +       }
4754 +       return true;
4755 +}
4756 +
4757 +bool isBool(const char* szValue,
4758 +                       int nLen = -1)
4759 +{
4760 +       return findStr(g_szaBools, szValue, nLen) != -1 ? true : false;
4761 +}
4762 +
4763 +bool isDate(const char* szValue)
4764 +{
4765 +       int nLen, nPos;
4766 +       char* szTemp = splitStr(szValue, ' ', nLen);
4767 +       if ((nPos = findStr(g_szaDays, szValue, nLen)) != -1) {
4768 +               if ((nPos = findStr(g_szaMonths, szTemp, nLen)) != -1) {
4769 +                       szTemp = splitStr(szTemp, ' ', nLen);
4770 +                       char* szBuffer = new char[nLen+1];
4771 +                       sprintf(szBuffer, "%s", szTemp);
4772 +                       szBuffer[nLen] = '\0';
4773 +                       if (atoi(szBuffer) <= g_naLengths[nPos]) {
4774 +                               delete[] szBuffer;
4775 +                               szTemp = splitStr(szTemp, ' ', nLen);
4776 +                               return isInteger(szTemp, nLen);
4777 +                       }
4778 +                       delete[] szBuffer;
4779 +               }
4780 +       }
4781 +       return false;
4782 +}
4783 +
4784 +bool isEmail(const char* szValue)
4785 +{
4786 +       bool bFound = false;
4787 +       for (unsigned int j = 0; j < strlen(szValue); j++) {
4788 +               if (szValue[j] == '@') {
4789 +                       if (bFound)
4790 +                               return false;
4791 +                       else
4792 +                               bFound = true;
4793 +               }
4794 +       }
4795 +       return bFound;
4796 +}
4797 Index: xmlspec/XMLMisc.h
4798 ===================================================================
4799 RCS file: xmlspec/XMLMisc.h
4800 diff -N xmlspec/XMLMisc.h
4801 --- /dev/null   1 Jan 1970 00:00:00 -0000
4802 +++ rpm/xmlspec/XMLMisc.h       28 Aug 2002 10:52:43 -0000      1.1.2.1
4803 @@ -0,0 +1,66 @@
4804 +#ifndef _H_XMLMISC_
4805 +#define _H_XMLMISC_
4806 +
4807 +extern char* g_szaDays[];
4808 +extern char* g_szaMonths[];
4809 +
4810 +/**
4811 + * Splits the input string according to the terminator, returning
4812 + * the length and the new search position
4813 + * .
4814 + * @param szInput The input string
4815 + * @param cTerm The terminating character
4816 + * @param nLen the length buffer
4817 + * @return The next string position
4818 + **/
4819 +extern char* splitStr(const char* szInput,
4820 +                                         char cTerm,
4821 +                                         int& nLen);
4822 +
4823 +/**
4824 + * Finds a string in an array of potential matches
4825 + * .
4826 + * @param szaMatches The potential matches
4827 + * @param szValue The value to search for
4828 + * @return The position on success, -1 if not found
4829 + **/
4830 +extern int findStr(char* szaMatches[],
4831 +                                  const char* szValue,
4832 +                                  int nLen = -1);
4833 +
4834 +/**
4835 + * Checks if a string contains an integer
4836 + * .
4837 + * @param szValue The string to check
4838 + * @param nLen The length to check, -1 to end of string
4839 + * @return true if the string is an integer, false otherwise
4840 + **/
4841 +extern bool isInteger(const char* szValue,
4842 +                                         int nLen = -1);
4843 +
4844 +/**
4845 + * Checks if a string contains a boolean value
4846 + * .
4847 + * @param szValue The value to check
4848 + * @return true if we have a boolean, false otherwise
4849 + **/
4850 +extern bool isBool(const char* szValue,
4851 +                                  int nLen = -1);
4852 +
4853 +/**
4854 + * Checks if a string is in a valid date format
4855 + * .
4856 + * @param szValue The string to check
4857 + * @return true is this is a date, false otherwise
4858 + **/
4859 +extern bool isDate(const char* szValue);
4860 +
4861 +/**
4862 + * Checks if a string contains a valid e-mail address
4863 + * .
4864 + * @param szValue the string to check
4865 + * @return true if this is an email address, false otherwise
4866 + **/
4867 +extern bool isEmail(const char* szValue);
4868 +
4869 +#endif
4870 Index: xmlspec/XMLPackage.cpp
4871 ===================================================================
4872 RCS file: xmlspec/XMLPackage.cpp
4873 diff -N xmlspec/XMLPackage.cpp
4874 --- /dev/null   1 Jan 1970 00:00:00 -0000
4875 +++ rpm/xmlspec/XMLPackage.cpp  28 Aug 2002 10:52:43 -0000      1.3.2.1
4876 @@ -0,0 +1,327 @@
4877 +// standard C++ includes
4878 +#include <string>
4879 +
4880 +// our includes
4881 +#include "XMLPackage.h"
4882 +#include "XMLRPMWrap.h"
4883 +#include "XMLSpec.h"
4884 +
4885 +// rpm includes
4886 +#include <rpmlib.h>
4887 +
4888 +// attribute structure for XMLPackage
4889 +structValidAttrs g_paPackageAttrs[] =
4890 +{
4891 +       {0x0000,    false, false, "name",        XATTRTYPE_STRING, {"*", NULL}},
4892 +       {0x0001,    true,  false, "group",       XATTRTYPE_STRING, {"*", NULL}},
4893 +       {0x0002,    false, false, "autoreq",     XATTRTYPE_BOOL,   {NULL}},
4894 +       {0x0003,    false, false, "autoprov",    XATTRTYPE_BOOL,   {NULL}},
4895 +       {0x0004,    false, false, "autoreqprov", XATTRTYPE_BOOL,   {NULL}},
4896 +       {0x0005,    false, false, "sub",         XATTRTYPE_BOOL,   {NULL}},
4897 +       {XATTR_END, false, false, "end",         XATTRTYPE_NONE,   {NULL}}
4898 +};
4899 +
4900 +bool XMLPackage::parseCreate(XMLAttrs* pAttrs,
4901 +                                                        XMLSpec* pSpec)
4902 +{
4903 +       // validate the attributes
4904 +       if (!pAttrs->validate(g_paPackageAttrs, (XMLBase*)pSpec))
4905 +               return false;
4906 +
4907 +       // setup the name attribute
4908 +       string sName;
4909 +       if (pAttrs->asString("name"))
4910 +               sName.assign(pAttrs->asString("name"));
4911 +
4912 +       // if we have a name, cool, now test if the package already exists
4913 +       if (sName.length()) {
4914 +               XMLPackage package(sName.c_str(), pAttrs->asString("group"),
4915 +                                                  pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4916 +                                                  pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4917 +                                                  pAttrs->asBool("sub"));
4918 +               pSpec->addPackage(package);
4919 +       }
4920 +
4921 +       // already something existing with %{name} ?
4922 +       else {
4923 +               XMLPackage package(NULL, pAttrs->asString("group"),
4924 +                                                  pAttrs->asBool("autoreq") || pAttrs->asBool("autoreqprov"),
4925 +                                                  pAttrs->asBool("autoprov") || pAttrs->asBool("autoreqprov"),
4926 +                                                  pAttrs->asBool("sub"));
4927 +               pSpec->addPackage(package);
4928 +       }
4929 +       return true;
4930 +}
4931 +
4932 +bool XMLPackage::structCreate(PackageStruct* pPackage,
4933 +                                                         Spec pSpec,
4934 +                                                         XMLSpec* pXSpec)
4935 +{
4936 +       if (!pXSpec || !pSpec || !pPackage || !pPackage->header)
4937 +               return false;
4938 +
4939 +       string sGroup, sName;
4940 +       if (!getRPMHeader(pPackage->header, RPMTAG_GROUP, sGroup))
4941 +               return false;
4942 +       getRPMHeader(pPackage->header, RPMTAG_NAME, sName);
4943 +       bool bSub = false;
4944 +       if (sName.compare(pXSpec->getName()) == 0) {
4945 +               bSub = true;
4946 +       }
4947 +
4948 +       XMLPackage package(bSub ? NULL : sName.c_str(), sGroup.c_str(),
4949 +                                          pPackage->autoReq ? true : false,
4950 +                                          pPackage->autoProv ? true : false,
4951 +                                          bSub);
4952 +       t_StrVector svText;
4953 +       t_StrVector svLang;
4954 +       getRPMHeaderArray(pPackage->header, RPMTAG_HEADERI18NTABLE, svLang);
4955 +       if (getRPMHeaderArray(pPackage->header, RPMTAG_SUMMARY, svText)) {
4956 +               for (unsigned int i = 0; i < svText.size(); i++)
4957 +                       package.addSummary(svText[i].c_str(), svLang[i].c_str());
4958 +       }
4959 +       if (getRPMHeaderArray(pPackage->header, RPMTAG_DESCRIPTION, svText)) {
4960 +               for (unsigned int i = 0; i < svText.size(); i++)
4961 +                       package.addDescription(svText[i].c_str(), svLang[i].c_str());
4962 +       }
4963 +       pXSpec->addPackage(package);
4964 +
4965 +       XMLPackageContainer::structCreate(pPackage, pSpec, pXSpec);
4966 +       XMLFiles::structCreate(pPackage, pSpec, pXSpec);
4967 +
4968 +       // do the next package and return
4969 +       XMLPackage::structCreate(pPackage->next, pSpec, pXSpec);
4970 +       return true;
4971 +}
4972 +
4973 +// attribute structure for summaries
4974 +structValidAttrs g_paDescriptionAttrs[] =
4975 +{
4976 +       {0x0000,    false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
4977 +       {XATTR_END, false, false, "end",  XATTRTYPE_NONE,   {NULL}}
4978 +};
4979 +
4980 +bool XMLPackage::addDescription(XMLAttrs* pAttrs,
4981 +                                                               const char* szDescription,
4982 +                                                               XMLSpec* pSpec)
4983 +{
4984 +       if (pSpec && pAttrs->validate(g_paDescriptionAttrs, (XMLBase*)pSpec)) {
4985 +               pSpec->lastPackage().addDescription(szDescription, pAttrs->asString("lang"));
4986 +               return true;
4987 +       }
4988 +       else
4989 +               return false;
4990 +}
4991 +
4992 +// attribute structure for summaries
4993 +structValidAttrs g_paSummaryAttrs[] =
4994 +{
4995 +       {0x0000,    false, false, "lang", XATTRTYPE_STRING, {"*", NULL}},
4996 +       {XATTR_END, false, false, "end",  XATTRTYPE_NONE,   {NULL}}
4997 +};
4998 +
4999 +bool XMLPackage::addSummary(XMLAttrs* pAttrs,
5000 +                                                       const char* szSummary,
5001 +                                                       XMLSpec* pSpec)
5002 +{
5003 +       if (pSpec && pAttrs->validate(g_paSummaryAttrs, (XMLBase*)pSpec)) {
5004 +               pSpec->lastPackage().addSummary(szSummary, pAttrs->asString("lang"));
5005 +               return true;
5006 +       }
5007 +       else
5008 +               return false;
5009 +}
5010 +
5011 +XMLPackage::XMLPackage(const char* szName,
5012 +                                          const char* szGroup,
5013 +                                          bool bAutoReq,
5014 +                                          bool bAutoProv,
5015 +                                          bool bSub)
5016 +       : XMLBase()
5017 +{
5018 +       setName(szName);
5019 +       setGroup(szGroup);
5020 +       setSubPackage(bSub);
5021 +       setAutoRequires(bAutoReq);
5022 +       setAutoProvides(bAutoProv);
5023 +}
5024 +
5025 +XMLPackage::XMLPackage(const XMLPackage& rPackage)
5026 +       : XMLBase()
5027 +{
5028 +       setName(rPackage.m_sName.c_str());
5029 +       setGroup(rPackage.m_sGroup.c_str());
5030 +       setSubPackage(rPackage.m_bSub);
5031 +       setAutoRequires(rPackage.m_bAutoReq);
5032 +       setAutoProvides(rPackage.m_bAutoProv);
5033 +       m_vSummaries = rPackage.m_vSummaries;
5034 +       m_vDescriptions = rPackage.m_vDescriptions;
5035 +       m_Requires = rPackage.m_Requires;
5036 +       m_BuildRequires = rPackage.m_BuildRequires;
5037 +       m_Provides = rPackage.m_Provides;
5038 +       m_Obsoletes = rPackage.m_Obsoletes;
5039 +       m_Post = rPackage.m_Post;
5040 +       m_PostUn = rPackage.m_PostUn;
5041 +       m_Pre = rPackage.m_Pre;
5042 +       m_PreUn = rPackage.m_PreUn;
5043 +       m_Verify = rPackage.m_Verify;
5044 +       m_Files = rPackage.m_Files;
5045 +}
5046 +
5047 +XMLPackage::~XMLPackage()
5048 +{
5049 +}
5050 +
5051 +void XMLPackage::toSpecFile(ostream& rOut)
5052 +{
5053 +       // top package bit
5054 +       if (hasName()) {
5055 +               rOut << endl << "%package";
5056 +               rOut << (!isSubPackage() ? " -n " : " ") << getName() << endl;
5057 +       }
5058 +       else
5059 +               rOut << endl << endl;
5060 +
5061 +       for (unsigned int i = 0; i < numSummaries(); i++) {
5062 +               rOut << "summary";
5063 +               if (getSummary(i).hasLang())
5064 +                       rOut << "(" << getSummary(i).getLang() << "):";
5065 +               else
5066 +                       rOut << ":    ";
5067 +               rOut << "    " << getSummary(i).getText() << endl;
5068 +       }
5069 +       if (hasGroup())
5070 +               rOut << "group:          " << getGroup() << endl;
5071 +       if (!hasAutoRequires() && !hasAutoProvides())
5072 +               rOut << "autoreqprov:    no" << endl;
5073 +       else {
5074 +               if (!hasAutoRequires())
5075 +                       rOut << "autoreq:        no" << endl;
5076 +               if (!hasAutoProvides())
5077 +                       rOut << "autoprov:       no" << endl;
5078 +       }
5079 +
5080 +       getProvides().toSpecFile(rOut, "provides");
5081 +       getObsoletes().toSpecFile(rOut, "obsoletes");
5082 +       getRequires().toSpecFile(rOut, "requires");
5083 +       getBuildRequires().toSpecFile(rOut, "buildrequires");
5084 +
5085 +       // add the description
5086 +       for (unsigned int i = 0; i < numDescriptions(); i++) {
5087 +               rOut << "%description ";
5088 +               if (getDescription(i).hasLang())
5089 +                       rOut << "-l " << getDescription(i).getLang() << " ";
5090 +               if (hasName()) {
5091 +                       rOut << (!isSubPackage() ? "-n " : "");
5092 +                       rOut << getName();
5093 +               }
5094 +               rOut << endl << getDescription(i).getText() << endl;
5095 +       }
5096 +}
5097 +
5098 +void toSectionSpecFile(ostream& rOut,
5099 +                                          const char* szSection,
5100 +                                          XMLPackage* pPkg)
5101 +{
5102 +       rOut << endl << "%" << szSection;
5103 +       if (pPkg->hasName())
5104 +               rOut << (!pPkg->isSubPackage() ? " -n " : " ") << pPkg->getName();
5105 +       rOut << endl;
5106 +}
5107 +
5108 +void XMLPackage::toScriptsSpecFile(ostream& rOut)
5109 +{
5110 +       if (getPre().numScripts()) {
5111 +               toSectionSpecFile(rOut, "pre", this);
5112 +               getPre().toSpecFile(rOut, "pre");
5113 +       }
5114 +
5115 +       if (getPost().numScripts()) {
5116 +               toSectionSpecFile(rOut, "post", this);
5117 +               getPost().toSpecFile(rOut, "post");
5118 +       }
5119 +
5120 +       if (getPreUn().numScripts()) {
5121 +               toSectionSpecFile(rOut, "preun", this);
5122 +               getPreUn().toSpecFile(rOut, "preun");
5123 +       }
5124 +
5125 +       if (getPostUn().numScripts()) {
5126 +               toSectionSpecFile(rOut, "postun", this);
5127 +               getPostUn().toSpecFile(rOut, "postun");
5128 +       }
5129 +
5130 +       if (getVerify().numScripts()) {
5131 +               toSectionSpecFile(rOut, "verifyscript", this);
5132 +               getVerify().toSpecFile(rOut, "verifyscript");
5133 +       }
5134 +}
5135 +
5136 +void XMLPackage::toFilesSpecFile(ostream& rOut)
5137 +{
5138 +       rOut << endl << "%files";
5139 +       if (hasName())
5140 +               rOut << (!isSubPackage() ? " -n " : " ") << getName();
5141 +       rOut << endl;
5142 +       getFiles().toSpecFile(rOut);
5143 +}
5144 +
5145 +void XMLPackage::toXMLFile(ostream& rOut)
5146 +{
5147 +       rOut << endl << "\t<package";
5148 +       if (hasName()) {
5149 +               rOut << " name=\"" << getName() << "\"";
5150 +               if (!isSubPackage())
5151 +                       rOut << " sub=\"no\"";
5152 +       }
5153 +       if (hasGroup())
5154 +               rOut << " group=\"" << getGroup() << "\"";
5155 +       if (!hasAutoRequires() && !hasAutoProvides())
5156 +               rOut << " autoreqprov=\"no\"";
5157 +       else {
5158 +               if (!hasAutoRequires())
5159 +                       rOut << " autoreq=\"no\"";
5160 +               if (!hasAutoProvides())
5161 +                       rOut << " autoprov=\"no\"";
5162 +       }
5163 +       rOut << ">";
5164 +
5165 +       for (unsigned int i = 0; i < numSummaries(); i++) {
5166 +               rOut << endl << "\t\t<summary";
5167 +               if (getSummary(i).hasLang())
5168 +                       rOut << " lang=\"" << getSummary(i).getLang() << "\"";
5169 +               rOut << ">" << getSummary(i).getText() << "</summary>";
5170 +       }
5171 +       for (unsigned int i = 0; i < numDescriptions(); i++) {
5172 +               rOut << endl << "\t\t<description";
5173 +               if (getDescription(i).hasLang())
5174 +                       rOut << " lang=\"" << getDescription(i).getLang() << "\"";
5175 +               rOut << ">" << getDescription(i).getText() << "</description>";
5176 +       }
5177 +
5178 +       getProvides().toXMLFile(rOut, "provides");
5179 +       getObsoletes().toXMLFile(rOut, "obsoletes");
5180 +       getRequires().toXMLFile(rOut, "requires");
5181 +       getBuildRequires().toXMLFile(rOut, "buildrequires");
5182 +
5183 +       getPre().toXMLFile(rOut, "pre");
5184 +       getPost().toXMLFile(rOut, "post");
5185 +       getPreUn().toXMLFile(rOut, "preun");
5186 +       getPostUn().toXMLFile(rOut, "postun");
5187 +       getVerify().toXMLFile(rOut, "verify");
5188 +
5189 +       getFiles().toXMLFile(rOut);
5190 +
5191 +       rOut << endl << "\t</package>";
5192 +}
5193 +
5194 +void XMLPackage::toRPMStruct(Spec spec)
5195 +{
5196 +       //Package pkg = newPackage(spec);
5197 +       //if (!hasName() && pkg == spec->packages)
5198 +       //      fillOutMainPackage(pkg->header);
5199 +       //else if (pkg != spec->packages)
5200 +       //      headerCopyTags(spec->packages->header,
5201 +       //                                 pkg->header,
5202 +       //                                 (int_32 *)copyTagsDuringParse);
5203 +}
5204 Index: xmlspec/XMLPackage.h
5205 ===================================================================
5206 RCS file: xmlspec/XMLPackage.h
5207 diff -N xmlspec/XMLPackage.h
5208 --- /dev/null   1 Jan 1970 00:00:00 -0000
5209 +++ rpm/xmlspec/XMLPackage.h    28 Aug 2002 10:52:43 -0000      1.3.2.1
5210 @@ -0,0 +1,507 @@
5211 +#ifndef _H_XMLPACKAGE_
5212 +#define _H_XMLPACKAGE_
5213 +
5214 +// standard C++ includes
5215 +#include <iostream>
5216 +#include <string>
5217 +#include <vector>
5218 +
5219 +// standard includes
5220 +#include <stdio.h>
5221 +
5222 +// our includes
5223 +#include "XMLAttrs.h"
5224 +#include "XMLBase.h"
5225 +#include "XMLFiles.h"
5226 +#include "XMLRequires.h"
5227 +#include "XMLScript.h"
5228 +#include "XMLText.h"
5229 +
5230 +// rpm includes
5231 +#include <rpmbuild.h>
5232 +
5233 +// forward class declarations
5234 +class XMLSpec;
5235 +
5236 +using namespace std;
5237 +
5238 +class XMLPackage : public XMLBase
5239 +{
5240 +//
5241 +// factory functions
5242 +//
5243 +public:
5244 +       /**
5245 +        * Creates an object as parsed from an XML spec
5246 +        * .
5247 +        * @param pAttrs XML atrtributes to use
5248 +        * @param pSpec The spec to which we are adding this object to
5249 +        * @return true on success, false otherwise
5250 +        **/
5251 +       static bool parseCreate(XMLAttrs* pAttrs,
5252 +                                                       XMLSpec* pSpec);
5253 +
5254 +       /**
5255 +        * Creates package objects from an RPM Spec structure
5256 +        * .
5257 +        * @param pPackage Pointer to the start package
5258 +        * @param pSpec pointer to the RPM spec
5259 +        * @param pXSpec Pointer to the spec object to populate
5260 +        * @return true on success, false otherwise
5261 +        **/
5262 +       static bool structCreate(PackageStruct* pPackage,
5263 +                                                        Spec pSpec,
5264 +                                                        XMLSpec* pXSpec);
5265 +
5266 +       /**
5267 +        * Adds a description for the last package
5268 +        * .
5269 +        * @param pAttrs The attributes
5270 +        * @param szDescription the description
5271 +        * @param pSpec The spec containing the package
5272 +        * @return true on success, false otherwise
5273 +        **/
5274 +       static bool addDescription(XMLAttrs* pAttrs,
5275 +                                                          const char* szDescription,
5276 +                                                          XMLSpec* pSpec);
5277 +
5278 +       /**
5279 +        * Adds the summary for the last added package
5280 +        * .
5281 +        * @param pAttrs The attributes
5282 +        * @param szSummary The summary to set
5283 +        * @param pSpec The spec contraining the package
5284 +        * @return trus on success, false otherwise
5285 +        **/
5286 +       static bool addSummary(XMLAttrs* pAttrs,
5287 +                                                  const char* szSummary,
5288 +                                                  XMLSpec* pSpec);
5289 +
5290 +//
5291 +// constructors/destructors
5292 +//
5293 +public:
5294 +       /**
5295 +        * Default constructor
5296 +        * .
5297 +        * @param szName The package name
5298 +        * @param szGroup The group this package belongs to
5299 +        * @param bAutoReq Auto Requires
5300 +        * @param bAutoProv Auto Provides
5301 +        * @param bSub true if this is a sub-package
5302 +        * @return none
5303 +        **/
5304 +       XMLPackage(const char* szName,
5305 +                          const char* szGroup,
5306 +                          bool bAutoReq,
5307 +                          bool bAutoProv,
5308 +                          bool bSub);
5309 +
5310 +       /**
5311 +        * Copy constructor
5312 +        * .
5313 +        * @param rPackage The package to copy from
5314 +        * @return none
5315 +        **/
5316 +       XMLPackage(const XMLPackage& rPackage);
5317 +
5318 +       /**
5319 +        * Destructor
5320 +        * .
5321 +        * @param none
5322 +        * @return none
5323 +        **/
5324 +       ~XMLPackage();
5325 +
5326 +//
5327 +// public member functions
5328 +//
5329 +public:
5330 +       /**
5331 +        * Converts the object to a spec file
5332 +        * .
5333 +        * @param rOut Output stream
5334 +        * @return none
5335 +        **/
5336 +       void toSpecFile(ostream& rOut);
5337 +
5338 +       /**
5339 +        * Converts the scripts part of the object to a spec
5340 +        * .
5341 +        * @param rOut Output stream
5342 +        * @return none
5343 +        **/
5344 +       void toScriptsSpecFile(ostream& rOut);
5345 +
5346 +       /**
5347 +        * Converts the files part of the object to a spec
5348 +        * .
5349 +        * @param rOut Output stream
5350 +        * @return none
5351 +        **/
5352 +       void toFilesSpecFile(ostream& rOut);
5353 +
5354 +       /**
5355 +        * Converts the object to an XML spec
5356 +        * .
5357 +        * @param rOut The output stream
5358 +        * @return none
5359 +        **/
5360 +       void toXMLFile(ostream& rOut);
5361 +
5362 +       /**
5363 +        * Converts the object to an RPM structure
5364 +        * .
5365 +        * @param Spec The main Spec object
5366 +        * @param none
5367 +        **/
5368 +       void toRPMStruct(Spec spec);
5369 +
5370 +//
5371 +// member variable get/set functions
5372 +//
5373 +public:
5374 +       /**
5375 +        * Checks of we have a package name
5376 +        * .
5377 +        * @param none
5378 +        * @return true if we have a name, false otherwise
5379 +        **/
5380 +       bool hasName()
5381 +       {
5382 +               return m_sName.length() ? true : false;
5383 +       }
5384 +
5385 +       /**
5386 +        * Gets the package name
5387 +        * .
5388 +        * @param none
5389 +        * @return string containing the package name
5390 +        **/
5391 +       const char* getName()
5392 +       {
5393 +               return m_sName.c_str();
5394 +       }
5395 +
5396 +       /**
5397 +        * Sets the package name
5398 +        * .
5399 +        * @param szName The name to set
5400 +        * @return none
5401 +        **/
5402 +       void setName(const char* szName)
5403 +       {
5404 +               if (szName)
5405 +                       m_sName.assign(szName);
5406 +       }
5407 +
5408 +       /**
5409 +        * Checks if we have a group
5410 +        * .
5411 +        * @param none
5412 +        * @return true if we have a group, false otherwise
5413 +        **/
5414 +       bool hasGroup()
5415 +       {
5416 +               return m_sGroup.length() ? true : false;
5417 +       }
5418 +
5419 +       /**
5420 +        * Returns the group
5421 +        * .
5422 +        * @param none
5423 +        * @return string containing the group
5424 +        **/
5425 +       const char* getGroup()
5426 +       {
5427 +               return m_sGroup.c_str();
5428 +       }
5429 +
5430 +       /**
5431 +        * Sets the group
5432 +        * .
5433 +        * @param szGroup The group to set
5434 +        * @return none
5435 +        **/
5436 +       void setGroup(const char* szGroup)
5437 +       {
5438 +               if (szGroup)
5439 +                       m_sGroup.assign(szGroup);
5440 +       }
5441 +
5442 +       /**
5443 +        * Tests if we are a sub-package
5444 +        * .
5445 +        * @param none
5446 +        * @return true if this is a sub-package
5447 +        **/
5448 +       bool isSubPackage()
5449 +       {
5450 +               return m_bSub;
5451 +       }
5452 +
5453 +       /**
5454 +        * Sets the sub-package status
5455 +        * .
5456 +        * @param bSub The sub-package status
5457 +        * @return none
5458 +        **/
5459 +       void setSubPackage(bool bSub)
5460 +       {
5461 +               m_bSub = bSub;
5462 +       }
5463 +
5464 +       /**
5465 +        * Tests for auto requires
5466 +        * .
5467 +        * @param none
5468 +        * @return true if we have auto requires, false otherwise
5469 +        **/
5470 +       bool hasAutoRequires()
5471 +       {
5472 +               return m_bAutoReq;
5473 +       }
5474 +
5475 +       /**
5476 +        * Sets the auto requires state
5477 +        * .
5478 +        * @param bAutoReq The auto requires state
5479 +        * @return none
5480 +        **/
5481 +       void setAutoRequires(bool bAutoReq)
5482 +       {
5483 +               m_bAutoReq = bAutoReq;
5484 +       }
5485 +
5486 +       /**
5487 +        * Tests for auto requires
5488 +        * .
5489 +        * @param none
5490 +        * @return true if we have auto requires, false otherwise
5491 +        **/
5492 +       bool hasAutoProvides()
5493 +       {
5494 +               return m_bAutoProv;
5495 +       }
5496 +
5497 +       /**
5498 +        * Sets the auto provides status
5499 +        * .
5500 +        * @param bAutoProv The auto provides status
5501 +        * @return none
5502 +        **/
5503 +       void setAutoProvides(bool bAutoProv)
5504 +       {
5505 +               m_bAutoProv = bAutoProv;
5506 +       }
5507 +
5508 +       /**
5509 +        * Gets the number of summaries
5510 +        * .
5511 +        * @param none
5512 +        * @return the number of summaries
5513 +        **/
5514 +       unsigned int numSummaries()
5515 +       {
5516 +               return m_vSummaries.size();
5517 +       }
5518 +
5519 +       /**
5520 +        * Gets a summary
5521 +        * .
5522 +        * @param nNum The number to get
5523 +        * @return the summary
5524 +        **/
5525 +       XMLText& getSummary(unsigned int nNum)
5526 +       {
5527 +               return m_vSummaries[nNum];
5528 +       }
5529 +
5530 +       /**
5531 +        * Adds a summary
5532 +        * .
5533 +        * @param szSummary the summary
5534 +        * @param szLang the language
5535 +        * @return none
5536 +        **/
5537 +       void addSummary(const char* szSummary,
5538 +                                       const char* szLang = NULL)
5539 +       {
5540 +               if (szSummary && strlen(szSummary)) {
5541 +                       XMLText summary(szSummary, szLang);
5542 +                       m_vSummaries.push_back(summary);
5543 +               }
5544 +       }
5545 +
5546 +       /**
5547 +        * Gets the number of descriptions
5548 +        * .
5549 +        * @param none
5550 +        * @return the number in our list
5551 +        **/
5552 +       unsigned int numDescriptions()
5553 +       {
5554 +               return m_vDescriptions.size();
5555 +       }
5556 +
5557 +       /**
5558 +        * Get a description
5559 +        * .
5560 +        * @param nNum The description to get
5561 +        * @return Reference to XMLText object
5562 +        **/
5563 +       XMLText& getDescription(unsigned int nNum)
5564 +       {
5565 +               return m_vDescriptions[nNum];
5566 +       }
5567 +
5568 +       /**
5569 +        * Adds a description
5570 +        * .
5571 +        * @param szDescription The description string
5572 +        * @param szLang The language
5573 +        * @return nonew
5574 +        **/
5575 +       void addDescription(const char* szDescription,
5576 +                                               const char* szLang = NULL)
5577 +       {
5578 +               if (szDescription && strlen(szDescription)) {
5579 +                       XMLText description(szDescription, szLang);
5580 +                       m_vDescriptions.push_back(description);
5581 +               }
5582 +       }
5583 +
5584 +       /**
5585 +        * Gets the provides
5586 +        * .
5587 +        * @param none
5588 +        * @return reference to the provides
5589 +        **/
5590 +       XMLPackageContainer& getProvides()
5591 +       {
5592 +               return m_Provides;
5593 +       }
5594 +
5595 +       /**
5596 +        * Gets the package requires
5597 +        * .
5598 +        * @param none
5599 +        * @return reference to the requires
5600 +        **/
5601 +       XMLPackageContainer& getRequires()
5602 +       {
5603 +               return m_Requires;
5604 +       }
5605 +
5606 +       /**
5607 +        * Get the buildrequires
5608 +        * .
5609 +        * @param none
5610 +        * @return reference to the buildrequires
5611 +        **/
5612 +       XMLPackageContainer& getBuildRequires()
5613 +       {
5614 +               return m_BuildRequires;
5615 +       }
5616 +
5617 +       /**
5618 +        * Gets the obsoletes
5619 +        * .
5620 +        * @param none
5621 +        * @return reference to the obsoletes
5622 +        **/
5623 +       XMLPackageContainer& getObsoletes()
5624 +       {
5625 +               return m_Obsoletes;
5626 +       }
5627 +
5628 +       /**
5629 +        * Gets the files
5630 +        * .
5631 +        * @param none
5632 +        * @return reference to the files
5633 +        **/
5634 +       XMLFiles& getFiles()
5635 +       {
5636 +               return m_Files;
5637 +       }
5638 +
5639 +       /**
5640 +        * Gets the pre section
5641 +        * .
5642 +        * @param none
5643 +        * @return reference to the pre section
5644 +        **/
5645 +       XMLPackageScripts& getPre()
5646 +       {
5647 +               return m_Pre;
5648 +       }
5649 +
5650 +       /**
5651 +        * Gets the post section
5652 +        * .
5653 +        * @param none
5654 +        * @return reference to the post section
5655 +        **/
5656 +       XMLPackageScripts& getPost()
5657 +       {
5658 +               return m_Post;
5659 +       }
5660 +
5661 +       /**
5662 +        * Gets the preun section
5663 +        * .
5664 +        * @param none
5665 +        * @return reference to the preun section
5666 +        **/
5667 +       XMLPackageScripts& getPreUn()
5668 +       {
5669 +               return m_PreUn;
5670 +       }
5671 +
5672 +       /**
5673 +        * Gets the postun section
5674 +        * .
5675 +        * @param none
5676 +        * @return reference to the postun section
5677 +        **/
5678 +       XMLPackageScripts& getPostUn()
5679 +       {
5680 +               return m_PostUn;
5681 +       }
5682 +
5683 +       /**
5684 +        * Gets the verify section
5685 +        * .
5686 +        * @param none
5687 +        * @return reference to the verify section
5688 +        **/
5689 +       XMLPackageScripts& getVerify()
5690 +       {
5691 +               return m_Verify;
5692 +       }
5693 +
5694 +//
5695 +// member variables
5696 +//
5697 +protected:
5698 +       string              m_sName;
5699 +       string              m_sGroup;
5700 +       bool                m_bSub;
5701 +       bool                m_bAutoReq;
5702 +       bool                m_bAutoProv;
5703 +       vector<XMLText>     m_vSummaries;
5704 +       vector<XMLText>     m_vDescriptions;
5705 +       XMLPackageContainer m_Requires;
5706 +       XMLPackageContainer m_BuildRequires;
5707 +       XMLPackageContainer m_Provides;
5708 +       XMLPackageContainer m_Obsoletes;
5709 +       XMLPackageScripts   m_Pre;
5710 +       XMLPackageScripts   m_PreUn;
5711 +       XMLPackageScripts   m_Post;
5712 +       XMLPackageScripts   m_PostUn;
5713 +       XMLPackageScripts   m_Verify;
5714 +       XMLFiles            m_Files;
5715 +};
5716 +
5717 +#endif
5718 Index: xmlspec/XMLParser.cpp
5719 ===================================================================
5720 RCS file: xmlspec/XMLParser.cpp
5721 diff -N xmlspec/XMLParser.cpp
5722 --- /dev/null   1 Jan 1970 00:00:00 -0000
5723 +++ rpm/xmlspec/XMLParser.cpp   28 Aug 2002 10:52:43 -0000      1.3.2.1
5724 @@ -0,0 +1,982 @@
5725 +// standard library includes
5726 +#include <stdarg.h>
5727 +#include <stdio.h>
5728 +#include <stdlib.h>
5729 +
5730 +// standard C++ includes
5731 +#include <fstream>
5732 +#include <string>
5733 +
5734 +// 3rd party library includes
5735 +#include <expat.h>
5736 +
5737 +// our includes
5738 +#include "XMLSpec.h"
5739 +
5740 +// this is the maximum tree dept we will require as
5741 +// well as the number of scructures a specific tag can
5742 +// occur in
5743 +#define XML_MAX_TREE_DEPTH 5
5744 +#define XML_MAX_PRE_TAGS   10
5745 +
5746 +using namespace std;
5747 +
5748 +// these define the error values
5749 +enum eXMLErr
5750 +{
5751 +       XMLERR_WARNING = 0x0000,
5752 +       XMLERR_ERROR,
5753 +       XMLERR_FATAL
5754 +};
5755 +
5756 +// this defines the structure that we are using in the callback
5757 +// containing all the parse-specific data we might need.
5758 +struct structCBData
5759 +{
5760 +       XML_Parser*  m_pParser;
5761 +       string       m_sFilename;
5762 +       int          m_nWarnings;
5763 +       int          m_nErrors;
5764 +       int          m_nDepth;
5765 +       unsigned int m_pnTree[XML_MAX_TREE_DEPTH];
5766 +       string       m_sData;
5767 +       XMLSpec*     m_pSpec;
5768 +       XMLAttrs*    m_pAttrs;
5769 +};
5770 +
5771 +// enumeration of all XML tags that are recognised
5772 +enum enumXMLTAGValid
5773 +{
5774 +       XTAG_NO          = 0x0000,
5775 +       XTAG_WRONGSTRUCT,
5776 +       XTAG_SPEC,
5777 +       XTAG_EXCLUDEARCH,
5778 +       XTAG_EXCLUDEOS,
5779 +       XTAG_EXCLUSIVEARCH,
5780 +       XTAG_EXCLUSIVEOS,
5781 +       XTAG_SOURCE,
5782 +       XTAG_PATCH,
5783 +       XTAG_NOSOURCE,
5784 +       XTAG_MIRROR,
5785 +       XTAG_PACKAGE,
5786 +       XTAG_SUMMARY,
5787 +       XTAG_DESC,
5788 +       XTAG_REQS,
5789 +       XTAG_BREQS,
5790 +       XTAG_PROVS,
5791 +       XTAG_OBSOLS,
5792 +       XTAG_FILES,
5793 +       XTAG_FILE,
5794 +       XTAG_MACRO,
5795 +       XTAG_PREP,
5796 +       XTAG_SETUP,
5797 +       XTAG_BUILD,
5798 +       XTAG_INSTALL,
5799 +       XTAG_CLEAN,
5800 +       XTAG_PRE,
5801 +       XTAG_POST,
5802 +       XTAG_PREUN,
5803 +       XTAG_POSTUN,
5804 +       XTAG_VERIFY,
5805 +       XTAG_SCRIPT,
5806 +       XTAG_CHANGELOG,
5807 +       XTAG_CHANGES,
5808 +       XTAG_CHANGE,
5809 +       XTAG_ANY         = 0xFFFF // this always needs to be the last entry
5810 +};
5811 +
5812 +// this is a structure to match tags to their values
5813 +struct structXMLMatch
5814 +{
5815 +       unsigned int m_nVal;
5816 +       int          m_pnDepth[XML_MAX_TREE_DEPTH+1];
5817 +       unsigned int m_pnFollows[XML_MAX_PRE_TAGS+1];
5818 +       char*        m_szName;
5819 +};
5820 +
5821 +// this allows for the matching of all tags
5822 +structXMLMatch g_pMatches[] =
5823 +{
5824 +       {
5825 +               XTAG_SPEC,         { 0, -1, -1},    {
5826 +                                                                                               XTAG_ANY,
5827 +                                                                                               XTAG_NO
5828 +                                                                                       },
5829 +               "spec"
5830 +       },
5831 +       {
5832 +               XTAG_PACKAGE,      { 1,  3, -1},    {
5833 +                                                                                               XTAG_SPEC,
5834 +                                                                                               XTAG_REQS,
5835 +                                                                                               XTAG_BREQS,
5836 +                                                                                               XTAG_PROVS,
5837 +                                                                                               XTAG_OBSOLS,
5838 +                                                                                               XTAG_NO
5839 +                                                                                       },
5840 +               "package"
5841 +       },
5842 +       {
5843 +               XTAG_SOURCE,       { 1, -1, -1},    {
5844 +                                                                                               XTAG_SPEC,
5845 +                                                                                               XTAG_NO
5846 +                                                                                       },
5847 +               "source"
5848 +       },
5849 +       {
5850 +               XTAG_PATCH,        { 1,  2, -1},    {
5851 +                                                                                               XTAG_SPEC,
5852 +                                                                                               XTAG_PREP,
5853 +                                                                                               XTAG_NO
5854 +                                                                                       },
5855 +               "patch"
5856 +       },
5857 +       {
5858 +               XTAG_NOSOURCE,     { 1, -1, -1},    {
5859 +                                                                                               XTAG_SPEC,
5860 +                                                                                               XTAG_NO
5861 +                                                                                       },
5862 +               "nosource"
5863 +       },
5864 +       {
5865 +               XTAG_MIRROR,       { 2, -1, -1},    {
5866 +                                                                                               XTAG_SOURCE,
5867 +                                                                                               XTAG_NO
5868 +                                                                                       },
5869 +               "mirror"
5870 +       },
5871 +       {
5872 +               XTAG_SUMMARY,      { 2, -1, -1},    {
5873 +                                                                                               XTAG_PACKAGE,
5874 +                                                                                               XTAG_NO
5875 +                                                                                       },
5876 +               "summary"
5877 +       },
5878 +       {
5879 +               XTAG_DESC,         { 2, -1, -1},    {
5880 +                                                                                               XTAG_PACKAGE,
5881 +                                                                                               XTAG_NO
5882 +                                                                                       },
5883 +               "description"
5884 +       },
5885 +       {
5886 +               XTAG_REQS,         { 2, -1, -1},    {
5887 +                                                                                               XTAG_PACKAGE,
5888 +                                                                                               XTAG_NO
5889 +                                                                                       },
5890 +               "requires"
5891 +       },
5892 +       {
5893 +               XTAG_BREQS,        { 2, -1, -1},    {
5894 +                                                                                               XTAG_PACKAGE,
5895 +                                                                                               XTAG_NO
5896 +                                                                                       },
5897 +               "buildrequires"
5898 +       },
5899 +       {
5900 +               XTAG_PROVS,        { 2, -1, -1},    {
5901 +                                                                                               XTAG_PACKAGE,
5902 +                                                                                               XTAG_NO
5903 +                                                                                       },
5904 +               "provides"
5905 +       },
5906 +       {
5907 +               XTAG_OBSOLS,       { 2, -1, -1},    {
5908 +                                                                                               XTAG_PACKAGE,
5909 +                                                                                               XTAG_NO
5910 +                                                                                       },
5911 +               "obsoletes"
5912 +       },
5913 +       {
5914 +               XTAG_FILES,        { 2, -1, -1},    {
5915 +                                                                                               XTAG_PACKAGE,
5916 +                                                                                               XTAG_NO
5917 +                                                                                       },
5918 +               "files"
5919 +       },
5920 +       {
5921 +               XTAG_FILE,         { 3, -1, -1},    {
5922 +                                                                                               XTAG_FILES,
5923 +                                                                                               XTAG_NO
5924 +                                                                                       },
5925 +               "file"
5926 +       },
5927 +       {
5928 +               XTAG_MACRO,        { 1, -1, -1},    {
5929 +                                                                                               XTAG_SPEC,
5930 +                                                                                               XTAG_NO
5931 +                                                                                       },
5932 +               "macro"
5933 +       },
5934 +       {
5935 +               XTAG_PREP,         { 1, -1, -1},    {
5936 +                                                                                               XTAG_SPEC,
5937 +                                                                                               XTAG_NO
5938 +                                                                                       },
5939 +               "prep"
5940 +       },
5941 +       {
5942 +               XTAG_SETUP,        { 2, -1, -1},    {
5943 +                                                                                               XTAG_PREP,
5944 +                                                                                               XTAG_NO
5945 +                                                                                       },
5946 +               "setup"
5947 +       },
5948 +       {
5949 +               XTAG_BUILD,        { 1, -1, -1},    {
5950 +                                                                                               XTAG_SPEC,
5951 +                                                                                               XTAG_NO
5952 +                                                                                       },
5953 +               "build"
5954 +       },
5955 +       {
5956 +               XTAG_INSTALL,      { 1, -1, -1},    {
5957 +                                                                                               XTAG_SPEC,
5958 +                                                                                               XTAG_NO
5959 +                                                                                       },
5960 +               "install"
5961 +       },
5962 +       {
5963 +               XTAG_CLEAN,        { 1, -1, -1},    {
5964 +                                                                                               XTAG_SPEC,
5965 +                                                                                               XTAG_NO
5966 +                                                                                       },
5967 +               "clean"
5968 +       },
5969 +       {
5970 +               XTAG_PRE,          { 2, -1, -1},    {
5971 +                                                                                               XTAG_PACKAGE,
5972 +                                                                                               XTAG_NO
5973 +                                                                                       },
5974 +               "pre"
5975 +       },
5976 +       {
5977 +               XTAG_POST,         { 2, -1, -1},    {
5978 +                                                                                               XTAG_PACKAGE,
5979 +                                                                                               XTAG_NO
5980 +                                                                                       },
5981 +               "post"
5982 +       },
5983 +       {
5984 +               XTAG_PREUN,       { 2, -1, -1},    {
5985 +                                                                                               XTAG_PACKAGE,
5986 +                                                                                               XTAG_NO
5987 +                                                                                       },
5988 +               "preun"
5989 +       },
5990 +       {
5991 +               XTAG_POSTUN,       { 2, -1, -1},    {
5992 +                                                                                               XTAG_PACKAGE,
5993 +                                                                                               XTAG_NO
5994 +                                                                                       },
5995 +               "postun"
5996 +       },
5997 +       {
5998 +               XTAG_VERIFY,        { 2, -1, -1},   {
5999 +                                                                                               XTAG_PACKAGE,
6000 +                                                                                               XTAG_NO
6001 +                                                                                       },
6002 +               "verify"
6003 +       },
6004 +       {
6005 +               XTAG_SCRIPT,       { 2,  3, -1},    {
6006 +                                                                                               XTAG_PREP,
6007 +                                                                                               XTAG_BUILD,
6008 +                                                                                               XTAG_INSTALL,
6009 +                                                                                               XTAG_CLEAN,
6010 +                                                                                               XTAG_PRE,
6011 +                                                                                               XTAG_POST,
6012 +                                                                                               XTAG_PREUN,
6013 +                                                                                               XTAG_POSTUN,
6014 +                                                                                               XTAG_VERIFY,
6015 +                                                                                               XTAG_NO
6016 +                                                                                       },
6017 +               "script"
6018 +       },
6019 +       {
6020 +               XTAG_CHANGELOG,    { 1, -1, -1},    {
6021 +                                                                                               XTAG_SPEC,
6022 +                                                                                               XTAG_NO
6023 +                                                                                       },
6024 +               "changelog"
6025 +       },
6026 +       {
6027 +               XTAG_CHANGES,      { 2, -1, -1},    {
6028 +                                                                                               XTAG_CHANGELOG,
6029 +                                                                                               XTAG_NO
6030 +                                                                                       },
6031 +               "changes"
6032 +       },
6033 +       {
6034 +               XTAG_CHANGE,       { 3, -1, -1},    {
6035 +                                                                                               XTAG_CHANGES,
6036 +                                                                                               XTAG_NO
6037 +                                                                                       },
6038 +               "change"
6039 +       },
6040 +       // this always needs to be the last entry
6041 +       {
6042 +               XTAG_NO,           {-1, -1, -1},    {
6043 +                                                                                               XTAG_NO
6044 +                                                                                       },
6045 +               "none"
6046 +       }
6047 +};
6048 +
6049 +const char* treeToString(unsigned int* pnTree,
6050 +                                                int nDepth)
6051 +{
6052 +       // internal string storage
6053 +       string sTree;
6054 +
6055 +       // build the tree to the specified depth
6056 +       for (int i = 0; i < nDepth; i++) {
6057 +               int j = 0;
6058 +               while (g_pMatches[j].m_nVal != pnTree[i])
6059 +                       j++;
6060 +               sTree += string("<") + string(g_pMatches[j].m_szName) + string(">");
6061 +       }
6062 +
6063 +       // return the tree string
6064 +       return sTree.c_str();
6065 +}
6066 +
6067 +unsigned int getTagValue(const char* szElement,
6068 +                                                int nDepth,
6069 +                                                unsigned int nPrev)
6070 +{
6071 +       // first convert the tag to a tag value
6072 +       unsigned int nTagVal = XTAG_NO;
6073 +
6074 +       // loop through all matches to see if we have a valid
6075 +       // tag here
6076 +       int i = 0;
6077 +       do {
6078 +               // test if we have a match
6079 +               if (strcasecmp(g_pMatches[i].m_szName, szElement) == 0) {
6080 +                       // look for a match on the tree depth
6081 +                       int j = 0;
6082 +                       nTagVal = XTAG_WRONGSTRUCT;
6083 +                       while (g_pMatches[i].m_pnDepth[j] != -1) {
6084 +                               if (g_pMatches[i].m_pnDepth[j++] == nDepth) {
6085 +                                       j = 0;
6086 +                                       do {
6087 +                                               if (g_pMatches[i].m_pnFollows[j] == nPrev) {
6088 +                                                       nTagVal = g_pMatches[i].m_nVal;
6089 +                                                       break;
6090 +                                               }
6091 +                                       } while (g_pMatches[i].m_pnFollows[++j] != XTAG_NO);
6092 +                                       break;
6093 +                               }
6094 +                       }
6095 +                       // break out
6096 +                       break;
6097 +               }
6098 +       } while (g_pMatches[++i].m_nVal != XTAG_NO);
6099 +
6100 +       // return
6101 +       return nTagVal;
6102 +}
6103 +
6104 +void createError(int nErrType,
6105 +                                structCBData* pData,
6106 +                                const char* szFormat, ...)
6107 +{
6108 +       // one more error/warning
6109 +       nErrType == XMLERR_WARNING ? pData->m_nWarnings++ : pData->m_nErrors++;
6110 +
6111 +       // setup internal variables
6112 +       FILE* fOut = stderr;
6113 +       switch (nErrType) {
6114 +               case XMLERR_WARNING:
6115 +                       fOut = stdout;
6116 +                       fprintf(fOut, "%s(%d): warning: ", pData->m_sFilename.c_str(),
6117 +                                                 XML_GetCurrentLineNumber(*(pData->m_pParser)));
6118 +                       break;
6119 +               case XMLERR_ERROR:
6120 +                       fprintf(fOut, "%s(%d): error:   ", pData->m_sFilename.c_str(),
6121 +                                                 XML_GetCurrentLineNumber(*(pData->m_pParser)));
6122 +                       break;
6123 +               case XMLERR_FATAL:
6124 +                       fprintf(fOut, "%s(%d): fatal:   ", pData->m_sFilename.c_str(),
6125 +                                                 XML_GetCurrentLineNumber(*(pData->m_pParser)));
6126 +                       break;
6127 +               default:
6128 +                       return;
6129 +       }
6130 +
6131 +       // create the argument list and print
6132 +       va_list vaArgList;
6133 +       va_start(vaArgList, szFormat);
6134 +       vfprintf(fOut, szFormat, vaArgList);
6135 +       fprintf(fOut, "\n");
6136 +}
6137 +
6138 +void startDepth0(structCBData* pData)
6139 +{
6140 +       // this indicates a spec start
6141 +       if (pData->m_pnTree[0] == XTAG_SPEC) {
6142 +               // if we have a spec already, we are in trouble
6143 +               if (pData->m_pSpec)
6144 +                       createError(XMLERR_ERROR, pData, "Extra 'spec' tag found.");
6145 +               else if (!(pData->m_pSpec = XMLSpec::parseCreate(pData->m_pAttrs,
6146 +                                                                                                                pData->m_sFilename.c_str())))
6147 +                       createError(XMLERR_ERROR, pData,
6148 +                                               "Failed to parse 'spec' tag (%s).",
6149 +                                               pData->m_pAttrs->getError());
6150 +               else if (pData->m_pAttrs->hasWarning())
6151 +                       createError(XMLERR_WARNING, pData, pData->m_pAttrs->getWarning());
6152 +       }
6153 +}
6154 +
6155 +void startDepth1(structCBData* pData)
6156 +{
6157 +       // make sure we have a spec
6158 +       if (!pData->m_pSpec) {
6159 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6160 +               return;
6161 +       }
6162 +
6163 +       // hanlde tag
6164 +       switch (pData->m_pnTree[1]) {
6165 +               case XTAG_PACKAGE:
6166 +                       if (!XMLPackage::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6167 +                               createError(XMLERR_ERROR, pData,
6168 +                                                       "Failed to parse 'package' tag or package already exists (%s).",
6169 +                                                       pData->m_pSpec->getError());
6170 +                       else if (pData->m_pSpec->hasWarning())
6171 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6172 +                       break;
6173 +               case XTAG_SOURCE:
6174 +                       if (!XMLSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6175 +                               createError(XMLERR_ERROR, pData,
6176 +                                                       "Failed to parse 'source' tag (%s).",
6177 +                                                       pData->m_pSpec->getError());
6178 +                       else if (pData->m_pSpec->hasWarning())
6179 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6180 +                       break;
6181 +               case XTAG_PATCH:
6182 +                       if (!XMLPatch::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6183 +                               createError(XMLERR_ERROR, pData,
6184 +                                                       "Failed to parse 'patch' tag (%s).",
6185 +                                                       pData->m_pSpec->getError());
6186 +                       else if (pData->m_pSpec->hasWarning())
6187 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6188 +                       break;
6189 +               case XTAG_NOSOURCE:
6190 +                       if (!XMLNoSource::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6191 +                               createError(XMLERR_ERROR, pData,
6192 +                                                       "Failed to parse 'nosource' tag (%s).",
6193 +                                                       pData->m_pSpec->getError());
6194 +                       else if (pData->m_pSpec->hasWarning())
6195 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6196 +                       break;
6197 +               case XTAG_CHANGELOG:
6198 +               case XTAG_PREP:
6199 +               case XTAG_BUILD:
6200 +               case XTAG_INSTALL:
6201 +               case XTAG_CLEAN:
6202 +               default:
6203 +                       break;
6204 +       }
6205 +}
6206 +
6207 +void startDepth2(structCBData* pData)
6208 +{
6209 +       // make sure we have a spec
6210 +       if (!pData->m_pSpec) {
6211 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6212 +               return;
6213 +       }
6214 +
6215 +       // handle tag
6216 +       switch (pData->m_pnTree[2]) {
6217 +               case XTAG_MIRROR:
6218 +                       switch (pData->m_pnTree[1]) {
6219 +                               case XTAG_SOURCE:
6220 +                                       if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6221 +                                               createError(XMLERR_ERROR, pData,
6222 +                                                                       "Failed to parse 'mirror' tag (%s).",
6223 +                                                                       pData->m_pSpec->getError());
6224 +                                       else if (pData->m_pSpec->hasWarning())
6225 +                                               createError(XMLERR_WARNING, pData,
6226 +                                                                       pData->m_pSpec->getWarning());
6227 +                                       break;
6228 +                               case XTAG_PATCH:
6229 +                                       if (!XMLMirror::parseCreate(pData->m_pAttrs, pData->m_pSpec, true))
6230 +                                               createError(XMLERR_ERROR, pData,
6231 +                                                                       "Failed to parse 'mirror' tag (%s).",
6232 +                                                                       pData->m_pSpec->getError());
6233 +                                       else if (pData->m_pSpec->hasWarning())
6234 +                                               createError(XMLERR_WARNING, pData,
6235 +                                                                       pData->m_pSpec->getWarning());
6236 +                                       break;
6237 +                       }
6238 +                       break;
6239 +               case XTAG_FILES:
6240 +                       if (!XMLFiles::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6241 +                               createError(XMLERR_ERROR, pData,
6242 +                                                       "Failed to parse 'change' tag (%s).",
6243 +                                                       pData->m_pSpec->getError());
6244 +                       else if (pData->m_pSpec->hasWarning())
6245 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6246 +                       break;
6247 +               case XTAG_CHANGES:
6248 +                       if (!XMLChangelogDate::parseCreate(pData->m_pAttrs, pData->m_pSpec))
6249 +                               createError(XMLERR_ERROR, pData,
6250 +                                                       "Failed to parse 'change' tag (%s).",
6251 +                                                       pData->m_pSpec->getError());
6252 +                       else if (pData->m_pSpec->hasWarning())
6253 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6254 +                       break;
6255 +               case XTAG_PRE:
6256 +                       if (!XMLPackageScripts::createPreScripts(pData->m_pAttrs, pData->m_pSpec))
6257 +                               createError(XMLERR_ERROR, pData,
6258 +                                                       "Failed to parse 'pre' tag (%s).",
6259 +                                                       pData->m_pSpec->getError());
6260 +                       else if (pData->m_pSpec->hasWarning())
6261 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6262 +                       break;
6263 +               case XTAG_POST:
6264 +                       if (!XMLPackageScripts::createPostScripts(pData->m_pAttrs, pData->m_pSpec))
6265 +                               createError(XMLERR_ERROR, pData,
6266 +                                                       "Failed to parse 'pre' tag (%s).",
6267 +                                                       pData->m_pSpec->getError());
6268 +                       else if (pData->m_pSpec->hasWarning())
6269 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6270 +                       break;
6271 +               case XTAG_PREUN:
6272 +                       if (!XMLPackageScripts::createPreUnScripts(pData->m_pAttrs, pData->m_pSpec))
6273 +                               createError(XMLERR_ERROR, pData,
6274 +                                                       "Failed to parse 'pre' tag (%s).",
6275 +                                                       pData->m_pSpec->getError());
6276 +                       else if (pData->m_pSpec->hasWarning())
6277 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6278 +                       break;
6279 +               case XTAG_POSTUN:
6280 +                       if (!XMLPackageScripts::createPostUnScripts(pData->m_pAttrs, pData->m_pSpec))
6281 +                               createError(XMLERR_ERROR, pData,
6282 +                                                       "Failed to parse 'pre' tag (%s).",
6283 +                                                       pData->m_pSpec->getError());
6284 +                       else if (pData->m_pSpec->hasWarning())
6285 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6286 +                       break;
6287 +               case XTAG_VERIFY:
6288 +                       if (!XMLPackageScripts::createVerifyScripts(pData->m_pAttrs, pData->m_pSpec))
6289 +                               createError(XMLERR_ERROR, pData,
6290 +                                                       "Failed to parse 'pre' tag (%s).",
6291 +                                                       pData->m_pSpec->getError());
6292 +                       else if (pData->m_pSpec->hasWarning())
6293 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6294 +                       break;
6295 +               case XTAG_REQS:
6296 +               case XTAG_BREQS:
6297 +               case XTAG_PROVS:
6298 +               case XTAG_OBSOLS:
6299 +               default:
6300 +                       break;
6301 +       }
6302 +}
6303 +
6304 +void startDepth3(structCBData* pData)
6305 +{
6306 +       // make sure we have a spec
6307 +       if (!pData->m_pSpec) {
6308 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6309 +               return;
6310 +       }
6311 +
6312 +       // handle tag
6313 +       switch (pData->m_pnTree[3]) {
6314 +               case XTAG_PACKAGE:
6315 +                       switch (pData->m_pnTree[2]) {
6316 +                               case XTAG_REQS:
6317 +                                       if (!XMLPackageContainer::addRequire(pData->m_pAttrs,
6318 +                                                                                                                pData->m_pSpec))
6319 +                                               createError(XMLERR_ERROR, pData,
6320 +                                                       "Failed to parse 'package' tag (%s).",
6321 +                                                       pData->m_pSpec->getError());
6322 +                                       else if (pData->m_pSpec->hasWarning())
6323 +                                               createError(XMLERR_WARNING, pData,
6324 +                                                                       pData->m_pSpec->getWarning());
6325 +                                       break;
6326 +                               case XTAG_BREQS:
6327 +                                       if (!XMLPackageContainer::addBuildRequire(pData->m_pAttrs,
6328 +                                                                                                                         pData->m_pSpec))
6329 +                                               createError(XMLERR_ERROR, pData,
6330 +                                                       "Failed to parse 'package' tag (%s).",
6331 +                                                       pData->m_pSpec->getError());
6332 +                                       else if (pData->m_pSpec->hasWarning())
6333 +                                               createError(XMLERR_WARNING, pData,
6334 +                                                                       pData->m_pSpec->getWarning());
6335 +                                       break;
6336 +                               case XTAG_PROVS:
6337 +                                       if (!XMLPackageContainer::addProvide(pData->m_pAttrs,
6338 +                                                                                                                pData->m_pSpec))
6339 +                                               createError(XMLERR_ERROR, pData,
6340 +                                                       "Failed to parse 'package' tag (%s).",
6341 +                                                       pData->m_pSpec->getError());
6342 +                                       else if (pData->m_pSpec->hasWarning())
6343 +                                               createError(XMLERR_WARNING, pData,
6344 +                                                                       pData->m_pSpec->getWarning());
6345 +                                       break;
6346 +                               case XTAG_OBSOLS:
6347 +                                       if (!XMLPackageContainer::addObsolete(pData->m_pAttrs,
6348 +                                                                                                                 pData->m_pSpec))
6349 +                                               createError(XMLERR_ERROR, pData,
6350 +                                                       "Failed to parse 'package' tag (%s).",
6351 +                                                       pData->m_pSpec->getError());
6352 +                                       else if (pData->m_pSpec->hasWarning())
6353 +                                               createError(XMLERR_WARNING, pData,
6354 +                                                                       pData->m_pSpec->getWarning());
6355 +                                       break;
6356 +                               default:
6357 +                                       break;
6358 +                       }
6359 +                       break;
6360 +               default:
6361 +                       break;
6362 +       }
6363 +}
6364 +
6365 +void startElementCB(void* pCBData,
6366 +                                       const char* szElement,
6367 +                                       const char** szAttr)
6368 +{
6369 +       // get the data structure we are working with and
6370 +       structCBData* pData = (structCBData*)pCBData;
6371 +
6372 +       // validate and get the tag we are working with
6373 +       unsigned int nTag = getTagValue(szElement,
6374 +                                                                       pData->m_nDepth,
6375 +                                                                       pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6376 +
6377 +       if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6378 +               return createError(XMLERR_WARNING, pData, "Unexpected tag '%s' in structure '%s'.",
6379 +                                                 szElement,
6380 +                                                 treeToString(pData->m_pnTree, pData->m_nDepth++));
6381 +       pData->m_pnTree[pData->m_nDepth] = nTag;
6382 +       pData->m_sData.assign("");
6383 +
6384 +       if (pData->m_pAttrs)
6385 +               delete pData->m_pAttrs;
6386 +       pData->m_pAttrs = new XMLAttrs(szAttr);
6387 +
6388 +       switch (pData->m_nDepth++) {
6389 +               case 0:
6390 +                       startDepth0(pData);
6391 +                       break;
6392 +               case 1:
6393 +                       startDepth1(pData);
6394 +                       break;
6395 +               case 2:
6396 +                       startDepth2(pData);
6397 +                       break;
6398 +               case 3:
6399 +                       startDepth3(pData);
6400 +                       break;
6401 +               default:
6402 +                       break;
6403 +       }
6404 +}
6405 +
6406 +void endDepth1(structCBData* pData)
6407 +{
6408 +       // make sure we have a spec
6409 +       if (!pData->m_pSpec) {
6410 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6411 +               return;
6412 +       }
6413 +
6414 +       // handle tag
6415 +       switch (pData->m_pnTree[1]) {
6416 +               case XTAG_MACRO:
6417 +                       if (!XMLMacro::parseCreate(pData->m_pAttrs,
6418 +                                                                          pData->m_sData.c_str(),
6419 +                                                                          pData->m_pSpec))
6420 +                               createError(XMLERR_ERROR, pData,
6421 +                                                       "Failed to add macro entry (%s).",
6422 +                                                       pData->m_pAttrs->getError());
6423 +                       else if (pData->m_pSpec->hasWarning())
6424 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6425 +                       break;
6426 +               default:
6427 +                       break;
6428 +       }
6429 +}
6430 +
6431 +void endDepth2(structCBData* pData)
6432 +{
6433 +       // make sure we have a spec
6434 +       if (!pData->m_pSpec) {
6435 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6436 +               return;
6437 +       }
6438 +
6439 +       // do the tag
6440 +       switch (pData->m_pnTree[2]) {
6441 +               case XTAG_SUMMARY:
6442 +                       if (!XMLPackage::addSummary(pData->m_pAttrs, pData->m_sData.c_str(),
6443 +                                                                               pData->m_pSpec))
6444 +                               createError(XMLERR_ERROR, pData,
6445 +                                                       "Failed to add 'summary'.");
6446 +                       break;
6447 +               case XTAG_DESC:
6448 +                       if (!XMLPackage::addDescription(pData->m_pAttrs, pData->m_sData.c_str(),
6449 +                                                                                       pData->m_pSpec))
6450 +                               createError(XMLERR_ERROR, pData,
6451 +                                                       "Failed to add 'description'.");
6452 +                       break;
6453 +               case XTAG_SCRIPT:
6454 +                       switch (pData->m_pnTree[1]) {
6455 +                               case XTAG_PREP:
6456 +                                       if (!XMLScripts::addPrepScript(pData->m_pAttrs,
6457 +                                                                                                  pData->m_sData.c_str(),
6458 +                                                                                                  pData->m_pSpec))
6459 +                                               createError(XMLERR_ERROR, pData,
6460 +                                                                       "Failed to add shell entry.");
6461 +                                       break;
6462 +                               case XTAG_BUILD:
6463 +                                       if (!XMLScripts::addBuildScript(pData->m_pAttrs,
6464 +                                                                                                       pData->m_sData.c_str(),
6465 +                                                                                                       pData->m_pSpec))
6466 +                                               createError(XMLERR_ERROR, pData,
6467 +                                                                       "Failed to add shell entry.");
6468 +                                       break;
6469 +                               case XTAG_INSTALL:
6470 +                                       if (!XMLScripts::addInstallScript(pData->m_pAttrs,
6471 +                                                                                                         pData->m_sData.c_str(),
6472 +                                                                                                         pData->m_pSpec))
6473 +                                               createError(XMLERR_ERROR, pData,
6474 +                                                                       "Failed to add shell entry.");
6475 +                                       break;
6476 +                               case XTAG_CLEAN:
6477 +                                       if (!XMLScripts::addCleanScript(pData->m_pAttrs,
6478 +                                                                                                       pData->m_sData.c_str(),
6479 +                                                                                                       pData->m_pSpec))
6480 +                                               createError(XMLERR_ERROR, pData,
6481 +                                                                       "Failed to add shell entry.");
6482 +                                       break;
6483 +                               default:
6484 +                                       break;
6485 +                       }
6486 +                       break;
6487 +               default:
6488 +                       break;
6489 +       }
6490 +}
6491 +
6492 +void endDepth3(structCBData* pData)
6493 +{
6494 +       // make sure we have a spec
6495 +       if (!pData->m_pSpec) {
6496 +               createError(XMLERR_ERROR, pData, "Spec has not been defined.");
6497 +               return;
6498 +       }
6499 +
6500 +       // handle tag
6501 +       switch (pData->m_pnTree[3]) {
6502 +               case XTAG_CHANGE:
6503 +                       if (!XMLChangelogEntry::parseCreate(pData->m_pAttrs,
6504 +                                                                                               pData->m_sData.c_str(),
6505 +                                                                                               pData->m_pSpec))
6506 +                               createError(XMLERR_ERROR, pData,
6507 +                                                       "Failed to add changelog entry.");
6508 +                       else if (pData->m_pSpec->hasWarning())
6509 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6510 +                       break;
6511 +               case XTAG_FILE:
6512 +                       if (!XMLFile::parseCreate(pData->m_pAttrs,
6513 +                                                                         pData->m_sData.c_str(),
6514 +                                                                         pData->m_pSpec))
6515 +                               createError(XMLERR_ERROR, pData, "Failed to parse 'file' tag (%s).",
6516 +                                                       pData->m_pSpec->getError());
6517 +                       else if (pData->m_pSpec->hasWarning())
6518 +                               createError(XMLERR_WARNING, pData, pData->m_pSpec->getWarning());
6519 +                       break;
6520 +               case XTAG_SCRIPT:
6521 +                       switch (pData->m_pnTree[2]) {
6522 +                               case XTAG_PRE:
6523 +                                       if (!XMLPackageScripts::addPreScript(pData->m_pAttrs,
6524 +                                                                                                                pData->m_sData.c_str(),
6525 +                                                                                                                pData->m_pSpec))
6526 +                                               createError(XMLERR_ERROR, pData,
6527 +                                                                       "Failed to parse 'script' tag (%s).",
6528 +                                                                       pData->m_pSpec->getError());
6529 +                                       else if (pData->m_pSpec->hasWarning())
6530 +                                               createError(XMLERR_WARNING, pData,
6531 +                                                                       pData->m_pSpec->getWarning());
6532 +                                       break;
6533 +                               case XTAG_POST:
6534 +                                       if (!XMLPackageScripts::addPostScript(pData->m_pAttrs,
6535 +                                                                                                                 pData->m_sData.c_str(),
6536 +                                                                                                                 pData->m_pSpec))
6537 +                                               createError(XMLERR_ERROR, pData,
6538 +                                                                       "Failed to parse 'script' tag (%s).",
6539 +                                                                       pData->m_pSpec->getError());
6540 +                                       else if (pData->m_pSpec->hasWarning())
6541 +                                               createError(XMLERR_WARNING, pData,
6542 +                                                                       pData->m_pSpec->getWarning());
6543 +                                       break;
6544 +                               case XTAG_PREUN:
6545 +                                       if (!XMLPackageScripts::addPreUnScript(pData->m_pAttrs,
6546 +                                                                                                                  pData->m_sData.c_str(),
6547 +                                                                                                                  pData->m_pSpec))
6548 +                                               createError(XMLERR_ERROR, pData,
6549 +                                                                       "Failed to parse 'script' tag (%s).",
6550 +                                                                       pData->m_pSpec->getError());
6551 +                                       else if (pData->m_pSpec->hasWarning())
6552 +                                               createError(XMLERR_WARNING, pData,
6553 +                                                                       pData->m_pSpec->getWarning());
6554 +                                       break;
6555 +                               case XTAG_POSTUN:
6556 +                                       if (!XMLPackageScripts::addPostUnScript(pData->m_pAttrs,
6557 +                                                                                                                       pData->m_sData.c_str(),
6558 +                                                                                                                       pData->m_pSpec))
6559 +                                               createError(XMLERR_ERROR, pData,
6560 +                                                                       "Failed to parse 'script' tag (%s).",
6561 +                                                                       pData->m_pSpec->getError());
6562 +                                       else if (pData->m_pSpec->hasWarning())
6563 +                                               createError(XMLERR_WARNING, pData,
6564 +                                                                       pData->m_pSpec->getWarning());
6565 +                                       break;
6566 +                               case XTAG_VERIFY:
6567 +                                       if (!XMLPackageScripts::addVerifyScript(pData->m_pAttrs,
6568 +                                                                                                                       pData->m_sData.c_str(),
6569 +                                                                                                                       pData->m_pSpec))
6570 +                                               createError(XMLERR_ERROR, pData,
6571 +                                                                       "Failed to parse 'script' tag (%s).",
6572 +                                                                       pData->m_pSpec->getError());
6573 +                                       else if (pData->m_pSpec->hasWarning())
6574 +                                               createError(XMLERR_WARNING, pData,
6575 +                                                                       pData->m_pSpec->getWarning());
6576 +                                       break;
6577 +                               default:
6578 +                                       break;
6579 +                       }
6580 +                       break;
6581 +               default:
6582 +                       break;
6583 +       }
6584 +}
6585 +
6586 +void endElementCB(void* pCBData,
6587 +                                const char* szElement)
6588 +{
6589 +       // get the data structure we are working with
6590 +       structCBData* pData = (structCBData*)pCBData;
6591 +       pData->m_nDepth--;
6592 +
6593 +       // validate and get the tag we are working with
6594 +       unsigned int nTag = getTagValue(szElement,
6595 +                                                                       pData->m_nDepth,
6596 +                                                                       pData->m_nDepth ? pData->m_pnTree[pData->m_nDepth-1] : XTAG_ANY);
6597 +       if (nTag == XTAG_NO || nTag == XTAG_WRONGSTRUCT)
6598 +               return;
6599 +
6600 +       // handle the tree depth
6601 +       switch (pData->m_nDepth) {
6602 +               case 0:
6603 +                       break;
6604 +               case 1:
6605 +                       endDepth1(pData);
6606 +                       break;
6607 +               case 2:
6608 +                       endDepth2(pData);
6609 +                       break;
6610 +               case 3:
6611 +                       endDepth3(pData);
6612 +                       break;
6613 +               default:
6614 +                       break;
6615 +       }
6616 +
6617 +       // clean up
6618 +       pData->m_sData.assign("");
6619 +}
6620 +
6621 +void characterCB(void* pCBData,
6622 +                                const char* szStr,
6623 +                                int nLen)
6624 +{
6625 +       // get the data structure we are working with
6626 +       structCBData* pData = (structCBData*)pCBData;
6627 +
6628 +       // append the string to our internal data
6629 +       if (nLen) {
6630 +               char* szTmp = new char[nLen+1];
6631 +               strncpy(szTmp, szStr, nLen);
6632 +               szTmp[nLen] = '\0';
6633 +               pData->m_sData.append(szTmp);
6634 +               delete[] szTmp;
6635 +       }
6636 +}
6637 +
6638 +int parseXMLSpec(const char* szXMLFilename,
6639 +                                XMLSpec*& pSpec)
6640 +{
6641 +       // create and setup our parser for use
6642 +       printf("Creating XML parser instance ... ");
6643 +       XML_Parser parser = XML_ParserCreate(NULL);
6644 +       if (!parser) {
6645 +               printf("Failed.\n\tERROR: Couldn't allocate memory for parser\n\n");
6646 +               return -1;
6647 +       }
6648 +       else
6649 +               printf("Ok.\n");
6650 +       XML_SetElementHandler(parser, startElementCB, endElementCB);
6651 +       XML_SetCharacterDataHandler(parser, characterCB);
6652 +       structCBData stData;
6653 +       stData.m_pParser = &parser;
6654 +       stData.m_sFilename.assign(szXMLFilename);
6655 +       stData.m_nWarnings = 0;
6656 +       stData.m_nErrors = 0;
6657 +       stData.m_nDepth = 0;
6658 +       stData.m_pSpec = NULL;
6659 +       stData.m_pAttrs = NULL;
6660 +       XML_SetUserData(parser, (void*)&stData);
6661 +
6662 +       // open the input and output files here
6663 +       printf("Opening input XML spec ... ");
6664 +       ifstream fIn(szXMLFilename);
6665 +       if (!fIn.is_open()) {
6666 +               printf("Failed.\n\tERROR: Could not open %s\n\n", szXMLFilename);
6667 +               return -2;
6668 +       }
6669 +       else
6670 +               printf("Ok.\n");
6671 +
6672 +       // parse our configuration (loop through file,
6673 +       // doing a break if needed (fatal error))
6674 +       printf("Parsing %s: \n", szXMLFilename);
6675 +       char szBuff[1024+1];
6676 +       unsigned int nLength = 0;
6677 +       while (!fIn.eof()) {
6678 +               fIn.get(szBuff, 1024, '\0');
6679 +               unsigned int nRead = strlen(szBuff);
6680 +               nLength += nRead;
6681 +               if (!XML_Parse(parser, szBuff, nRead, fIn.eof() ? 1 : 0)) {
6682 +                       createError(XMLERR_FATAL, &stData, "XML parsing: %s",
6683 +                                               XML_ErrorString(XML_GetErrorCode(parser)));
6684 +                       break;
6685 +               }
6686 +       }
6687 +
6688 +       // print the end results
6689 +       printf("\t%d bytes parsed, %d errors(s), %d warnings(s)\n",
6690 +                       nLength, stData.m_nErrors, stData.m_nWarnings);
6691 +       printf("Closing input XML spec ... ");
6692 +       fIn.close();
6693 +       printf("Ok.\n");
6694 +
6695 +       // clean up
6696 +       if (stData.m_nErrors) {
6697 +               if (stData.m_pSpec != NULL)
6698 +                       delete stData.m_pSpec;
6699 +               pSpec = NULL;
6700 +       }
6701 +       else
6702 +               pSpec = stData.m_pSpec;
6703 +
6704 +       // return number of errors
6705 +       return stData.m_nErrors;
6706 +}
6707 Index: xmlspec/XMLParser.h
6708 ===================================================================
6709 RCS file: xmlspec/XMLParser.h
6710 diff -N xmlspec/XMLParser.h
6711 --- /dev/null   1 Jan 1970 00:00:00 -0000
6712 +++ rpm/xmlspec/XMLParser.h     28 Aug 2002 10:52:43 -0000      1.1.1.1.2.1
6713 @@ -0,0 +1,19 @@
6714 +#ifndef _H_XMLPARSER_
6715 +#define _H_XMLPARSER_
6716 +
6717 +// our includes
6718 +#include "XMLSpec.h"
6719 +
6720 +/**
6721 + * Parses an XML spec into the internal data structures as
6722 + * defined in the XML* classes.
6723 + * .
6724 + * @param szXMLFilename The Spec to read as parser input
6725 + * @param pSpec         A reference to the spec data structure we
6726 + *                      are to fill.
6727 + * @return The number of parsing/other errors (0 == success)
6728 + **/
6729 +extern int parseXMLSpec(const char* szXMLFilename,
6730 +                                               XMLSpec*& pSpec);
6731 +
6732 +#endif
6733 Index: xmlspec/XMLRPMWrap.cpp
6734 ===================================================================
6735 RCS file: xmlspec/XMLRPMWrap.cpp
6736 diff -N xmlspec/XMLRPMWrap.cpp
6737 --- /dev/null   1 Jan 1970 00:00:00 -0000
6738 +++ rpm/xmlspec/XMLRPMWrap.cpp  28 Aug 2002 10:52:43 -0000      1.1.2.1
6739 @@ -0,0 +1,72 @@
6740 +// standard c++ includes
6741 +#include <string>
6742 +#include <vector>
6743 +
6744 +// rpm includes
6745 +#include <rpmlib.h>
6746 +#include <rpmbuild.h>
6747 +
6748 +// type definitions
6749 +typedef vector<string> t_StrVector;
6750 +
6751 +using namespace std;
6752 +
6753 +bool getRPMHeader(Header header,
6754 +                                 int_32 nTag,
6755 +                                 string& rResult)
6756 +{
6757 +       if (headerIsEntry(header, nTag)) {
6758 +               int_32 nCount, nTagType;
6759 +               void* pBuffer;
6760 +               if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6761 +                       return false;
6762 +               char szTemp[32];
6763 +               switch (nTagType) {
6764 +                       case RPM_INT32_TYPE:
6765 +                               sprintf(szTemp, "%d", *((int_32*)pBuffer));
6766 +                               rResult.assign(szTemp);
6767 +                       default:
6768 +                               rResult.assign((char*)pBuffer);
6769 +                               break;
6770 +               }
6771 +               headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6772 +               return true;
6773 +       }
6774 +       else
6775 +               return false;
6776 +}
6777 +
6778 +bool getRPMHeaderArray(Header header,
6779 +                                          int_32 nTag,
6780 +                                          t_StrVector& rvResult)
6781 +{
6782 +       rvResult.clear();
6783 +       if (headerIsEntry(header, nTag)) {
6784 +               int_32 nCount, nTagType;
6785 +               void* pBuffer;
6786 +               if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount))
6787 +                       return false;
6788 +               if (nTagType == RPM_STRING_ARRAY_TYPE || nTagType == RPM_I18NSTRING_TYPE) {
6789 +                       for (int_32 i = 0; i < nCount; i++)
6790 +                               rvResult.push_back(((char**)pBuffer)[i]);
6791 +               }
6792 +               else
6793 +                       rvResult.push_back((char*)pBuffer);
6794 +               headerFreeData(pBuffer, (rpmTagType_e)nTagType);
6795 +               return true;
6796 +       }
6797 +       else
6798 +               return false;
6799 +}
6800 +
6801 +bool getRPMMacro(const char* szMacro,
6802 +                                string& rResult)
6803 +{
6804 +       char* szValue = rpmExpand(szMacro, NULL);
6805 +       if (szValue) {
6806 +               rResult.assign(szValue);
6807 +               return true;
6808 +       }
6809 +       else
6810 +               return false;
6811 +}
6812 Index: xmlspec/XMLRPMWrap.h
6813 ===================================================================
6814 RCS file: xmlspec/XMLRPMWrap.h
6815 diff -N xmlspec/XMLRPMWrap.h
6816 --- /dev/null   1 Jan 1970 00:00:00 -0000
6817 +++ rpm/xmlspec/XMLRPMWrap.h    28 Aug 2002 10:52:43 -0000      1.1.2.1
6818 @@ -0,0 +1,49 @@
6819 +#ifndef _H_XMLRPMWRAP_
6820 +#define _H_XMLRPMWRAP_
6821 +
6822 +// standard C++ includes
6823 +#include <string>
6824 +#include <vector>
6825 +
6826 +// rpm includes
6827 +#include <rpmlib.h>
6828 +
6829 +// type definitions
6830 +typedef vector<string> t_StrVector;
6831 +
6832 +/**
6833 + * Gets an RPM header after checking that is does exist.
6834 + * .
6835 + * @param header The RPM header to interrogate
6836 + * @param nTag The header tag to extract
6837 + * @param rResult The string to populate with the result
6838 + * @return true on success, false otherwise
6839 + **/
6840 +extern bool getRPMHeader(Header header,
6841 +                                                int_32 nTag,
6842 +                                                std::string& rResult);
6843 +
6844 +/**
6845 + * Gets an RPM header array into a vector after checking that it
6846 + * does indeed exist
6847 + * .
6848 + * @param header The RPM header to interrogate
6849 + * @param nTag The header tag to extract
6850 + * @param rvResult The vector<string> to populate with the result
6851 + * @return true on success, false otherwise
6852 + **/
6853 +extern bool getRPMHeaderArray(Header header,
6854 +                                                         int_32 nTag,
6855 +                                                         t_StrVector& rvResult);
6856 +
6857 +/**
6858 + * Gets a specific RPM macro
6859 + * .
6860 + * @param szMacro The macro to get the value of
6861 + * @param rResult The string to populate with the result
6862 + * @return true on success, false otherwise
6863 + **/
6864 +extern bool getRPMMacro(const char* szMacro,
6865 +                                               std::string& rResult);
6866 +
6867 +#endif
6868 Index: xmlspec/XMLRequires.cpp
6869 ===================================================================
6870 RCS file: xmlspec/XMLRequires.cpp
6871 diff -N xmlspec/XMLRequires.cpp
6872 --- /dev/null   1 Jan 1970 00:00:00 -0000
6873 +++ rpm/xmlspec/XMLRequires.cpp 28 Aug 2002 10:52:43 -0000      1.2.2.1
6874 @@ -0,0 +1,189 @@
6875 +// our includes
6876 +#include "XMLAttrs.h"
6877 +#include "XMLPackage.h"
6878 +#include "XMLRequires.h"
6879 +#include "XMLRPMWrap.h"
6880 +#include "XMLSpec.h"
6881 +
6882 +// rpm includes
6883 +#include <rpmlib.h>
6884 +
6885 +using namespace std;
6886 +
6887 +// attribute structure for XMLPackageEntry
6888 +structValidAttrs g_paEntryAttrs[] =
6889 +{
6890 +       {0x0000,    true,  false, "name",    XATTRTYPE_STRING, {"*", NULL}},
6891 +       {0x0001,    false, false, "version", XATTRTYPE_STRING, {"*", NULL}},
6892 +       {0x0002,    false, false, "cmp",     XATTRTYPE_STRING, {"*", NULL}},
6893 +       {XATTR_END, false, false, "end",     XATTRTYPE_NONE,   {NULL}}
6894 +};
6895 +
6896 +bool XMLPackageEntry::parseCreate(XMLAttrs* pAttrs,
6897 +                                                                 XMLPackageContainer& rContainer)
6898 +{
6899 +       // validate the attributes
6900 +       if (!pAttrs->validate(g_paEntryAttrs, (XMLBase*)pAttrs))
6901 +               return false;
6902 +
6903 +       // create and return
6904 +       XMLPackageEntry entry(pAttrs->asString("name"), pAttrs->asString("version"),
6905 +                                                 pAttrs->asString("cmp"));
6906 +       rContainer.addEntry(entry);
6907 +       return true;
6908 +}
6909 +
6910 +XMLPackageEntry::XMLPackageEntry(const char* szName,
6911 +                                                                const char* szVersion,
6912 +                                                                const char* szCmp)
6913 +       : XMLBase()
6914 +{
6915 +       if (szName)
6916 +               m_sName.assign(szName);
6917 +       if (szVersion)
6918 +               m_sVersion.assign(szVersion);
6919 +       m_sCmp.assign("=");
6920 +       if (szCmp) {
6921 +               if (strcasecmp(szCmp, "lt") == 0)
6922 +                       m_sCmp.assign("<");
6923 +               else if (strcasecmp(szCmp, "le") == 0)
6924 +                       m_sCmp.assign("<=");
6925 +               else if (strcasecmp(szCmp, "gt") == 0)
6926 +                       m_sCmp.assign(">");
6927 +               else if (strcasecmp(szCmp, "ge") == 0)
6928 +                       m_sCmp.assign(">=");
6929 +       }
6930 +}
6931 +
6932 +XMLPackageEntry::XMLPackageEntry(const XMLPackageEntry& rEntry)
6933 +       : XMLBase()
6934 +{
6935 +       m_sName.assign(rEntry.m_sName);
6936 +       m_sVersion.assign(rEntry.m_sVersion);
6937 +       m_sCmp.assign(rEntry.m_sCmp);
6938 +}
6939 +
6940 +XMLPackageEntry::~XMLPackageEntry()
6941 +{
6942 +}
6943 +
6944 +XMLPackageEntry XMLPackageEntry::operator=(XMLPackageEntry entry)
6945 +{
6946 +       m_sName.assign(entry.m_sName);
6947 +       m_sVersion.assign(entry.m_sVersion);
6948 +       m_sCmp.assign(entry.m_sCmp);
6949 +       return *this;
6950 +}
6951 +
6952 +void XMLPackageEntry::toSpecFile(ostream& rOut)
6953 +{
6954 +       rOut << getName();
6955 +       if (hasVersion()) {
6956 +               rOut << " " << getCompare() << " " << getVersion();
6957 +       }
6958 +}
6959 +
6960 +void XMLPackageEntry::toXMLFile(ostream& rOut)
6961 +{
6962 +       rOut << endl << "\t\t\t<package name=\"" << getName() << "\"";
6963 +       if (hasVersion()) {
6964 +               if (m_sCmp.compare("=") == 0)
6965 +                       rOut << " cmp=\"eq\"";
6966 +               else if (m_sCmp.compare("<") == 0)
6967 +                       rOut << " cmp=\"lt\"";
6968 +               else if (m_sCmp.compare("<=") == 0)
6969 +                       rOut << " cmp=\"le\"";
6970 +               else if (m_sCmp.compare(">") == 0)
6971 +                       rOut << " cmp=\"gt\"";
6972 +               else if (m_sCmp.compare(">=") == 0)
6973 +                       rOut << " cmp=\"ge\"";
6974 +               rOut << " version=\"" << getVersion() << "\"";
6975 +       }
6976 +       rOut << " />";
6977 +}
6978 +
6979 +XMLPackageContainer::XMLPackageContainer()
6980 +       : XMLBase()
6981 +{
6982 +}
6983 +
6984 +XMLPackageContainer::XMLPackageContainer(const XMLPackageContainer& rContainer)
6985 +       : XMLBase()
6986 +{
6987 +       m_vPackages = rContainer.m_vPackages;
6988 +}
6989 +
6990 +XMLPackageContainer::~XMLPackageContainer()
6991 +{
6992 +}
6993 +
6994 +XMLPackageContainer XMLPackageContainer::operator=(XMLPackageContainer container)
6995 +{
6996 +       m_vPackages = container.m_vPackages;
6997 +       return *this;
6998 +}
6999 +
7000 +void XMLPackageContainer::toSpecFile(ostream& rOut,
7001 +                                                                        const char* szTag)
7002 +{
7003 +       if (numEntries()) {
7004 +               rOut << szTag << ": ";
7005 +               for (unsigned int i = 0; i < numEntries(); i++) {
7006 +                       rOut << (i ? ", " : "");
7007 +                       getEntry(i).toSpecFile(rOut);
7008 +               }
7009 +               rOut << endl;
7010 +       }
7011 +}
7012 +
7013 +void XMLPackageContainer::toXMLFile(ostream& rOut,
7014 +                                                                       const char* szTag)
7015 +{
7016 +       if (numEntries()) {
7017 +               rOut << endl << "\t\t<" << szTag << ">";
7018 +               for (unsigned int i = 0; i < numEntries(); i++)
7019 +                       getEntry(i).toXMLFile(rOut);
7020 +               rOut << endl << "\t\t</" << szTag << ">";
7021 +       }
7022 +}
7023 +
7024 +bool XMLPackageContainer::addRequire(XMLAttrs* pAttrs,
7025 +                                                                        XMLSpec* pSpec)
7026 +{
7027 +       if (!pSpec)
7028 +               return false;
7029 +       return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getRequires());
7030 +}
7031 +
7032 +bool XMLPackageContainer::addBuildRequire(XMLAttrs* pAttrs,
7033 +                                                                                 XMLSpec* pSpec)
7034 +{
7035 +       if (!pSpec)
7036 +               return false;
7037 +       return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getBuildRequires());
7038 +}
7039 +
7040 +bool XMLPackageContainer::addProvide(XMLAttrs* pAttrs,
7041 +                                                                        XMLSpec* pSpec)
7042 +{
7043 +       if (!pSpec)
7044 +               return false;
7045 +       return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getProvides());
7046 +}
7047 +
7048 +bool XMLPackageContainer::addObsolete(XMLAttrs* pAttrs,
7049 +                                                                         XMLSpec* pSpec)
7050 +{
7051 +       if (!pSpec)
7052 +               return false;
7053 +       return XMLPackageEntry::parseCreate(pAttrs, pSpec->lastPackage().getObsoletes());
7054 +}
7055 +
7056 +bool XMLPackageContainer::structCreate(PackageStruct* pPackage,
7057 +                                                                          Spec pSpec,
7058 +                                                                          XMLSpec* pXSpec)
7059 +{
7060 +       if (!pXSpec || !pPackage || !pPackage->header)
7061 +               return false;
7062 +       return true;
7063 +}
7064 Index: xmlspec/XMLRequires.h
7065 ===================================================================
7066 RCS file: xmlspec/XMLRequires.h
7067 diff -N xmlspec/XMLRequires.h
7068 --- /dev/null   1 Jan 1970 00:00:00 -0000
7069 +++ rpm/xmlspec/XMLRequires.h   28 Aug 2002 10:52:43 -0000      1.2.2.1
7070 @@ -0,0 +1,327 @@
7071 +#ifndef _H_XMLREQUIRES_
7072 +#define _H_XMLREQUIRES_
7073 +
7074 +// standard C++ includes
7075 +#include <iostream>
7076 +#include <string>
7077 +#include <vector>
7078 +
7079 +// standard C includes
7080 +#include <stdio.h>
7081 +
7082 +// our includes
7083 +#include "XMLAttrs.h"
7084 +#include "XMLBase.h"
7085 +
7086 +// forward definitions
7087 +class XMLPackage;
7088 +class XMLPackageContainer;
7089 +class XMLSpec;
7090 +
7091 +using namespace std;
7092 +
7093 +//<package ...> (after requires, buildrequires, obsoletes, provides)
7094 +class XMLPackageEntry : public XMLBase
7095 +{
7096 +//
7097 +// factory functions
7098 +//
7099 +public:
7100 +       /**
7101 +        * Creates an object as parsed from an XML spec
7102 +        * .
7103 +        * @param pAttrs XML atrtributes to use
7104 +        * @param rContainer The container to which to add the object
7105 +        * @return true on success, false otherwise
7106 +        **/
7107 +       static bool parseCreate(XMLAttrs* pAttrs,
7108 +                                                       XMLPackageContainer& rContainer);
7109 +
7110 +//
7111 +// constructors/destructor
7112 +//
7113 +public:
7114 +       /**
7115 +        * Default constructor
7116 +        * .
7117 +        * @param szName Name of the package
7118 +        * @param szVersion version of the package
7119 +        * @param szCmp the comparator (eq,lt,le,gt,ge)
7120 +        * @return none
7121 +        **/
7122 +       XMLPackageEntry(const char* szName,
7123 +                                       const char* szVersion,
7124 +                                       const char* szCmp);
7125 +
7126 +       /**
7127 +        * Copy constructor
7128 +        * .
7129 +        * @param rEntry reference to the entrry to copy
7130 +        * @return none
7131 +        **/
7132 +       XMLPackageEntry(const XMLPackageEntry& rEntry);
7133 +
7134 +       /**
7135 +        * Destructor
7136 +        * .
7137 +        * @param none
7138 +        * @return none
7139 +        **/
7140 +       ~XMLPackageEntry();
7141 +
7142 +//
7143 +// operators
7144 +//
7145 +public:
7146 +       /**
7147 +        * Assignment operator
7148 +        * .
7149 +        * @param entry The entry to assigne to
7150 +        * @return thye modified object
7151 +        **/
7152 +       XMLPackageEntry operator=(XMLPackageEntry entry);
7153 +//
7154 +// member functions
7155 +//
7156 +public:
7157 +       /**
7158 +        * Converts the object into an RPM spec
7159 +        * .
7160 +        * @param rOut Output stream
7161 +        * @return none
7162 +        **/
7163 +       void toSpecFile(ostream& rOut);
7164 +
7165 +       /**
7166 +        * Converts the object into an XML spec
7167 +        * .
7168 +        * @param rOut output stream
7169 +        * @return none
7170 +        **/
7171 +       void toXMLFile(ostream& rOut);
7172 +
7173 +//
7174 +// member variable get/set functions
7175 +//
7176 +public:
7177 +       /**
7178 +        * Gets the name
7179 +        * .
7180 +        * @param none
7181 +        * @return string containing the name
7182 +        **/
7183 +       const char* getName()
7184 +       {
7185 +               return m_sName.c_str();
7186 +       }
7187 +
7188 +       /**
7189 +        * Checks if we have a version
7190 +        * .
7191 +        * @param none
7192 +        * @return true if available, false otherwise
7193 +        **/
7194 +       bool hasVersion()
7195 +       {
7196 +               return m_sVersion.length() ? true : false;
7197 +       }
7198 +
7199 +       /**
7200 +        * Gets the version
7201 +        * .
7202 +        * @param none
7203 +        * @return string containing the version
7204 +        **/
7205 +       const char* getVersion()
7206 +       {
7207 +               return m_sVersion.c_str();
7208 +       }
7209 +
7210 +       /**
7211 +        * Gets the comparision string
7212 +        * .
7213 +        * @param none
7214 +        * @return string with the comparator (=, <, <=, >, >=, <>)
7215 +        **/
7216 +        const char* getCompare()
7217 +        {
7218 +               return m_sCmp.c_str();
7219 +        }
7220 +
7221 +//
7222 +// member variables
7223 +//
7224 +protected:
7225 +       string m_sName;
7226 +       string m_sVersion;
7227 +       string m_sCmp;
7228 +};
7229 +
7230 +//<requires,obsoletes,buildrequires,provides ...>
7231 +class XMLPackageContainer : public XMLBase
7232 +{
7233 +//
7234 +// factory functions
7235 +//
7236 +public:
7237 +       /**
7238 +        * Adds a require
7239 +        * .
7240 +        * @param pAttrs XML attributes
7241 +        * @param pSpecx pointer to the spec to add to
7242 +        * @return true on success, false otherwise
7243 +        **/
7244 +       static bool addRequire(XMLAttrs* pAttrs,
7245 +                                                  XMLSpec* pSpec);
7246 +
7247 +       /**
7248 +        * Adds a buildrequire
7249 +        * .
7250 +        * @param pAttrs XML attributes
7251 +        * @param pSpecx pointer to the spec to add to
7252 +        * @return true on success, false otherwise
7253 +        **/
7254 +       static bool addBuildRequire(XMLAttrs* pAttrs,
7255 +                                                               XMLSpec* pSpec);
7256 +
7257 +       /**
7258 +        * Adds a provide
7259 +        * .
7260 +        * @param pAttrs XML attributes
7261 +        * @param pSpecx pointer to the spec to add to
7262 +        * @return true on success, false otherwise
7263 +        **/
7264 +       static bool addProvide(XMLAttrs* pAttrs,
7265 +                                                  XMLSpec* pSpec);
7266 +
7267 +       /**
7268 +        * Adds an obsolete
7269 +        * .
7270 +        * @param pAttrs XML attributes
7271 +        * @param pSpecx pointer to the spec to add to
7272 +        * @return true on success, false otherwise
7273 +        **/
7274 +       static bool addObsolete(XMLAttrs* pAttrs,
7275 +                                                       XMLSpec* pSpec);
7276 +
7277 +       /**
7278 +        * Adds requires/provides/obsoletes from RPM structures
7279 +        * .
7280 +        * @param pPackage pointer to the RPM package
7281 +        * @param pSpec pointer to the RPM spec
7282 +        * @param pXSpec pointer to the XML spec to populate
7283 +        * @return true on success, false otherwise
7284 +        **/
7285 +       static bool structCreate(PackageStruct* pPackage,
7286 +                                                        Spec pSpec,
7287 +                                                        XMLSpec* pXSpec);
7288 +
7289 +//
7290 +// constructors/destructor
7291 +//
7292 +public:
7293 +       /**
7294 +        * Default constructor
7295 +        * .
7296 +        * @param none
7297 +        * @return none
7298 +        **/
7299 +       XMLPackageContainer();
7300 +
7301 +       /**
7302 +        * Copy constructor
7303 +        * .
7304 +        * @param rContainer The container to copy
7305 +        * @return none
7306 +        **/
7307 +        XMLPackageContainer(const XMLPackageContainer& rContainer);
7308 +
7309 +       /**
7310 +        * Destructor
7311 +        * .
7312 +        * @param none
7313 +        * @return none
7314 +        **/
7315 +       virtual ~XMLPackageContainer();
7316 +
7317 +//
7318 +// operators
7319 +//
7320 +public:
7321 +       /**
7322 +        * Assignment operator
7323 +        * .
7324 +        * @param container The container to copy
7325 +        * @return a copy of the object
7326 +        **/
7327 +       XMLPackageContainer operator=(XMLPackageContainer container);
7328 +
7329 +//
7330 +// member functions
7331 +//
7332 +public:
7333 +       /**
7334 +        * Converts the object into an RPM spec
7335 +        * .
7336 +        * @param rOut Output stream
7337 +        * @param szTag the tag for this object (eg. buildrequires)
7338 +        * @return none
7339 +        **/
7340 +       virtual void toSpecFile(ostream& rOut,
7341 +                                                       const char* szTag);
7342 +
7343 +       /**
7344 +        * Converts the object into an XML spec
7345 +        * .
7346 +        * @param rOut Output stream
7347 +        * @para szTag the tag for this object (eg. buildrequires)
7348 +        * @return none
7349 +        **/
7350 +       virtual void toXMLFile(ostream& rOut,
7351 +                                                  const char* szTag);
7352 +
7353 +//
7354 +// member variable get/set functions
7355 +//
7356 +public:
7357 +       /**
7358 +        * Gets the number of entries
7359 +        * .
7360 +        * @param none
7361 +        * @return the number of entries
7362 +        **/
7363 +       unsigned int numEntries()
7364 +       {
7365 +               return m_vPackages.size();
7366 +       }
7367 +
7368 +       /**
7369 +        * Gets a specific entry
7370 +        * .
7371 +        * @param nNum The number of the entry
7372 +        * @return reference to the entry
7373 +        **/
7374 +       XMLPackageEntry& getEntry(unsigned int nNum)
7375 +       {
7376 +               return m_vPackages[nNum];
7377 +       }
7378 +
7379 +       /**
7380 +        * Adds an entry
7381 +        * .
7382 +        * @param rPackage the entry to add
7383 +        * @return none
7384 +        **/
7385 +       void addEntry(XMLPackageEntry& rPackage)
7386 +       {
7387 +               m_vPackages.push_back(rPackage);
7388 +       }
7389 +
7390 +//
7391 +// member variables
7392 +//
7393 +protected:
7394 +       vector<XMLPackageEntry> m_vPackages;
7395 +};
7396 +
7397 +#endif
7398 Index: xmlspec/XMLScript.cpp
7399 ===================================================================
7400 RCS file: xmlspec/XMLScript.cpp
7401 diff -N xmlspec/XMLScript.cpp
7402 --- /dev/null   1 Jan 1970 00:00:00 -0000
7403 +++ rpm/xmlspec/XMLScript.cpp   28 Aug 2002 10:52:43 -0000      1.2.2.1
7404 @@ -0,0 +1,285 @@
7405 +// standard includes
7406 +#include <stdio.h>
7407 +
7408 +// our includes
7409 +#include "XMLPackage.h"
7410 +#include "XMLScript.h"
7411 +#include "XMLSpec.h"
7412 +
7413 +// attribute structure for XMLScript
7414 +structValidAttrs g_paScriptAttrs[] =
7415 +{
7416 +       {0x0000,    false, false, "dir",         XATTRTYPE_STRING, {"*", NULL}},
7417 +       {0x0001,    false, false, "interpreter", XATTRTYPE_STRING, {"*", NULL}},
7418 +       {XATTR_END, false, false, "end",         XATTRTYPE_NONE,   {NULL}}
7419 +};
7420 +
7421 +bool XMLScript::parseCreate(XMLAttrs* pAttrs,
7422 +                                                       const char* szScript,
7423 +                                                       XMLScripts& rContainer)
7424 +{
7425 +       if (!pAttrs->validate(g_paScriptAttrs, (XMLBase*)pAttrs))
7426 +               return false;
7427 +       XMLScript script(szScript,
7428 +                                        pAttrs->asString("interpreter"),
7429 +                                        pAttrs->asString("dir"));
7430 +       rContainer.add(script);
7431 +       return true;
7432 +}
7433 +
7434 +XMLScript::XMLScript(const char* szScript,
7435 +                                        const char* szInterpreter,
7436 +                                        const char* szDir)
7437 +       : XMLBase()
7438 +{
7439 +       if (szScript)
7440 +               m_sValue.assign(szScript);
7441 +       if (szInterpreter)
7442 +               m_sInterpreter.assign(szInterpreter);
7443 +       if (szDir)
7444 +               m_sDir.assign(szDir);
7445 +}
7446 +
7447 +XMLScript::XMLScript(const XMLScript& rScript)
7448 +       : XMLBase()
7449 +{
7450 +       m_sValue.assign(rScript.m_sValue);
7451 +       m_sInterpreter.assign(rScript.m_sInterpreter);
7452 +       m_sDir.assign(rScript.m_sDir);
7453 +}
7454 +
7455 +XMLScript::~XMLScript()
7456 +{
7457 +}
7458 +
7459 +XMLScript XMLScript::operator=(XMLScript script)
7460 +{
7461 +       m_sValue.assign(script.m_sValue);
7462 +       m_sInterpreter.assign(script.m_sInterpreter);
7463 +       m_sDir.assign(script.m_sDir);
7464 +}
7465 +
7466 +void XMLScript::toSpecFile(ostream& rOut)
7467 +{
7468 +       if (hasDirectory())
7469 +               rOut << "cd " << getDirectory() << endl;
7470 +       rOut << getValue() << endl;
7471 +}
7472 +
7473 +void XMLScript::toXMLFile(ostream& rOut,
7474 +                                                 const char* szIndent)
7475 +{
7476 +       rOut << endl << szIndent << "\t\t<script";
7477 +       if (hasDirectory())
7478 +               rOut << " dir=\"" << getDirectory() << "\"";
7479 +       rOut << ">" << getValue() << "</script>";
7480 +}
7481 +
7482 +void XMLScript::toRPMStruct(StringBuf* pSB)
7483 +{
7484 +       if (hasDirectory()) {
7485 +               char szBuff[getDirectoryLen()+3+1]; // 3 == strlen("cd ")
7486 +               sprintf(szBuff, "cd %s", getDirectory());
7487 +               appendStringBuf(*pSB, szBuff);
7488 +       }
7489 +       appendStringBuf(*pSB, getValue());
7490 +}
7491 +
7492 +bool XMLScripts::addPrepScript(XMLAttrs* pAttrs,
7493 +                                                          const char* szScript,
7494 +                                                          XMLSpec* pSpec)
7495 +{
7496 +       // no spec or already set
7497 +       if (!pSpec)
7498 +               return false;
7499 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->getPrep());
7500 +}
7501 +
7502 +bool XMLScripts::addBuildScript(XMLAttrs* pAttrs,
7503 +                                                               const char* szScript,
7504 +                                                               XMLSpec* pSpec)
7505 +{
7506 +       // no spec or already set
7507 +       if (!pSpec)
7508 +               return false;
7509 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->getBuild());
7510 +}
7511 +
7512 +bool XMLScripts::addInstallScript(XMLAttrs* pAttrs,
7513 +                                                                 const char* szScript,
7514 +                                                                 XMLSpec* pSpec)
7515 +{
7516 +       // no spec or already set
7517 +       if (!pSpec)
7518 +               return false;
7519 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->getInstall());
7520 +}
7521 +
7522 +bool XMLScripts::addCleanScript(XMLAttrs* pAttrs,
7523 +                                                               const char* szScript,
7524 +                                                               XMLSpec* pSpec)
7525 +{
7526 +       // no spec or already set
7527 +       if (!pSpec)
7528 +               return false;
7529 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->getClean());
7530 +}
7531 +
7532 +XMLScripts::XMLScripts()
7533 +       : XMLBase()
7534 +{
7535 +}
7536 +
7537 +XMLScripts::XMLScripts(const XMLScripts& rContainer)
7538 +       : XMLBase()
7539 +{
7540 +       m_vScripts = rContainer.m_vScripts;
7541 +}
7542 +
7543 +XMLScripts::~XMLScripts()
7544 +{
7545 +}
7546 +
7547 +void XMLScripts::toSpecFile(ostream& rOut,
7548 +                                                       const char* szTag)
7549 +{
7550 +       if (numScripts()) {
7551 +               rOut << endl << "%" << szTag << endl;
7552 +               for (unsigned int i = 0; i < numScripts(); i++)
7553 +                       getScript(i).toSpecFile(rOut);
7554 +       }
7555 +}
7556 +
7557 +void XMLScripts::toXMLFile(ostream& rOut,
7558 +                                                  const char* szTag)
7559 +{
7560 +       if (numScripts()) {
7561 +               rOut << endl << "\t<" << szTag << ">";
7562 +               for (unsigned int i = 0; i < numScripts(); i++)
7563 +                       getScript(i).toXMLFile(rOut, "");
7564 +               rOut << endl << "\t</" << szTag << ">";
7565 +       }
7566 +}
7567 +
7568 +bool XMLPackageScripts::addPreScript(XMLAttrs* pAttrs,
7569 +                                                                        const char* szScript,
7570 +                                                                        XMLSpec* pSpec)
7571 +{
7572 +       if (!pSpec)
7573 +               return false;
7574 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPre());
7575 +}
7576 +
7577 +bool XMLPackageScripts::addPostScript(XMLAttrs* pAttrs,
7578 +                                                                         const char* szScript,
7579 +                                                                         XMLSpec* pSpec)
7580 +{
7581 +       if (!pSpec)
7582 +               return false;
7583 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPost());
7584 +}
7585 +
7586 +bool XMLPackageScripts::addPreUnScript(XMLAttrs* pAttrs,
7587 +                                                                          const char* szScript,
7588 +                                                                          XMLSpec* pSpec)
7589 +{
7590 +       if (!pSpec)
7591 +               return false;
7592 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPreUn());
7593 +}
7594 +
7595 +bool XMLPackageScripts::addPostUnScript(XMLAttrs* pAttrs,
7596 +                                                                               const char* szScript,
7597 +                                                                               XMLSpec* pSpec)
7598 +{
7599 +       if (!pSpec)
7600 +               return false;
7601 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getPostUn());
7602 +}
7603 +
7604 +bool XMLPackageScripts::addVerifyScript(XMLAttrs* pAttrs,
7605 +                                                                               const char* szScript,
7606 +                                                                               XMLSpec* pSpec)
7607 +{
7608 +       if (!pSpec)
7609 +               return false;
7610 +       return XMLScript::parseCreate(pAttrs, szScript, pSpec->lastPackage().getVerify());
7611 +}
7612 +
7613 +bool XMLPackageScripts::createPreScripts(XMLAttrs* pAttrs,
7614 +                                                                                XMLSpec* pSpec)
7615 +{
7616 +       if (!pSpec)
7617 +               return false;
7618 +       pSpec->lastPackage().getPre().setInterpreter(pAttrs->asString("interpreter"));
7619 +       return true;
7620 +}
7621 +
7622 +bool XMLPackageScripts::createPostScripts(XMLAttrs* pAttrs,
7623 +                                                                                 XMLSpec* pSpec)
7624 +{
7625 +       if (!pSpec)
7626 +               return false;
7627 +       pSpec->lastPackage().getPost().setInterpreter(pAttrs->asString("interpreter"));
7628 +       return true;
7629 +}
7630 +
7631 +bool XMLPackageScripts::createPreUnScripts(XMLAttrs* pAttrs,
7632 +                                                                                  XMLSpec* pSpec)
7633 +{
7634 +       if (!pSpec)
7635 +               return false;
7636 +       pSpec->lastPackage().getPreUn().setInterpreter(pAttrs->asString("interpreter"));
7637 +       return true;
7638 +}
7639 +
7640 +bool XMLPackageScripts::createPostUnScripts(XMLAttrs* pAttrs,
7641 +                                                                                       XMLSpec* pSpec)
7642 +{
7643 +       if (!pSpec)
7644 +               return false;
7645 +       pSpec->lastPackage().getPostUn().setInterpreter(pAttrs->asString("interpreter"));
7646 +       return true;
7647 +}
7648 +
7649 +bool XMLPackageScripts::createVerifyScripts(XMLAttrs* pAttrs,
7650 +                                                                                       XMLSpec* pSpec)
7651 +{
7652 +       if (!pSpec)
7653 +               return false;
7654 +       pSpec->lastPackage().getVerify().setInterpreter(pAttrs->asString("interpreter"));
7655 +       return true;
7656 +}
7657 +
7658 +XMLPackageScripts::XMLPackageScripts()
7659 +       : XMLScripts()
7660 +{
7661 +}
7662 +
7663 +XMLPackageScripts::XMLPackageScripts(const XMLPackageScripts& rContainer)
7664 +       : XMLScripts(rContainer)
7665 +{
7666 +}
7667 +
7668 +XMLPackageScripts::~XMLPackageScripts()
7669 +{
7670 +}
7671 +
7672 +void XMLPackageScripts::toSpecFile(ostream& rOut,
7673 +                                                                  const char* szTag)
7674 +{
7675 +       // NOTE: header not done here, but by "package"
7676 +       for (unsigned int i = 0; i < numScripts(); i++)
7677 +               getScript(i).toSpecFile(rOut);
7678 +}
7679 +
7680 +void XMLPackageScripts::toXMLFile(ostream& rOut,
7681 +                                                                 const char* szTag)
7682 +{
7683 +       if (numScripts()) {
7684 +               rOut << endl << "\t\t<" << szTag << ">";
7685 +               for (unsigned int i = 0; i < numScripts(); i++)
7686 +                       getScript(i).toXMLFile(rOut, "\t");
7687 +               rOut << endl << "\t\t</" << szTag << ">";
7688 +       }
7689 +}
7690 Index: xmlspec/XMLScript.h
7691 ===================================================================
7692 RCS file: xmlspec/XMLScript.h
7693 diff -N xmlspec/XMLScript.h
7694 --- /dev/null   1 Jan 1970 00:00:00 -0000
7695 +++ rpm/xmlspec/XMLScript.h     28 Aug 2002 10:52:43 -0000      1.2.2.1
7696 @@ -0,0 +1,519 @@
7697 +#ifndef _H_XMLSCRIPT_
7698 +#define _H_XMLSCRIPT_
7699 +
7700 +// standard C++ includes
7701 +#include <iostream>
7702 +#include <string>
7703 +#include <vector>
7704 +
7705 +// our includes
7706 +#include "XMLAttrs.h"
7707 +#include "XMLBase.h"
7708 +
7709 +// rpm includes
7710 +#include <rpmbuild.h>
7711 +
7712 +// forward definitions
7713 +class XMLPackage;
7714 +class XMLSpec;
7715 +class XMLScripts;
7716 +
7717 +using namespace std;
7718 +
7719 +class XMLScript : public XMLBase
7720 +{
7721 +//
7722 +// factory methods
7723 +//
7724 +public:
7725 +       /**
7726 +        * Creates a script object and adds it to the container
7727 +        * .
7728 +        * @param pAttrs The XML attributes
7729 +        * @param szScript The script value
7730 +        * @param rContainer reference to the script container to add to
7731 +        * @return true on success, false otherwise
7732 +        **/
7733 +        static bool parseCreate(XMLAttrs* pAttrs,
7734 +                                                        const char* szScript,
7735 +                                                        XMLScripts& rContainer);
7736 +
7737 +//
7738 +// constructors/destructor
7739 +//
7740 +public:
7741 +       /**
7742 +        * Default constructor
7743 +        * .
7744 +        * @param szScript The script
7745 +        * @param szInterpreter The interpreter to use for script execution
7746 +        * @param szDir Directory to execute the script in
7747 +        * @return none
7748 +        **/
7749 +        XMLScript(const char* szScript,
7750 +                          const char* szInterpreter,
7751 +                          const char* szDir);
7752 +
7753 +       /**
7754 +        * Copy constructor
7755 +        * .
7756 +        * @param rScript Script to copy
7757 +        * @return none
7758 +        **/
7759 +        XMLScript(const XMLScript& rScript);
7760 +
7761 +        /**
7762 +         * Destructor
7763 +         * .
7764 +         * @param none
7765 +         * @return none
7766 +         **/
7767 +         virtual ~XMLScript();
7768 +
7769 +//
7770 +// operators
7771 +//
7772 +public:
7773 +       /**
7774 +        * Assignment operator
7775 +        * .
7776 +        * @param script the script to copy
7777 +        * @return the copied object
7778 +        **/
7779 +        XMLScript operator=(XMLScript script);
7780 +
7781 +//
7782 +// member functions
7783 +//
7784 +public:
7785 +       /**
7786 +        * Converts the object into an RPM spec file
7787 +        * .
7788 +        * @param rOut Output stream
7789 +        * @return none
7790 +        **/
7791 +       void toSpecFile(ostream& rOut);
7792 +
7793 +       /**
7794 +        * Converts the object into an XML spec
7795 +        * .
7796 +        * @param rOut Output stream
7797 +        * @param szIndent Indent string
7798 +        * @return none
7799 +        **/
7800 +       void toXMLFile(ostream& rOut,
7801 +                                  const char* szIndent = "");
7802 +
7803 +       /**
7804 +        * Converts the object into an RPM structure
7805 +        * .
7806 +        * @param pSB Pointer to the string buffer
7807 +        * @return none
7808 +        **/
7809 +       virtual void toRPMStruct(StringBuf* pSB);
7810 +
7811 +//
7812 +// member variable get/set functions
7813 +//
7814 +public:
7815 +       /**
7816 +        * Gets the script value
7817 +        * .
7818 +        * @param none
7819 +        * @return string containing the script
7820 +        **/
7821 +        const char* getValue()
7822 +        {
7823 +               return m_sValue.c_str();
7824 +        }
7825 +
7826 +       /**
7827 +        * Checks if we have an interpreter
7828 +        * .
7829 +        * @param none
7830 +        * @return true if we have an interpreter, false otherwise
7831 +        **/
7832 +       bool hasInterpreter()
7833 +       {
7834 +               return m_sInterpreter.length() ? true : false;
7835 +       }
7836 +
7837 +       /**
7838 +        * Gets the interpreter
7839 +        * .
7840 +        * @param none
7841 +        * @return string contating the interpreter
7842 +        **/
7843 +       const char* getInterpreter()
7844 +       {
7845 +               return m_sInterpreter.c_str();
7846 +       }
7847 +
7848 +       /**
7849 +        * Checks if we have a direcory
7850 +        * .
7851 +        * @param none
7852 +        * @return true if we have a directory, false otherwise
7853 +        **/
7854 +       bool hasDirectory()
7855 +       {
7856 +               return m_sDir.length() ? true : false;
7857 +       }
7858 +
7859 +       /**
7860 +        * Gets the directory
7861 +        * .
7862 +        * @param none
7863 +        * @return string contating the directory
7864 +        **/
7865 +       const char* getDirectory()
7866 +       {
7867 +               return m_sDir.c_str();
7868 +       }
7869 +
7870 +       /**
7871 +        * Gets the length of the directory string
7872 +        * .
7873 +        * @param none
7874 +        * @return length of the description string
7875 +        **/
7876 +        unsigned int getDirectoryLen()
7877 +        {
7878 +               return m_sDir.length();
7879 +        }
7880 +
7881 +//
7882 +// member variables
7883 +//
7884 +public:
7885 +       string m_sValue;
7886 +       string m_sInterpreter;
7887 +       string m_sDir;
7888 +};
7889 +
7890 +//<prep,build,install,clean ...>
7891 +class XMLScripts : public XMLBase
7892 +{
7893 +//
7894 +// factory functions
7895 +//
7896 +public:
7897 +       static bool addPrepScript(XMLAttrs* pAttrs,
7898 +                                                         const char* szScript,
7899 +                                                         XMLSpec* pSpec);
7900 +
7901 +       static bool addBuildScript(XMLAttrs* pAttrs,
7902 +                                                          const char* szScript,
7903 +                                                          XMLSpec* pSpec);
7904 +
7905 +       static bool addInstallScript(XMLAttrs* pAttrs,
7906 +                                                                const char* szScript,
7907 +                                                                XMLSpec* pSpec);
7908 +
7909 +       static bool addCleanScript(XMLAttrs* pAttrs,
7910 +                                                          const char* szScript,
7911 +                                                          XMLSpec* pSpec);
7912 +
7913 +//
7914 +// constructors/destructor
7915 +//
7916 +public:
7917 +       /**
7918 +        * Default constructor
7919 +        * .
7920 +        * @param none
7921 +        * @return none
7922 +        **/
7923 +       XMLScripts();
7924 +
7925 +       /**
7926 +        * Copy constructor
7927 +        * .
7928 +        * @param rContainer the object to copy
7929 +        * @return none
7930 +        **/
7931 +        XMLScripts(const XMLScripts& rContainer);
7932 +
7933 +       /**
7934 +        * Destructor
7935 +        * .
7936 +        * @param none
7937 +        * @return none
7938 +        **/
7939 +       virtual ~XMLScripts();
7940 +
7941 +//
7942 +// member functions
7943 +//
7944 +public:
7945 +       /**
7946 +        * Converts the object into an RPM spec file
7947 +        * .
7948 +        * @param rOut Output stream
7949 +        * @param szTag The tag name
7950 +        * @return none
7951 +        **/
7952 +       virtual void toSpecFile(ostream& rOut,
7953 +                                                       const char* szTag);
7954 +
7955 +       /**
7956 +        * Converts the object into an XML spec
7957 +        * .
7958 +        * @param rOut Output stream
7959 +        * @param szTag The tag name
7960 +        * @return none
7961 +        **/
7962 +       void toXMLFile(ostream& rOut,
7963 +                                  const char* szTag);
7964 +
7965 +//
7966 +// member variable get/set functions
7967 +//
7968 +public:
7969 +       /**
7970 +        * Checks if we have an interpreter
7971 +        * .
7972 +        * @param none
7973 +        * @return true if we have an interpreter, false otherwise
7974 +        **/
7975 +       bool hasInterpreter()
7976 +       {
7977 +               return m_sInterpreter.length() ? true : false;
7978 +       }
7979 +
7980 +       /**
7981 +        * Gets the interpreter
7982 +        * .
7983 +        * @param none
7984 +        * @return string contatining the interpreter
7985 +        **/
7986 +       const char* getInterpreter()
7987 +       {
7988 +               return m_sInterpreter.c_str();
7989 +       }
7990 +
7991 +       /**
7992 +        * Sets the script interpreter
7993 +        * .
7994 +        * @param szInterpreter The interpreter
7995 +        * @return none
7996 +        **/
7997 +       void setInterpreter(const char* szInterpreter)
7998 +       {
7999 +               if (szInterpreter)
8000 +                       m_sInterpreter.assign(szInterpreter);
8001 +       }
8002 +
8003 +       /**
8004 +        * Gets the number of script entries
8005 +        * .
8006 +        * @param none
8007 +        * @return the number of scripts
8008 +        **/
8009 +       unsigned int numScripts()
8010 +       {
8011 +               return m_vScripts.size();
8012 +       }
8013 +
8014 +       /**
8015 +        * Gets a specific script entry
8016 +        * .
8017 +        * @param nNum The entry number
8018 +        * @return Reference to the script entry
8019 +        **/
8020 +       XMLScript& getScript(unsigned int nNum)
8021 +       {
8022 +               return m_vScripts[nNum];
8023 +       }
8024 +
8025 +       /**
8026 +        * Adds an script entry
8027 +        * .
8028 +        * @param szScript the script to add
8029 +        * @return none
8030 +        **/
8031 +       void add(XMLScript& rScript)
8032 +       {
8033 +               m_vScripts.push_back(rScript);
8034 +       }
8035 +
8036 +//
8037 +// member variables
8038 +//
8039 +protected:
8040 +       string            m_sInterpreter;
8041 +       vector<XMLScript> m_vScripts;
8042 +};
8043 +
8044 +//<post, postun, ...>
8045 +class XMLPackageScripts : public XMLScripts
8046 +{
8047 +//
8048 +// factory functions
8049 +//
8050 +public:
8051 +       /**
8052 +        * Adds a pre script
8053 +        * .
8054 +        * @param pAttrs The XML attributes
8055 +        * @param szScript The script to add
8056 +        * @param pSpec The spec to which we are adding
8057 +        * @return true on success, false otherwise
8058 +        **/
8059 +       static bool addPreScript(XMLAttrs* pAttrs,
8060 +                                                        const char* szScript,
8061 +                                                        XMLSpec* pSpec);
8062 +
8063 +       /**
8064 +        * Adds a post script
8065 +        * .
8066 +        * @param pAttrs The XML attributes
8067 +        * @param szScript The script to add
8068 +        * @param pSpec The spec to which we are adding
8069 +        * @return true on success, false otherwise
8070 +        **/
8071 +       static bool addPostScript(XMLAttrs* pAttrs,
8072 +                                                         const char* szScript,
8073 +                                                         XMLSpec* pSpec);
8074 +
8075 +       /**
8076 +        * Adds a preun script
8077 +        * .
8078 +        * @param pAttrs The XML attributes
8079 +        * @param szScript The script to add
8080 +        * @param pSpec The spec to which we are adding
8081 +        * @return true on success, false otherwise
8082 +        **/
8083 +       static bool addPreUnScript(XMLAttrs* pAttrs,
8084 +                                                          const char* szScript,
8085 +                                                          XMLSpec* pSpec);
8086 +
8087 +       /**
8088 +        * Adds a postun script
8089 +        * .
8090 +        * @param pAttrs The XML attributes
8091 +        * @param szScript The script to add
8092 +        * @param pSpec The spec to which we are adding
8093 +        * @return true on success, false otherwise
8094 +        **/
8095 +       static bool addPostUnScript(XMLAttrs* pAttrs,
8096 +                                                               const char* szScript,
8097 +                                                               XMLSpec* pSpec);
8098 +
8099 +       /**
8100 +        * Adds a verify script
8101 +        * .
8102 +        * @param pAttrs The XML attributes
8103 +        * @param szScript The script to add
8104 +        * @param pSpec The spec to which we are adding
8105 +        * @return true on success, false otherwise
8106 +        **/
8107 +       static bool addVerifyScript(XMLAttrs* pAttrs,
8108 +                                                               const char* szScript,
8109 +                                                               XMLSpec* pSpec);
8110 +
8111 +       /**
8112 +        * Initialises a pre script container
8113 +        * .
8114 +        * @param pAttrs The XML attributes
8115 +        * @param pSpec The spec to which we are adding
8116 +        * @return true on success, false otherwise
8117 +        **/
8118 +       static bool createPreScripts(XMLAttrs* pAttrs,
8119 +                                                                XMLSpec* pSpec);
8120 +
8121 +       /**
8122 +        * Initialises a post script container
8123 +        * .
8124 +        * @param pAttrs The XML attributes
8125 +        * @param pSpec The spec to which we are adding
8126 +        * @return true on success, false otherwise
8127 +        **/
8128 +       static bool createPostScripts(XMLAttrs* pAttrs,
8129 +                                                                 XMLSpec* pSpec);
8130 +
8131 +       /**
8132 +        * Initialises a preun script container
8133 +        * .
8134 +        * @param pAttrs The XML attributes
8135 +        * @param pSpec The spec to which we are adding
8136 +        * @return true on success, false otherwise
8137 +        **/
8138 +       static bool createPreUnScripts(XMLAttrs* pAttrs,
8139 +                                                                  XMLSpec* pSpec);
8140 +
8141 +       /**
8142 +        * Initialises a postun script container
8143 +        * .
8144 +        * @param pAttrs The XML attributes
8145 +        * @param pSpec The spec to which we are adding
8146 +        * @return true on success, false otherwise
8147 +        **/
8148 +       static bool createPostUnScripts(XMLAttrs* pAttrs,
8149 +                                                                       XMLSpec* pSpec);
8150 +
8151 +       /**
8152 +        * Initialises a verify script container
8153 +        * .
8154 +        * @param pAttrs The XML attributes
8155 +        * @param pSpec The spec to which we are adding
8156 +        * @return true on success, false otherwise
8157 +        **/
8158 +       static bool createVerifyScripts(XMLAttrs* pAttrs,
8159 +                                                                       XMLSpec* pSpec);
8160 +
8161 +//
8162 +// constructors/destructors
8163 +//
8164 +public:
8165 +       /**
8166 +        * Default constructor
8167 +        * .
8168 +        * @param none
8169 +        * @return none
8170 +        **/
8171 +       XMLPackageScripts();
8172 +
8173 +       /**
8174 +        * Copy constructor
8175 +        * .
8176 +        * @param rScripts Reference to the object to copy
8177 +        * @return none
8178 +        **/
8179 +       XMLPackageScripts(const XMLPackageScripts& rScripts);
8180 +
8181 +       /**
8182 +        * Destructor
8183 +        * .
8184 +        * @param none
8185 +        * @return none
8186 +        **/
8187 +       ~XMLPackageScripts();
8188 +
8189 +//
8190 +// member functions
8191 +//
8192 +public:
8193 +       /**
8194 +        * Converts the object into an RPM spec
8195 +        * .
8196 +        * @param rOut Output stream
8197 +        * @param szTag The tag name
8198 +        * @return none
8199 +        **/
8200 +       virtual void toSpecFile(ostream& rOut,
8201 +                                                       const char* szTag);
8202 +
8203 +       /**
8204 +        * Converts the object into an XML spec
8205 +        * .
8206 +        * @param rOut Output stream
8207 +        * @param szTag The tag name
8208 +        * @return none
8209 +        **/
8210 +       virtual void toXMLFile(ostream& rOut,
8211 +                                                  const char* szTag);
8212 +
8213 +};
8214 +
8215 +#endif
8216 Index: xmlspec/XMLSource.cpp
8217 ===================================================================
8218 RCS file: xmlspec/XMLSource.cpp
8219 diff -N xmlspec/XMLSource.cpp
8220 --- /dev/null   1 Jan 1970 00:00:00 -0000
8221 +++ rpm/xmlspec/XMLSource.cpp   28 Aug 2002 10:52:43 -0000      1.2.2.1
8222 @@ -0,0 +1,339 @@
8223 +// standard includes
8224 +#include <stdio.h>
8225 +
8226 +// our includes
8227 +#include "XMLSource.h"
8228 +#include "XMLSpec.h"
8229 +
8230 +// rpm includes
8231 +#include <rpmspec.h>
8232 +
8233 +using namespace std;
8234 +
8235 +bool XMLSource::structCreate(Source* pSource,
8236 +                                                        Spec pSpec,
8237 +                                                        XMLSpec* pXSpec)
8238 +{
8239 +       if (!pXSpec || !pSpec || !pSource)
8240 +               return false;
8241 +
8242 +       // create our mirror
8243 +       XMLMirror *pMirror = NULL;
8244 +       if (pSource->source != pSource->fullSource) {
8245 +               unsigned int nLen = pSource->source-pSource->fullSource;
8246 +               char szPath[nLen+1];
8247 +               strncpy(szPath, pSource->fullSource, nLen);
8248 +               szPath[nLen] = '\0';
8249 +               pMirror = new XMLMirror(szPath, NULL, NULL);
8250 +       }
8251 +
8252 +       // generate the source, nosource, patch
8253 +       XMLSource* pXSource = NULL;
8254 +       XMLNoSource* pXNoSource = NULL;
8255 +       XMLPatch* pXPatch = NULL;
8256 +       switch (pSource->flags) {
8257 +               case RPMBUILD_ISSOURCE:
8258 +                       pXSource = new XMLSource(pSource->source, pSource->num,
8259 +                                                                        NULL, NULL, NULL);
8260 +                       pXSpec->addSource(*pXSource);
8261 +                       if (pMirror)
8262 +                               pXSpec->lastSource().addMirror(*pMirror);
8263 +                       delete pXSource;
8264 +                       break;
8265 +               case RPMBUILD_ISNO:
8266 +                       pXNoSource = new XMLNoSource(pSource->source, pSource->num,
8267 +                                                                                NULL, NULL, NULL);
8268 +                       pXSpec->addNoSource(*pXNoSource);
8269 +                       if (pMirror)
8270 +                               pXSpec->lastNoSource().addMirror(*pMirror);
8271 +                       delete pXNoSource;
8272 +                       break;
8273 +               case RPMBUILD_ISPATCH:
8274 +                       pXPatch = new XMLPatch(pSource->source, pSource->num, NULL, NULL);
8275 +                       pXSpec->addPatch(*pXPatch);
8276 +                       if (pMirror)
8277 +                               pXSpec->lastPatch().addMirror(*pMirror);
8278 +                       delete pXPatch;
8279 +                       break;
8280 +               default:
8281 +                       break;
8282 +       }
8283 +       if (pMirror)
8284 +               delete pMirror;
8285 +
8286 +       // do the next source and return
8287 +       XMLSource::structCreate(pSource->next, pSpec, pXSpec);
8288 +       return true;
8289 +}
8290 +
8291 +// attribute structure for XMLSource
8292 +structValidAttrs g_paSourceAttrs[] =
8293 +{
8294 +       {0x0000,    true,  false, "name", XATTRTYPE_STRING,  {"*", NULL}},
8295 +       {0x0001,    false, false, "num",  XATTRTYPE_INTEGER, {NULL}},
8296 +       {0x0002,    false, false, "dir",  XATTRTYPE_STRING,  {"*", NULL}},
8297 +       {0x0003,    false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8298 +       {0x0004,    false, false, "md5",  XATTRTYPE_STRING,  {"*", NULL}},
8299 +       {XATTR_END, false, false, "end",  XATTRTYPE_NONE,    {NULL}}
8300 +};
8301 +
8302 +bool XMLSource::parseCreate(XMLAttrs* pAttrs,
8303 +                                                       XMLSpec* pSpec)
8304 +{
8305 +       // validate the attributes
8306 +       if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8307 +               return false;
8308 +
8309 +       XMLSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8310 +                                        pAttrs->asString("dir"), pAttrs->asString("size"),
8311 +                                        pAttrs->asString("md5"));
8312 +       pSpec->addSource(source);
8313 +
8314 +       return true;
8315 +}
8316 +
8317 +XMLSource::XMLSource(const char* szName,
8318 +                                        unsigned int nNum,
8319 +                                        const char* szDir,
8320 +                                        const char* szSize,
8321 +                                        const char* szMD5)
8322 +       : XMLBase()
8323 +{
8324 +       if (szName)
8325 +               m_sName.assign(szName);
8326 +       m_nNum = nNum;
8327 +       if (szDir)
8328 +               m_sDir.assign(szDir);
8329 +       if (szSize)
8330 +               m_sSize.assign(szSize);
8331 +       if (szMD5)
8332 +               m_sMD5.assign(szMD5);
8333 +}
8334 +
8335 +XMLSource::XMLSource(const XMLSource& rSource)
8336 +       : XMLBase()
8337 +{
8338 +       m_sName.assign(rSource.m_sName);
8339 +       m_nNum = rSource.m_nNum;
8340 +       m_sDir.assign(rSource.m_sDir);
8341 +       m_sSize.assign(rSource.m_sSize);
8342 +       m_sMD5.assign(rSource.m_sMD5);
8343 +       m_vMirrors = rSource.m_vMirrors;
8344 +}
8345 +
8346 +XMLSource::~XMLSource()
8347 +{
8348 +}
8349 +
8350 +XMLSource XMLSource::operator=(XMLSource source)
8351 +{
8352 +       m_sName.assign(source.m_sName);
8353 +       m_nNum = source.m_nNum;
8354 +       m_sDir.assign(source.m_sDir);
8355 +       m_sSize.assign(source.m_sSize);
8356 +       m_sMD5.assign(source.m_sMD5);
8357 +       m_vMirrors = source.m_vMirrors;
8358 +       return *this;
8359 +}
8360 +
8361 +void XMLSource::toSpecFile(ostream& rOut)
8362 +{
8363 +       for (unsigned int i = 0; i < numMirrors(); i++)
8364 +               getMirror(i).toSpecFile(rOut);
8365 +
8366 +       rOut << endl << "source";
8367 +       rOut << getNum();
8368 +       rOut << ":        ";
8369 +       if (numMirrors())
8370 +               rOut << getMirror(0).getPath();
8371 +       rOut << getName();
8372 +}
8373 +
8374 +void XMLSource::toXMLFile(ostream& rOut)
8375 +{
8376 +       rOut << endl << "\t<source name=\"" << getName() << "\"";
8377 +       rOut << endl << "\t        num=\"";
8378 +       rOut << getNum();
8379 +       rOut << "\"";
8380 +       if (hasSize())
8381 +               rOut << endl << "\t        size=\"" << getSize() << "\"";
8382 +       if (hasMD5())
8383 +               rOut << endl << "\t        md5=\"" << getMD5() << "\"";
8384 +       if (hasDir())
8385 +               rOut << endl << "\t        dir=\"" << getDir() << "\"";
8386 +       rOut << ">";
8387 +
8388 +       for (unsigned int i = 0; i < numMirrors(); i++)
8389 +               getMirror(i).toXMLFile(rOut);
8390 +
8391 +       rOut << endl << "\t</source>";
8392 +}
8393 +
8394 +void XMLSource::toRPMStruct(Spec pRPMSpec)
8395 +{
8396 +       /*Source* pCurr = new Source;
8397 +       unsigned int nNameLen = strlen(getName());
8398 +       unsigned int nMirrorLen = 0;
8399 +       if (pPrev)
8400 +               pPrev->next = pCurr;
8401 +       pCurr->next = NULL;
8402 +       if (numMirrors())
8403 +               nMirrorlen = strlen(getMirror(0).getPath());
8404 +       pCurr->fullSource = new char[nNamelen+nMirrorLen+1];
8405 +       pCurr->fullSources[0] = '\0';
8406 +       if (numMirrors())
8407 +               strcpy(pCurr->fullSource, getMirror(0).getPath());
8408 +       strcat(pCurr->fullSource, getName());
8409 +       pCurr->source = pCurr->fullSource+nMirrorLen;
8410 +       pCurr->num = getNum();
8411 +       pCurr->flags = RPMBUILD_ISSOURCE;
8412 +       return pCurr;*/
8413 +}
8414 +
8415 +bool XMLNoSource::parseCreate(XMLAttrs* pAttrs,
8416 +                                                       XMLSpec* pSpec)
8417 +{
8418 +       // validate the attributes
8419 +       if (!pAttrs->validate(g_paSourceAttrs, (XMLBase*)pSpec))
8420 +               return false;
8421 +
8422 +       XMLNoSource source(pAttrs->asString("name"), pAttrs->asInteger("num"),
8423 +                                          pAttrs->asString("dir"), pAttrs->asString("size"),
8424 +                                          pAttrs->asString("md5"));
8425 +       pSpec->addNoSource(source);
8426 +       return true;
8427 +}
8428 +
8429 +XMLNoSource::XMLNoSource(const char* szName,
8430 +                                                unsigned int nNum,
8431 +                                                const char* szDir,
8432 +                                                const char* szSize,
8433 +                                                const char* szMD5)
8434 +       : XMLSource(szName,
8435 +                               nNum,
8436 +                               szDir,
8437 +                               szSize,
8438 +                               szMD5)
8439 +{
8440 +}
8441 +
8442 +XMLNoSource::XMLNoSource(const XMLNoSource& rNoSource)
8443 +       : XMLSource(rNoSource.m_sName.c_str(),
8444 +                               rNoSource.m_nNum,
8445 +                               rNoSource.m_sDir.c_str(),
8446 +                               rNoSource.m_sSize.c_str(),
8447 +                               rNoSource.m_sMD5.c_str())
8448 +{
8449 +}
8450 +
8451 +XMLNoSource::~XMLNoSource()
8452 +{
8453 +}
8454 +
8455 +void XMLNoSource::toSpecFile(ostream& rOut)
8456 +{
8457 +       for (unsigned int i = 0; i < numMirrors(); i++)
8458 +               getMirror(i).toSpecFile(rOut);
8459 +
8460 +       rOut << endl << "nosource";
8461 +       rOut << getNum();
8462 +       rOut << ":      " << getName();
8463 +}
8464 +
8465 +void XMLNoSource::toXMLFile(ostream& rOut)
8466 +{
8467 +       for (unsigned int i = 0; i < numMirrors(); i++)
8468 +               getMirror(i).toXMLFile(rOut);
8469 +}
8470 +
8471 +void XMLNoSource::toRPMStruct(Spec pRPMSpec)
8472 +{
8473 +       //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8474 +       //pCurr->flags = RPMBUILD_ISNO;
8475 +       //return pCurr;
8476 +}
8477 +
8478 +// attribute structure for XMLPatch
8479 +structValidAttrs g_paPatchAttrs[] =
8480 +{
8481 +       {0x0000,    true,  false, "name", XATTRTYPE_STRING,  {"*", NULL}},
8482 +       {0x0001,    false, false, "num",  XATTRTYPE_INTEGER, {NULL}},
8483 +       {0x0002,    false, false, "size", XATTRTYPE_INTEGER, {NULL}},
8484 +       {0x0003,    false, false, "md5",  XATTRTYPE_STRING,  {"*", NULL}},
8485 +       {XATTR_END, false, false, "end",  XATTRTYPE_NONE,    {NULL}}
8486 +};
8487 +
8488 +bool XMLPatch::parseCreate(XMLAttrs* pAttrs,
8489 +                                                  XMLSpec* pSpec)
8490 +{
8491 +       // validate the attributes
8492 +       if (!pAttrs->validate(g_paPatchAttrs, (XMLBase*)pSpec))
8493 +               return false;
8494 +
8495 +       XMLPatch patch(pAttrs->asString("name"), pAttrs->asInteger("num"),
8496 +                                  pAttrs->asString("size"), pAttrs->asString("md5"));
8497 +       pSpec->addPatch(patch);
8498 +       return true;
8499 +}
8500 +
8501 +XMLPatch::XMLPatch(const char* szName,
8502 +                                  unsigned int nNum,
8503 +                                  const char* szSize,
8504 +                                  const char* szMD5)
8505 +       : XMLSource(szName,
8506 +                               nNum,
8507 +                               NULL,
8508 +                               szSize,
8509 +                               szMD5)
8510 +{
8511 +}
8512 +
8513 +XMLPatch::XMLPatch(const XMLPatch& rPatch)
8514 +       : XMLSource(rPatch.m_sName.c_str(),
8515 +                               rPatch.m_nNum,
8516 +                               NULL,
8517 +                               rPatch.m_sSize.c_str(),
8518 +                               rPatch.m_sMD5.c_str())
8519 +{
8520 +}
8521 +
8522 +XMLPatch::~XMLPatch()
8523 +{
8524 +}
8525 +
8526 +void XMLPatch::toSpecFile(ostream& rOut)
8527 +{
8528 +       for (unsigned int i = 0; i < numMirrors(); i++)
8529 +               getMirror(i).toSpecFile(rOut);
8530 +       rOut << endl << "patch";
8531 +       rOut << getNum();
8532 +       rOut << ":         " << getName();
8533 +}
8534 +
8535 +void XMLPatch::toXMLFile(ostream& rOut)
8536 +{
8537 +       rOut << endl << "\t<patch name=\"" << getName() << "\"";
8538 +       rOut << endl << "\t       num=\"";
8539 +       rOut << getNum();
8540 +       rOut << "\"";
8541 +       if (hasSize())
8542 +               rOut << endl << "\t       size=\"" << getSize() << "\"";
8543 +       if (hasMD5())
8544 +               rOut << endl << "\t       md5=\"" << getMD5() << "\"";
8545 +       if (hasDir())
8546 +               rOut << endl << "\t       dir=\"" << getDir() << "\"";
8547 +       rOut << ">";
8548 +
8549 +       for (unsigned int i = 0; i < numMirrors(); i++)
8550 +               getMirror(i).toXMLFile(rOut);
8551 +
8552 +       rOut << endl << "\t</patch>";
8553 +}
8554 +
8555 +void XMLPatch::toRPMStruct(Spec pRPMSpec)
8556 +{
8557 +
8558 +       //Source* pCurr = XMLSource::toRPMStruct(pPrev);
8559 +       //pCurr->flags = RPMBUILD_ISPATCH;
8560 +       //return pCurr;
8561 +}
8562 Index: xmlspec/XMLSource.h
8563 ===================================================================
8564 RCS file: xmlspec/XMLSource.h
8565 diff -N xmlspec/XMLSource.h
8566 --- /dev/null   1 Jan 1970 00:00:00 -0000
8567 +++ rpm/xmlspec/XMLSource.h     28 Aug 2002 10:52:43 -0000      1.2.2.1
8568 @@ -0,0 +1,454 @@
8569 +#ifndef _H_XMLSOURCE_
8570 +#define _H_XMLSOURCE_
8571 +
8572 +// standard C++ includes
8573 +#include <string>
8574 +#include <vector>
8575 +#include <iostream>
8576 +
8577 +// standard includes
8578 +#include <stdio.h>
8579 +
8580 +// our includes
8581 +#include "XMLAttrs.h"
8582 +#include "XMLBase.h"
8583 +#include "XMLMirror.h"
8584 +
8585 +// rpm includes
8586 +#include <rpmbuild.h>
8587 +
8588 +// forward declaration
8589 +class XMLSpec;
8590 +
8591 +using namespace std;
8592 +
8593 +// <source ...>
8594 +class XMLSource : public XMLBase
8595 +{
8596 +//
8597 +// factory functions
8598 +//
8599 +public:
8600 +       /**
8601 +        * Static factory function for the creation of XMLSource, XMLPatch, ...
8602 +        * objects from RPM Source* structure.
8603 +        * .
8604 +        * @param pSource Pointer to a list of sources
8605 +        * @param pSpec pointer to the RPM spec
8606 +        * @param pSpec pointer to our spec object
8607 +        * @return true on success, false otherwise
8608 +        **/
8609 +       static bool structCreate(Source* pSource,
8610 +                                                        Spec pSpec,
8611 +                                                        XMLSpec* pXSpec);
8612 +
8613 +       /**
8614 +        * Static factory function for the creation of an XMLSource
8615 +        * object from details parsed from an XML spec.
8616 +        * .
8617 +        * @param pAttrs Pointer to an XML attribute object
8618 +        * @param pspec Ponter to our spec object
8619 +        * @param bPatch True if this source is a patch
8620 +        * @return true on success, false otherwise
8621 +        **/
8622 +       static bool parseCreate(XMLAttrs* pAttrs,
8623 +                                                       XMLSpec* pSpec);
8624 +
8625 +//
8626 +// constructors/destructor
8627 +//
8628 +public:
8629 +       /**
8630 +        * Default contructor
8631 +        * .
8632 +        * @param szName The name
8633 +        * @param szNum The source number
8634 +        * @param szDir The unpack directory
8635 +        * @param szSize The size of the source archive
8636 +        * @param szMD5 The MD5 sum of the archive
8637 +        * @return none
8638 +        **/
8639 +       XMLSource(const char* szName,
8640 +                         unsigned int nNum,
8641 +                         const char* szDir,
8642 +                         const char* szSize,
8643 +                         const char* szMD5);
8644 +
8645 +       /**
8646 +        * Copy contructor
8647 +        * .
8648 +        * @param rSource The source that we are to copy
8649 +        * @return none
8650 +        **/
8651 +       XMLSource(const XMLSource& rSource);
8652 +
8653 +       /**
8654 +        * Destructor
8655 +        * .
8656 +        * @param none
8657 +        * @return none
8658 +        **/
8659 +       virtual ~XMLSource();
8660 +
8661 +//
8662 +// operators
8663 +//
8664 +public:
8665 +       /**
8666 +        * Assignment operator
8667 +        * .
8668 +        * @param source The source to copy
8669 +        * @return copied object
8670 +        **/
8671 +       XMLSource operator=(XMLSource source);
8672 +
8673 +//
8674 +// Member functions
8675 +//
8676 +public:
8677 +       /**
8678 +        * Convert the object into an RPM spec file
8679 +        * .
8680 +        * @param rOut Output stream
8681 +        * @return none
8682 +        **/
8683 +       virtual void toSpecFile(ostream& rOut);
8684 +
8685 +       /**
8686 +        * Converts the object into an XML spec
8687 +        * .
8688 +        * @param rOut Output stream
8689 +        * @return none
8690 +        **/
8691 +       virtual void toXMLFile(ostream& rOut);
8692 +
8693 +       /**
8694 +        * Converts the object into an RPM structure
8695 +        * .
8696 +        * @param spec the RPM structure to use
8697 +        * @return none
8698 +        **/
8699 +       virtual void toRPMStruct(Spec spec);
8700 +
8701 +//
8702 +// member variable get/set functions
8703 +//
8704 +public:
8705 +       /**
8706 +        * Checks if we have a source name
8707 +        * .
8708 +        * @param none
8709 +        * @return true if we have a name, false otherwise
8710 +        **/
8711 +       bool hasName()
8712 +       {
8713 +               return m_sName.length() ? true : false;
8714 +       }
8715 +
8716 +       /**
8717 +        * Get the source name
8718 +        * .
8719 +        * @param none
8720 +        * @return string containing the name
8721 +        **/
8722 +       const char* getName()
8723 +       {
8724 +               return m_sName.c_str();
8725 +       }
8726 +
8727 +       /**
8728 +        * Get the length of the name
8729 +        * .
8730 +        * @param none
8731 +        * @return the length of the name
8732 +        **/
8733 +       unsigned int getNameLen()
8734 +       {
8735 +               return m_sName.length();
8736 +       }
8737 +
8738 +       /**
8739 +        * Get the source number
8740 +        * .
8741 +        * @param none
8742 +        * @return the number
8743 +        **/
8744 +       unsigned int getNum()
8745 +       {
8746 +               return m_nNum;
8747 +       }
8748 +
8749 +       /**
8750 +        * Checks to see if we have an unpack directory
8751 +        * .
8752 +        * @param none
8753 +        * @return true if we have a specified directory, false otherwise
8754 +        **/
8755 +       bool hasDir()
8756 +       {
8757 +               return m_sDir.length() ? true : false;
8758 +       }
8759 +
8760 +       /**
8761 +        * Gets the directory that we are to unpack this source to
8762 +        * .
8763 +        * @param none
8764 +        * @return string contating the directory
8765 +        **/
8766 +       const char* getDir()
8767 +       {
8768 +               return m_sDir.c_str();
8769 +       }
8770 +
8771 +       /**
8772 +        * Checks to see if we have a source size
8773 +        * .
8774 +        * @param none
8775 +        * @return true if we have a size, false otherwise
8776 +        **/
8777 +       bool hasSize()
8778 +       {
8779 +               return m_sSize.length() ? true : false;
8780 +       }
8781 +
8782 +       /**
8783 +        * Gets the size of the source
8784 +        * .
8785 +        * @param none
8786 +        * @return string contating the size
8787 +        **/
8788 +       const char* getSize()
8789 +       {
8790 +               return m_sSize.c_str();
8791 +       }
8792 +
8793 +       /**
8794 +        * Checks to see if this source has an MD5 sum
8795 +        * .
8796 +        * @param none
8797 +        * @return true if we have an MD5, false oterwise
8798 +        **/
8799 +       bool hasMD5()
8800 +       {
8801 +               return m_sMD5.length() ? true : false;
8802 +       }
8803 +
8804 +       /**
8805 +        * Gets the MD5 sum for this source
8806 +        * .
8807 +        * @param none
8808 +        * @return string contating the MD5
8809 +        **/
8810 +       const char* getMD5()
8811 +       {
8812 +               return m_sMD5.c_str();
8813 +       }
8814 +
8815 +       /**
8816 +        * Add a mirror for this source
8817 +        * .
8818 +        * @param rMirror The mirror to add
8819 +        * @return none
8820 +        **/
8821 +       void addMirror(XMLMirror& rMirror)
8822 +       {
8823 +               m_vMirrors.push_back(rMirror);
8824 +       }
8825 +
8826 +       /**
8827 +        * Gets the number of mirrors for this source
8828 +        * .
8829 +        * @param none
8830 +        * @return the number oif mirrors
8831 +        **/
8832 +       unsigned int numMirrors()
8833 +       {
8834 +               return m_vMirrors.size();
8835 +       }
8836 +
8837 +       /**
8838 +        * Gets a specific mirror by number
8839 +        * .
8840 +        * @param nNum The mirror to get
8841 +        * @param the mirror
8842 +        **/
8843 +       XMLMirror& getMirror(unsigned int nNum)
8844 +       {
8845 +               return m_vMirrors[nNum];
8846 +       }
8847 +
8848 +//
8849 +// member variables
8850 +//
8851 +protected:
8852 +       string            m_sName;
8853 +       unsigned int      m_nNum;
8854 +       string            m_sDir;
8855 +       string            m_sSize;
8856 +       string            m_sMD5;
8857 +       vector<XMLMirror> m_vMirrors;
8858 +};
8859 +
8860 +// <nosource ...>
8861 +class XMLNoSource : public XMLSource
8862 +{
8863 +//
8864 +// factory methods
8865 +//
8866 +public:
8867 +       /**
8868 +        * Create an XMLNoSource object
8869 +        * .
8870 +        * @param pAttrs XML attributes
8871 +        * @param pSpec The spec to add the object o
8872 +        * @return true on success, false otherwise
8873 +        **/
8874 +       static bool parseCreate(XMLAttrs* pAttrs,
8875 +                                                       XMLSpec* pSpec);
8876 +
8877 +//
8878 +// constructors/destructor
8879 +//
8880 +public:
8881 +       /**
8882 +        * Default constructor
8883 +        * .
8884 +        * @param szName The name
8885 +        * @param nNum source number
8886 +        * @param szDir Thje director to extract to
8887 +        * @param szSize size of the archive
8888 +        * @param szMD5 the MD5 sum of the archive
8889 +        * @return none
8890 +        **/
8891 +       XMLNoSource(const char* szName,
8892 +                               unsigned int nNum,
8893 +                               const char* szDir,
8894 +                               const char* szSize,
8895 +                               const char* szMD5);
8896 +
8897 +       /**
8898 +        * Copy constructor
8899 +        * .
8900 +        * @param rNoSource Reference to the object ot copy
8901 +        * @return none
8902 +        **/
8903 +       XMLNoSource(const XMLNoSource& rNoSource);
8904 +
8905 +       /**
8906 +        * Destructor
8907 +        * .
8908 +        * @param none
8909 +        * @return none
8910 +        **/
8911 +       virtual ~XMLNoSource();
8912 +
8913 +//
8914 +// public member functions
8915 +//
8916 +public:
8917 +       /**
8918 +        * Converts the object into an RPM spec file
8919 +        * .
8920 +        * @param rOut Output stream
8921 +        * @param none
8922 +        **/
8923 +       virtual void toSpecFile(ostream& rOut);
8924 +
8925 +       /**
8926 +        * Converts the object into an XML spec
8927 +        * .
8928 +        * @param rOut Output stream
8929 +        * @return none
8930 +        **/
8931 +       virtual void toXMLFile(ostream& rOut);
8932 +
8933 +       /**
8934 +        * Converts the object into an RPM structure
8935 +        * .
8936 +        * @param spec The RPM spec structure
8937 +        * @return none
8938 +        **/
8939 +        virtual void toRPMStruct(Spec spec);
8940 +};
8941 +
8942 +// <patch ...>
8943 +class XMLPatch : public XMLSource
8944 +{
8945 +//
8946 +// factory methods
8947 +//
8948 +public:
8949 +       /**
8950 +        * Create an XMLPatch object
8951 +        * .
8952 +        * @param pAttrs XML attributes
8953 +        * @param pSpec The spec to add the object o
8954 +        * @return true on success, false otherwise
8955 +        **/
8956 +       static bool parseCreate(XMLAttrs* pAttrs,
8957 +                                                       XMLSpec* pSpec);
8958 +
8959 +//
8960 +// constructors/destructor
8961 +//
8962 +public:
8963 +       /**
8964 +        * Default constructor
8965 +        * .
8966 +        * @param szName archive name
8967 +        * @param nNum source number
8968 +        * @param szSize size of the archive
8969 +        * @param szMD5 MD5 sum
8970 +        * @return none
8971 +        **/
8972 +       XMLPatch(const char* szName,
8973 +                        unsigned int nNum,
8974 +                        const char* szSize,
8975 +                        const char* szMD5);
8976 +
8977 +       /**
8978 +        * Copy constructor
8979 +        * .
8980 +        * @param rPatch Reference to the object to copy
8981 +        * @return none
8982 +        **/
8983 +       XMLPatch(const XMLPatch& rPatch);
8984 +
8985 +       /**
8986 +        * Destructor
8987 +        * .
8988 +        * @param none
8989 +        * @return nonew
8990 +        **/
8991 +       virtual ~XMLPatch();
8992 +
8993 +//
8994 +// member functions
8995 +//
8996 +public:
8997 +       /**
8998 +        * Converts the object into an RPM spec file
8999 +        * .
9000 +        * @param rOut Output stream
9001 +        * @param none
9002 +        **/
9003 +       virtual void toSpecFile(ostream& rOut);
9004 +
9005 +       /**
9006 +        * Converts the object into an XML spec
9007 +        * .
9008 +        * @param rOut Output stream
9009 +        * @return none
9010 +        **/
9011 +       virtual void toXMLFile(ostream& rOut);
9012 +
9013 +       /**
9014 +        * Converts the object into an RPM structure
9015 +        * .
9016 +        * @param spec The RPM spec structure
9017 +        * @return none
9018 +        **/
9019 +       virtual void toRPMStruct(Spec spec);
9020 +};
9021 +
9022 +#endif
9023 Index: xmlspec/XMLSpec.cpp
9024 ===================================================================
9025 RCS file: xmlspec/XMLSpec.cpp
9026 diff -N xmlspec/XMLSpec.cpp
9027 --- /dev/null   1 Jan 1970 00:00:00 -0000
9028 +++ rpm/xmlspec/XMLSpec.cpp     28 Aug 2002 10:52:43 -0000      1.3.2.1
9029 @@ -0,0 +1,252 @@
9030 +// 3rd party includes
9031 +#include <expat.h>
9032 +
9033 +// our includes
9034 +#include "XMLAttrs.h"
9035 +#include "XMLRPMWrap.h"
9036 +#include "XMLSpec.h"
9037 +
9038 +// rpm includes
9039 +#include <rpmlib.h>
9040 +
9041 +using namespace std;
9042 +
9043 +// attribute structure for XMLSpec
9044 +structValidAttrs g_paSpecAttrs[] =
9045 +{
9046 +       {0x0000,    true,  false, "name",           XATTRTYPE_STRING,  {"*", NULL}},
9047 +       {0x0001,    true,  false, "version",        XATTRTYPE_STRING,  {"*", NULL}},
9048 +       {0x0002,    true,  false, "release",        XATTRTYPE_STRING,  {"*", NULL}},
9049 +       {0x0003,    false, false, "epoch",          XATTRTYPE_INTEGER, {NULL}},
9050 +       {0x0004,    false, false, "distribution",   XATTRTYPE_STRING,  {"*", NULL}},
9051 +       {0x0005,    false, false, "vendor",         XATTRTYPE_STRING,  {"*", NULL}},
9052 +       {0x0006,    false, false, "packager",       XATTRTYPE_STRING,  {"*", NULL}},
9053 +       {0x0007,    false, false, "packager-email", XATTRTYPE_MAIL,    {"*", NULL}},
9054 +       {0x0008,    false, false, "copyright",      XATTRTYPE_STRING,  {"*", NULL}},
9055 +       {0x0009,    false, false, "url",            XATTRTYPE_STRING,  {"*", NULL}},
9056 +       {0x000A,    false, false, "buildroot",      XATTRTYPE_STRING,  {"*", NULL}},
9057 +       {XATTR_END, false, false, "end",            XATTRTYPE_NONE,    {NULL}}
9058 +};
9059 +
9060 +XMLSpec* XMLSpec::parseCreate(XMLAttrs* pAttrs,
9061 +                                                         const char* szFilename)
9062 +{
9063 +       // verify the attributes
9064 +       if (!pAttrs->validate(g_paSpecAttrs, (XMLBase*)pAttrs))
9065 +               return NULL;
9066 +
9067 +       // create and return
9068 +       return new XMLSpec(szFilename,
9069 +                                          pAttrs->asString("name"),
9070 +                                          pAttrs->asString("version"),
9071 +                                          pAttrs->asString("release"),
9072 +                                          pAttrs->asString("epoch"),
9073 +                                          pAttrs->asString("distribution"),
9074 +                                          pAttrs->asString("vendor"),
9075 +                                          pAttrs->asString("packager"),
9076 +                                          pAttrs->asString("packager-email"),
9077 +                                          pAttrs->asString("copyright"),
9078 +                                          pAttrs->asString("url"),
9079 +                                          pAttrs->asString("buildroot"));
9080 +}
9081 +
9082 +XMLSpec* XMLSpec::structCreate(Spec pSpec)
9083 +{
9084 +       if (!pSpec || !pSpec->packages || !pSpec->packages->header)
9085 +               return NULL;
9086 +
9087 +       // create the spec with values from the RPM stuff
9088 +       string sName, sVersion, sRelease, sEpoch, sDistro;
9089 +       string sVendor, sPackager, sMail, sLicense, sURL;
9090 +       if (!getRPMHeader(pSpec->packages->header, RPMTAG_NAME, sName) ||
9091 +               !getRPMMacro("PACKAGE_VERSION", sVersion) ||
9092 +               !getRPMMacro("PACKAGE_RELEASE", sRelease))
9093 +               return NULL;
9094 +       getRPMHeader(pSpec->packages->header, RPMTAG_EPOCH, sEpoch);
9095 +       getRPMHeader(pSpec->packages->header, RPMTAG_DISTRIBUTION, sDistro);
9096 +       getRPMHeader(pSpec->packages->header, RPMTAG_VENDOR, sVendor);
9097 +       getRPMHeader(pSpec->packages->header, RPMTAG_PACKAGER, sPackager);
9098 +       getRPMHeader(pSpec->packages->header, RPMTAG_LICENSE, sLicense);
9099 +       getRPMHeader(pSpec->packages->header, RPMTAG_URL, sURL);
9100 +       XMLSpec* pXSpec = new XMLSpec(pSpec->specFile, sName.c_str(), sVersion.c_str(),
9101 +                                                                 sRelease.c_str(), sEpoch.c_str(), sDistro.c_str(),
9102 +                                                                 sVendor.c_str(), sPackager.c_str(), sMail.c_str(),
9103 +                                                                 sLicense.c_str(), sURL.c_str(), pSpec->buildRootURL);
9104 +
9105 +       // add sources, packages all kinds of funny stuff
9106 +       XMLChangelog::structCreate(pSpec, pXSpec);
9107 +       XMLSource::structCreate(pSpec->sources, pSpec, pXSpec);
9108 +       XMLPackage::structCreate(pSpec->packages, pSpec, pXSpec);
9109 +
9110 +       // return the created spec
9111 +       return pXSpec;
9112 +}
9113 +
9114 +XMLSpec::XMLSpec(const char* szFilename,
9115 +                                const char* szName,
9116 +                                const char* szVersion,
9117 +                                const char* szRelease,
9118 +                                const char* szEpoch,
9119 +                                const char* szDistribution,
9120 +                                const char* szVendor,
9121 +                                const char* szPackager,
9122 +                                const char* szPkgrEmail,
9123 +                                const char* szCopyright,
9124 +                                const char* szURL,
9125 +                                const char* szBuildRoot) : XMLBase()
9126 +{
9127 +       if (szFilename)
9128 +               m_sFilename.assign(szFilename);
9129 +       if (szName)
9130 +               m_sName.assign(szName);
9131 +       if (szVersion)
9132 +               m_sVersion.assign(szVersion);
9133 +       if (szRelease)
9134 +               m_sRelease.assign(szRelease);
9135 +       if (szEpoch)
9136 +               m_sEpoch.assign(szEpoch);
9137 +       if (szDistribution)
9138 +               m_sDistribution.assign(szDistribution);
9139 +       if (szVendor)
9140 +               m_sVendor.assign(szVendor);
9141 +       if (szPackager)
9142 +               m_sPackager.assign(szPackager);
9143 +       if (szPkgrEmail)
9144 +               m_sPkgrEmail.assign(szPkgrEmail);
9145 +       if (szCopyright)
9146 +               m_sCopyright.assign(szCopyright);
9147 +       if (szURL)
9148 +               m_sURL.assign(szURL);
9149 +       if (szBuildRoot)
9150 +               m_sBuildRoot.assign(szBuildRoot);
9151 +}
9152 +
9153 +XMLSpec::~XMLSpec()
9154 +{
9155 +}
9156 +
9157 +void XMLSpec::toSpecFile(ostream& rOut)
9158 +{
9159 +       for (unsigned int i = 0; i < numXMacros(); i++)
9160 +               getXMacro(i).toSpecFile(rOut);
9161 +
9162 +       rOut << "name:           " << getName() << endl;
9163 +       rOut << "version:        " << getVersion() << endl;
9164 +       rOut << "release:        " << getRelease() << endl;
9165 +       if (hasEpoch())
9166 +               rOut << "epoch:          " << getEpoch() << endl;
9167 +       if (hasCopyright())
9168 +               rOut << "copyright:      " << getCopyright() << endl;
9169 +       if (hasURL())
9170 +               rOut << "url:            " << getURL() << endl;
9171 +       if (hasBuildRoot())
9172 +               rOut << "buildroot:      " << getBuildRoot() << endl;
9173 +       if (hasDistribution())
9174 +               rOut << "distribution:   " << getDistribution() << endl;
9175 +       if (hasVendor())
9176 +               rOut << "vendor:         " << getVendor() << endl;
9177 +       if (hasPackager()) {
9178 +               rOut << "packager:       " << getPackager();
9179 +               if (hasPkgrEmail())
9180 +                       rOut << " <" << getPkgrEmail() << ">";
9181 +               rOut << endl;
9182 +       }
9183 +
9184 +       for (unsigned int i = 0; i < numSources(); i++)
9185 +               getSource(i).toSpecFile(rOut);
9186 +       //for (unsigned int i = 0; i < numNoSources(); i++)
9187 +       //      getNoSource(i).toSpecFile(rOut);
9188 +       for (unsigned int i = 0; i < numPatches(); i++)
9189 +               getPatch(i).toSpecFile(rOut);
9190 +       for (unsigned int i = 0; i < numPackages(); i++)
9191 +               getPackage(i).toSpecFile(rOut);
9192 +
9193 +       getPrep().toSpecFile(rOut, "prep");
9194 +       getBuild().toSpecFile(rOut, "build");
9195 +       getInstall().toSpecFile(rOut, "install");
9196 +       getClean().toSpecFile(rOut, "clean");
9197 +
9198 +       for (unsigned int i = 0; i < numPackages(); i++)
9199 +               getPackage(i).toScriptsSpecFile(rOut);
9200 +
9201 +       for (unsigned int i = 0; i < numPackages(); i++)
9202 +               getPackage(i).toFilesSpecFile(rOut);
9203 +
9204 +       getChangelog().toSpecFile(rOut);
9205 +}
9206 +
9207 +void XMLSpec::toXMLFile(ostream& rOut)
9208 +{
9209 +       // spec start
9210 +       rOut << "<?xml version=\"1.0\"?>";
9211 +       rOut << endl << "<spec name=\"" << getName() << "\"";
9212 +       rOut << endl << "      version=\"" << getVersion() << "\"";
9213 +       rOut << endl << "      release=\"" << getRelease() << "\"";
9214 +       if (hasEpoch())
9215 +               rOut << endl << "      epoch=\"" << getEpoch() << "\"";
9216 +       if (hasCopyright())
9217 +               rOut << endl << "      copyright=\"" << getCopyright() << "\"";
9218 +       if (hasURL())
9219 +               rOut << endl << "      url=\"" << getURL() << "\"";
9220 +       if (hasBuildRoot())
9221 +               rOut << endl << "      buildroot=\"" << getBuildRoot() << "\"";
9222 +       if (hasDistribution())
9223 +               rOut << endl << "      distribution=\"" << getDistribution() << "\"";
9224 +       if (hasVendor())
9225 +               rOut << endl << "      vendor=\"" << getVendor() << "\"";
9226 +       if (hasPackager()) {
9227 +               rOut << endl << "      packager=\"" << getPackager() << "\"";
9228 +               if (hasPkgrEmail())
9229 +                       rOut << endl << "      packager-email=\"" << getPkgrEmail() << "\"";
9230 +       }
9231 +       rOut << ">";
9232 +
9233 +       for (unsigned int i = 0; i < numXMacros(); i++)
9234 +               getXMacro(i).toXMLFile(rOut);
9235 +       for (unsigned int i = 0; i < numSources(); i++)
9236 +               getSource(i).toXMLFile(rOut);
9237 +       for (unsigned int i = 0; i < numNoSources(); i++)
9238 +               getNoSource(i).toXMLFile(rOut);
9239 +       for (unsigned int i = 0; i < numPatches(); i++)
9240 +               getPatch(i).toXMLFile(rOut);
9241 +       for (unsigned int i = 0; i < numPackages(); i++)
9242 +               getPackage(i).toXMLFile(rOut);
9243 +
9244 +       getPrep().toXMLFile(rOut, "prep");
9245 +       getBuild().toXMLFile(rOut, "build");
9246 +       getInstall().toXMLFile(rOut, "install");
9247 +       getClean().toXMLFile(rOut, "clean");
9248 +
9249 +       getChangelog().toXMLFile(rOut);
9250 +
9251 +       rOut << endl << "</spec>";
9252 +}
9253 +
9254 +void XMLSpec::toRPMStruct(Spec* pRPMSpec)
9255 +{
9256 +       Spec spec = newSpec();
9257 +       if (hasBuildRoot()) {
9258 +               spec->gotBuildRootURL = 1;
9259 +               spec->buildRootURL = strdup(getBuildRoot());
9260 +               addMacro(spec->macros, "buildroot", NULL, getBuildRoot(), RMIL_SPEC);
9261 +       }
9262 +       addMacro(NULL, "_docdir", NULL, "%{_defaultdocdir}", RMIL_SPEC);
9263 +       spec->timeCheck = rpmExpandNumeric("%{_timecheck}");
9264 +
9265 +       //getChangelog().toRPMStruct(spec);
9266 +       /*for (unsigned int i = 0; i < numPackages(); i++)
9267 +               getPackage(i).toRPMStruct(pRPMSpec);
9268 +       for (unsigned int i = 0; i < numSources(); i++)
9269 +               getSource(i).toRPMStruct(pRPMSpec);
9270 +       for (unsigned int i = 0; i < numNoSources(); i++)
9271 +               getNoSource(i).toRPMStruct(pRPMSpec);
9272 +       for (unsigned int i = 0; i < numPatches(); i++)
9273 +               getPatch(i).toRPMStruct(pRPMSpec);*/
9274 +
9275 +       //getPrep().toRPMStruct(spec);
9276 +       //getBuild().toRPMStruct(spec);
9277 +       //getInstall().toRPMStruct(spec);
9278 +       //getClean().toRPMStruct(spec);
9279 +
9280 +       *pRPMSpec = spec;
9281 +}
9282 Index: xmlspec/XMLSpec.h
9283 ===================================================================
9284 RCS file: xmlspec/XMLSpec.h
9285 diff -N xmlspec/XMLSpec.h
9286 --- /dev/null   1 Jan 1970 00:00:00 -0000
9287 +++ rpm/xmlspec/XMLSpec.h       28 Aug 2002 10:52:43 -0000      1.2.2.1
9288 @@ -0,0 +1,678 @@
9289 +#ifndef _H_XMLSPEC_
9290 +#define _H_XMLSPEC_
9291 +
9292 +// standard C++ includes
9293 +#include <iostream>
9294 +#include <string>
9295 +#include <vector>
9296 +
9297 +// our includes
9298 +#include "XMLAttrs.h"
9299 +#include "XMLBase.h"
9300 +#include "XMLChangelog.h"
9301 +#include "XMLMacro.h"
9302 +#include "XMLPackage.h"
9303 +#include "XMLScript.h"
9304 +#include "XMLSource.h"
9305 +
9306 +// rpm includes
9307 +#include <rpmbuild.h>
9308 +
9309 +using namespace std;
9310 +
9311 +// <spec ...>
9312 +class XMLSpec : public XMLBase
9313 +{
9314 +//
9315 +// static object creation functions
9316 +//
9317 +public:
9318 +       /**
9319 +        * Creates an XMLSpec from values parsed
9320 +        * .
9321 +        * @param pAttrs The XML attributes
9322 +        * @param szFilename The XML spec filename
9323 +        * @return Pointer to the created spec
9324 +        **/
9325 +       static XMLSpec* parseCreate(XMLAttrs* pAttrs,
9326 +                                                               const char* szFilename);
9327 +
9328 +       /**
9329 +        * Creates and XMLSpec from an RPM Spec structure
9330 +        * .
9331 +        * @param pSpec The RPM spec structure
9332 +        * @return Pointer to the created spec
9333 +        **/
9334 +       static XMLSpec* structCreate(Spec pSpec);
9335 +
9336 +//
9337 +// constructors/destructor
9338 +//
9339 +public:
9340 +       /**
9341 +        * Default constructor
9342 +        * .
9343 +        * @param szFilename Filename of the spec on disk
9344 +        * @param szName spec name
9345 +        * @param szVersion Spec version
9346 +        * @param szRelease spec release
9347 +        * @param szEpoch spec epoch
9348 +        * @param szDistribution spec distribution
9349 +        * @param szVendor spec vendor
9350 +        * @param szPackage spec packager
9351 +        * @param szPkgEmail email address for the packager
9352 +        * @param szCopyright spec copyright/licence
9353 +        * @param szURL main package url
9354 +        * @param szBuildRoot buildroot
9355 +        * @return none
9356 +        **/
9357 +       XMLSpec(const char* szFilename,
9358 +                       const char* szName,
9359 +                       const char* szVersion,
9360 +                       const char* szRelease,
9361 +                       const char* szEpoch,
9362 +                       const char* szDistribution,
9363 +                       const char* szVendor,
9364 +                       const char* szPackager,
9365 +                       const char* szPkgrEmail,
9366 +                       const char* szCopyright,
9367 +                       const char* szURL,
9368 +                       const char* szBuildRoot);
9369 +
9370 +       /**
9371 +        * Destructor
9372 +        * .
9373 +        * @param none
9374 +        * @return none
9375 +        **/
9376 +       ~XMLSpec();
9377 +
9378 +//
9379 +// public member functions
9380 +//
9381 +public:
9382 +       /**
9383 +        * Converts the spec object to a normal RPM spec file
9384 +        * .
9385 +        * @param rOut Reference to the stream to write the information to
9386 +        * @return none
9387 +        **/
9388 +       void toSpecFile(ostream& rOut);
9389 +
9390 +       /**
9391 +        * Converts the spec object to an XML spec file
9392 +        * .
9393 +        * @param rOut Reference to the stream to write the information to
9394 +        * @return none
9395 +        **/
9396 +        void toXMLFile(ostream& rOut);
9397 +
9398 +        /**
9399 +         * Converts the spec object to an internal RPM structure
9400 +         * .
9401 +         * @param none
9402 +         * @return the created RPM structure
9403 +         **/
9404 +         void toRPMStruct(Spec* pRPMSpec);
9405 +
9406 +//
9407 +// member variable get/set functions
9408 +//
9409 +public:
9410 +       /**
9411 +        * Adds a package to the internal list
9412 +        * .
9413 +        * @param rPkg Reference to the package to add
9414 +        * @return none
9415 +        **/
9416 +       void addPackage(XMLPackage& rPkg)
9417 +       {
9418 +               m_vPackages.push_back(rPkg);
9419 +       }
9420 +
9421 +       /**
9422 +        * Gets the number of packages
9423 +        * .
9424 +        * @param none
9425 +        * @return the number of packages
9426 +        **/
9427 +       unsigned int numPackages()
9428 +       {
9429 +               return m_vPackages.size();
9430 +       }
9431 +
9432 +       /**
9433 +        * Gets a specific package
9434 +        * .
9435 +        * @param nNum The package number
9436 +        * @return the required package
9437 +        **/
9438 +       XMLPackage& getPackage(unsigned int nNum)
9439 +       {
9440 +               return m_vPackages[nNum];
9441 +       }
9442 +
9443 +       /**
9444 +        * Gets the last package added
9445 +        * .
9446 +        * @param none
9447 +        * @return the last package added
9448 +        **/
9449 +       XMLPackage& lastPackage()
9450 +       {
9451 +               return m_vPackages[numPackages()-1];
9452 +       }
9453 +
9454 +       /**
9455 +        * Adds a source to the internal list
9456 +        * .
9457 +        * @param rSource Reference to the source to add
9458 +        * @return none
9459 +        **/
9460 +       void addSource(XMLSource& rSource)
9461 +       {
9462 +               m_vSources.push_back(rSource);
9463 +       }
9464 +
9465 +       /**
9466 +        * Gets the number of sources
9467 +        * .
9468 +        * @param none
9469 +        * @return the number of sources
9470 +        **/
9471 +       unsigned int numSources()
9472 +       {
9473 +               return m_vSources.size();
9474 +       }
9475 +
9476 +       /**
9477 +        * Gets a specific source
9478 +        * .
9479 +        * @param nNum The source number
9480 +        * @return the required source
9481 +        **/
9482 +       XMLSource& getSource(unsigned int nNum)
9483 +       {
9484 +               return m_vSources[nNum];
9485 +       }
9486 +
9487 +       /**
9488 +        * Gets the last source added
9489 +        * .
9490 +        * @param none
9491 +        * @return the last source added
9492 +        **/
9493 +       XMLSource& lastSource()
9494 +       {
9495 +               return m_vSources[numSources()-1];
9496 +       }
9497 +
9498 +       /**
9499 +        * Adds a source to the internal list
9500 +        * .
9501 +        * @param rSource Reference to the source to add
9502 +        * @return none
9503 +        **/
9504 +       void addNoSource(XMLNoSource& rSource)
9505 +       {
9506 +               m_vNoSources.push_back(rSource);
9507 +       }
9508 +
9509 +       /**
9510 +        * Gets the number of nosources
9511 +        * .
9512 +        * @param none
9513 +        * @return the number of nsources
9514 +        **/
9515 +       unsigned int numNoSources()
9516 +       {
9517 +               return m_vNoSources.size();
9518 +       }
9519 +
9520 +       /**
9521 +        * Gets a specific nosource
9522 +        * .
9523 +        * @param nNum The nosource number
9524 +        * @return the required nosource
9525 +        **/
9526 +       XMLNoSource& getNoSource(unsigned int nNum)
9527 +       {
9528 +               return m_vNoSources[nNum];
9529 +       }
9530 +
9531 +       /**
9532 +        * Gets the last nosource added
9533 +        * .
9534 +        * @param none
9535 +        * @return the last nosource added
9536 +        **/
9537 +       XMLNoSource& lastNoSource()
9538 +       {
9539 +               return m_vNoSources[numNoSources()-1];
9540 +       }
9541 +
9542 +       /**
9543 +        * Adds a patch to the internal list
9544 +        * .
9545 +        * @param rSource Reference to the patch to add
9546 +        * @return none
9547 +        **/
9548 +       void addPatch(XMLPatch& rSource)
9549 +       {
9550 +               m_vPatches.push_back(rSource);
9551 +       }
9552 +
9553 +       /**
9554 +        * Gets the number of patches
9555 +        * .
9556 +        * @param none
9557 +        * @return the number of patches
9558 +        **/
9559 +       unsigned int numPatches()
9560 +       {
9561 +               return m_vPatches.size();
9562 +       }
9563 +
9564 +       /**
9565 +        * Gets a specific patch
9566 +        * .
9567 +        * @param nNum The patch number
9568 +        * @return the required patch
9569 +        **/
9570 +       XMLPatch& getPatch(unsigned int nNum)
9571 +       {
9572 +               return m_vPatches[nNum];
9573 +       }
9574 +
9575 +       /**
9576 +        * Gets the last patch added
9577 +        * .
9578 +        * @param none
9579 +        * @return the last patch added
9580 +        **/
9581 +       XMLPatch& lastPatch()
9582 +       {
9583 +               return m_vPatches[numPatches()-1];
9584 +       }
9585 +
9586 +       /**
9587 +        * Adds a macro to the internal list
9588 +        * .
9589 +        * @param rMacro Reference to the macro to add
9590 +        * @return none
9591 +        **/
9592 +       void addXMacro(XMLMacro& rMacro)
9593 +       {
9594 +               m_vMacros.push_back(rMacro);
9595 +       }
9596 +
9597 +       /**
9598 +        * Gets the number of macros
9599 +        * .
9600 +        * @param none
9601 +        * @return the number of macros
9602 +        **/
9603 +       unsigned int numXMacros()
9604 +       {
9605 +               return m_vMacros.size();
9606 +       }
9607 +
9608 +       /**
9609 +        * Gets a specific macro
9610 +        * .
9611 +        * @param nNum The macro number
9612 +        * @return the required macro
9613 +        **/
9614 +       XMLMacro& getXMacro(unsigned int nNum)
9615 +       {
9616 +               return m_vMacros[nNum];
9617 +       }
9618 +
9619 +       /**
9620 +        * Checks if we have a filename
9621 +        * .
9622 +        * @param none
9623 +        * @return true if available, false otherwise
9624 +        **/
9625 +       bool hasFilename()
9626 +       {
9627 +               return m_sFilename.length() ? true : false;
9628 +       }
9629 +
9630 +       /**
9631 +        * Gets the filename
9632 +        * .
9633 +        * @param none
9634 +        * @return string containing the filename
9635 +        **/
9636 +       const char* getFilename()
9637 +       {
9638 +               return m_sFilename.c_str();
9639 +       }
9640 +
9641 +       /**
9642 +        * Checks if we have a name
9643 +        * .
9644 +        * @param none
9645 +        * @return true if available, false otherwise
9646 +        **/
9647 +       bool hasName()
9648 +       {
9649 +               return m_sName.length() ? true : false;
9650 +       }
9651 +
9652 +       /**
9653 +        * Gets the name
9654 +        * .
9655 +        * @param none
9656 +        * @return string containing the name
9657 +        **/
9658 +       const char* getName()
9659 +       {
9660 +               return m_sName.c_str();
9661 +       }
9662 +
9663 +       /**
9664 +        * Checks if we have a version
9665 +        * .
9666 +        * @param none
9667 +        * @return true if available, false otherwise
9668 +        **/
9669 +       bool hasVersion()
9670 +       {
9671 +               return m_sVersion.length() ? true : false;
9672 +       }
9673 +
9674 +       /**
9675 +        * Gets the version
9676 +        * .
9677 +        * @param none
9678 +        * @return string containing the version
9679 +        **/
9680 +       const char* getVersion()
9681 +       {
9682 +               return m_sVersion.c_str();
9683 +       }
9684 +
9685 +       /**
9686 +        * Checks if we have a release
9687 +        * .
9688 +        * @param none
9689 +        * @return true if available, false otherwise
9690 +        **/
9691 +       bool hasRelease()
9692 +       {
9693 +               return m_sRelease.length() ? true : false;
9694 +       }
9695 +
9696 +       /**
9697 +        * Gets the release
9698 +        * .
9699 +        * @param none
9700 +        * @return string containing the release
9701 +        **/
9702 +       const char* getRelease()
9703 +       {
9704 +               return m_sRelease.c_str();
9705 +       }
9706 +
9707 +       /**
9708 +        * Checks if we have a epoch
9709 +        * .
9710 +        * @param none
9711 +        * @return true if available, false otherwise
9712 +        **/
9713 +       bool hasEpoch()
9714 +       {
9715 +               return m_sEpoch.length() ? true : false;
9716 +       }
9717 +
9718 +       /**
9719 +        * Gets the epoch
9720 +        * .
9721 +        * @param none
9722 +        * @return string containing the epoch
9723 +        **/
9724 +       const char* getEpoch()
9725 +       {
9726 +               return m_sEpoch.c_str();
9727 +       }
9728 +
9729 +       /**
9730 +        * Checks if we have a distribution
9731 +        * .
9732 +        * @param none
9733 +        * @return true if available, false otherwise
9734 +        **/
9735 +       bool hasDistribution()
9736 +       {
9737 +               return m_sDistribution.length() ? true : false;
9738 +       }
9739 +
9740 +       /**
9741 +        * Gets the distribution
9742 +        * .
9743 +        * @param none
9744 +        * @return string containing the distribution
9745 +        **/
9746 +       const char* getDistribution()
9747 +       {
9748 +               return m_sDistribution.c_str();
9749 +       }
9750 +
9751 +       /**
9752 +        * Checks if we have a vendor
9753 +        * .
9754 +        * @param none
9755 +        * @return true if available, false otherwise
9756 +        **/
9757 +       bool hasVendor()
9758 +       {
9759 +               return m_sVendor.length() ? true : false;
9760 +       }
9761 +
9762 +       /**
9763 +        * Gets the vendor
9764 +        * .
9765 +        * @param none
9766 +        * @return string containing the vendor
9767 +        **/
9768 +       const char* getVendor()
9769 +       {
9770 +               return m_sVendor.c_str();
9771 +       }
9772 +
9773 +       /**
9774 +        * Checks if we have a packager
9775 +        * .
9776 +        * @param none
9777 +        * @return true if available, false otherwise
9778 +        **/
9779 +       bool hasPackager()
9780 +       {
9781 +               return m_sPackager.length() ? true : false;
9782 +       }
9783 +
9784 +       /**
9785 +        * Gets the packager
9786 +        * .
9787 +        * @param none
9788 +        * @return string containing the packager
9789 +        **/
9790 +       const char* getPackager()
9791 +       {
9792 +               return m_sPackager.c_str();
9793 +       }
9794 +
9795 +       /**
9796 +        * Checks if we have a packager email
9797 +        * .
9798 +        * @param none
9799 +        * @return true if available, false otherwise
9800 +        **/
9801 +       bool hasPkgrEmail()
9802 +       {
9803 +               return m_sPkgrEmail.length() ? true : false;
9804 +       }
9805 +
9806 +       /**
9807 +        * Gets the packager's email address
9808 +        * .
9809 +        * @param none
9810 +        * @return string containing the packager's email address
9811 +        **/
9812 +       const char* getPkgrEmail()
9813 +       {
9814 +               return m_sPkgrEmail.c_str();
9815 +       }
9816 +
9817 +       /**
9818 +        * Checks if we have a copyright
9819 +        * .
9820 +        * @param none
9821 +        * @return true if available, false otherwise
9822 +        **/
9823 +       bool hasCopyright()
9824 +       {
9825 +               return m_sCopyright.length() ? true : false;
9826 +       }
9827 +
9828 +       /**
9829 +        * Gets the copyright
9830 +        * .
9831 +        * @param none
9832 +        * @return string containing the copyright
9833 +        **/
9834 +       const char* getCopyright()
9835 +       {
9836 +               return m_sCopyright.c_str();
9837 +       }
9838 +
9839 +       /**
9840 +        * Checks if we have an URL
9841 +        * .
9842 +        * @param none
9843 +        * @return true if available, false otherwise
9844 +        **/
9845 +       bool hasURL()
9846 +       {
9847 +               return m_sURL.length() ? true : false;
9848 +       }
9849 +
9850 +       /**
9851 +        * Gets the URL
9852 +        * .
9853 +        * @param none
9854 +        * @return string containing the URL
9855 +        **/
9856 +       const char* getURL()
9857 +       {
9858 +               return m_sURL.c_str();
9859 +       }
9860 +
9861 +       /**
9862 +        * Checks if we have a BuildRoot
9863 +        * .
9864 +        * @param none
9865 +        * @return true if available, false otherwise
9866 +        **/
9867 +       bool hasBuildRoot()
9868 +       {
9869 +               return m_sBuildRoot.length() ? true : false;
9870 +       }
9871 +
9872 +       /**
9873 +        * Gets the buildroot
9874 +        * .
9875 +        * @param none
9876 +        * @return string containing the buildroor
9877 +        **/
9878 +       const char* getBuildRoot()
9879 +       {
9880 +               return m_sBuildRoot.c_str();
9881 +       }
9882 +
9883 +       /**
9884 +        * Gets the prep section
9885 +        * .
9886 +        * @param none
9887 +        * @return reference to the prep section
9888 +        **/
9889 +       XMLScripts& getPrep()
9890 +       {
9891 +               return m_Prep;
9892 +       }
9893 +
9894 +       /**
9895 +        * Gets the build section
9896 +        * .
9897 +        * @param none
9898 +        * @return reference to the build section
9899 +        **/
9900 +       XMLScripts& getBuild()
9901 +       {
9902 +               return m_Build;
9903 +       }
9904 +
9905 +       /**
9906 +        * Gets the install section
9907 +        * .
9908 +        * @param none
9909 +        * @return reference to the install section
9910 +        **/
9911 +       XMLScripts& getInstall()
9912 +       {
9913 +               return m_Install;
9914 +       }
9915 +
9916 +       /**
9917 +        * Gets the clean section
9918 +        * .
9919 +        * @param none
9920 +        * @return reference to the clean section
9921 +        **/
9922 +       XMLScripts& getClean()
9923 +       {
9924 +               return m_Clean;
9925 +       }
9926 +
9927 +       /**
9928 +        * Gets the changelog section
9929 +        * .
9930 +        * @param none
9931 +        * @return reference to the changelog section
9932 +        **/
9933 +       XMLChangelog& getChangelog()
9934 +       {
9935 +               return m_Changelog;
9936 +       }
9937 +
9938 +//
9939 +// internal member variables
9940 +//
9941 +protected:
9942 +       string              m_sFilename;
9943 +       string              m_sName;
9944 +       string              m_sVersion;
9945 +       string              m_sRelease;
9946 +       string              m_sEpoch;
9947 +       string              m_sDistribution;
9948 +       string              m_sVendor;
9949 +       string              m_sPackager;
9950 +       string              m_sPkgrEmail;
9951 +       string              m_sCopyright;
9952 +       string              m_sURL;
9953 +       string              m_sBuildRoot;
9954 +       vector<XMLPackage>  m_vPackages;
9955 +       vector<XMLSource>   m_vSources;
9956 +       vector<XMLNoSource> m_vNoSources;
9957 +       vector<XMLPatch>    m_vPatches;
9958 +       vector<XMLMacro>    m_vMacros;
9959 +       XMLScripts          m_Prep;
9960 +       XMLScripts          m_Build;
9961 +       XMLScripts          m_Install;
9962 +       XMLScripts          m_Clean;
9963 +       XMLChangelog        m_Changelog;
9964 +};
9965 +
9966 +#endif
9967 Index: xmlspec/XMLText.cpp
9968 ===================================================================
9969 RCS file: xmlspec/XMLText.cpp
9970 diff -N xmlspec/XMLText.cpp
9971 --- /dev/null   1 Jan 1970 00:00:00 -0000
9972 +++ rpm/xmlspec/XMLText.cpp     28 Aug 2002 10:52:43 -0000      1.1.2.1
9973 @@ -0,0 +1,23 @@
9974 +// our includes
9975 +#include "XMLText.h"
9976 +
9977 +using namespace std;
9978 +
9979 +XMLText::XMLText(const char* szText,
9980 +                                const char* szLang)
9981 +       : XMLBase()
9982 +{
9983 +       setText(szText);
9984 +       setLang(szLang);
9985 +}
9986 +
9987 +XMLText::XMLText(const XMLText& rText)
9988 +       : XMLBase()
9989 +{
9990 +       setText(rText.m_sText.c_str());
9991 +       setLang(rText.m_sLang.c_str());
9992 +}
9993 +
9994 +XMLText::~XMLText()
9995 +{
9996 +}
9997 Index: xmlspec/XMLText.h
9998 ===================================================================
9999 RCS file: xmlspec/XMLText.h
10000 diff -N xmlspec/XMLText.h
10001 --- /dev/null   1 Jan 1970 00:00:00 -0000
10002 +++ rpm/xmlspec/XMLText.h       28 Aug 2002 10:52:43 -0000      1.1.2.1
10003 @@ -0,0 +1,119 @@
10004 +#ifndef _H_XMLTEXT_
10005 +#define _H_XMLTEXT_
10006 +
10007 +// standard c++ includes
10008 +#include <string>
10009 +
10010 +// our includes
10011 +#include "XMLBase.h"
10012 +
10013 +using namespace std;
10014 +
10015 +class XMLText : public XMLBase
10016 +{
10017 +//
10018 +// constructors/destructor
10019 +//
10020 +public:
10021 +       /**
10022 +        * Default constructor
10023 +        * .
10024 +        * @param szText The text to add
10025 +        * @param szLang The text's language
10026 +        * @return none
10027 +        **/
10028 +       XMLText(const char* szText,
10029 +                       const char* szLang = NULL);
10030 +
10031 +       /**
10032 +        * Copy constructor
10033 +        * .
10034 +        * @param rText reference to the text to copy
10035 +        * @return none
10036 +        **/
10037 +       XMLText(const XMLText& rText);
10038 +
10039 +       /**
10040 +        * Default destructor
10041 +        * .
10042 +        * @param none
10043 +        * @return none
10044 +        **/
10045 +       ~XMLText();
10046 +
10047 +//
10048 +// get/set methods for internal variables
10049 +//
10050 +public:
10051 +       /**
10052 +        * Sets the text
10053 +        * .
10054 +        * @param szText The text
10055 +        * @return none
10056 +        **/
10057 +       void setText(const char* szText)
10058 +       {
10059 +               if (szText)
10060 +                       m_sText.assign(szText);
10061 +       }
10062 +
10063 +       /**
10064 +        * Gets the text
10065 +        * .
10066 +        * @param none
10067 +        * @return string containing the text
10068 +        **/
10069 +       const char* getText()
10070 +       {
10071 +               return m_sText.c_str();
10072 +       }
10073 +
10074 +       /**
10075 +        * Tests if we have a language for this description
10076 +        * .
10077 +        * @param none
10078 +        * @return true if we have a language, false otherwise
10079 +        **/
10080 +       bool hasLang()
10081 +       {
10082 +               return m_sLang.length() ? true : false;
10083 +       }
10084 +
10085 +       /**
10086 +        * Sets the language
10087 +        * .
10088 +        * @param szLang The language
10089 +        * @return none
10090 +        **/
10091 +       void setLang(const char* szLang)
10092 +       {
10093 +               if (szLang) {
10094 +                       // FIXME: We need to get the actual default language as specified
10095 +                       // in one of the RPM headers (which I cannot find now) and
10096 +                       // substitute it here. (I know the value is "C", bu we should
10097 +                       // use the define.)
10098 +                       if (strcmp(szLang, "C") != 0)
10099 +                               m_sLang.assign(szLang);
10100 +               }
10101 +       }
10102 +
10103 +       /**
10104 +        * Gets the language
10105 +        * .
10106 +        * @param none
10107 +        * @return string containing the language
10108 +        **/
10109 +       const char* getLang()
10110 +       {
10111 +               return m_sLang.c_str();
10112 +       }
10113 +
10114 +//
10115 +// member variables
10116 +//
10117 +public:
10118 +       string m_sText;
10119 +       string m_sLang;
10120 +};
10121 +
10122 +#endif
10123 Index: xmlspec/example.spec.xml
10124 ===================================================================
10125 RCS file: xmlspec/example.spec.xml
10126 diff -N xmlspec/example.spec.xml
10127 --- /dev/null   1 Jan 1970 00:00:00 -0000
10128 +++ rpm/xmlspec/example.spec.xml        28 Aug 2002 10:52:43 -0000      1.3.2.1
10129 @@ -0,0 +1,188 @@
10130 +<?xml version="1.0"?>
10131 +<!--
10132 +       This is an example XML spec file to demonstrate the xml2spec
10133 +       conversion program. By running "xml2spec example.spec.xml" it
10134 +       will create an output spec in "normal" RPM spec format, ready
10135 +       for comsumption by rpmbuild.
10136 +-->
10137 +<spec name="example"
10138 +         version="1.0"
10139 +         release="06"
10140 +         copyright="GPL"
10141 +         url="http://www.rpm.org/"
10142 +         distribution="Any distribution"
10143 +         vendor="rpm.org"
10144 +         packager="Jaco Greeff"
10145 +         packager-email="jaco@puxedo.org"
10146 +         buildroot="%{tmppath}/lvr-%{name}-build">
10147 +
10148 +       <macro name="test">value is this</macro>
10149 +
10150 +       <source name="rpm-4.0.4.tar.bz2"
10151 +                       num="0"
10152 +                       size="4296845"
10153 +                       md5="bb80a5d06a48623ecbe3f2d41cac15f9">
10154 +               <mirror path="ftp://ftp.rpm.org/"
10155 +                               description="Main RPM FTP site" />
10156 +               <mirror path="http://www.puxedo.org/downloads/source/"
10157 +                               description="puxedo.org source distribution"
10158 +                               country="za" />
10159 +       </source>
10160 +       <source name="expat-1.95.2.tar.bz2"
10161 +                       num="1"
10162 +                       size="156575"
10163 +                       md5="919c78ddaf7f319b7e07792309ae2f22">
10164 +               <mirror path="http://expat.sourceforge.net/"
10165 +                               description="SourceForge Mirror"
10166 +                               country="us" />
10167 +       </source>
10168 +
10169 +       <patch name="example-1.0-1.patch.bz2"
10170 +                  num="0"
10171 +                  size="3276"
10172 +                  md5="467c78cbdf75619b7e0abc2309ae2f11" />
10173 +
10174 +       <nosource name="nosource-sample-0.98.bz2"
10175 +                          num="33" />
10176 +
10177 +       <package group="System/Libraries">
10178 +               <buildrequires>
10179 +                       <package name="automake" />
10180 +                       <package name="autoconf" />
10181 +                       <package name="bash" />
10182 +                       <package name="binutils" />
10183 +                       <package name="gcc" />
10184 +                       <package name="glibc-devel" />
10185 +               </buildrequires>
10186 +               <requires>
10187 +                       <package name="gcc" cmp="ge" version="2.95" />
10188 +                       <package name="glibc" cmp="ge" version="2.2" />
10189 +                       <package name="libogg" />
10190 +               </requires>
10191 +               <provides>
10192 +                       <package name="%{name}" />
10193 +               </provides>
10194 +               <obsoletes>
10195 +                       <package name="old-example" />
10196 +               </obsoletes>
10197 +               <summary>This spec is just an example for some funny purpose.</summary>
10198 +               <summary lang="af">Hierdie is net 'n toets vir i18n in die opsomming</summary>
10199 +               <description>%{summary}</description>
10200 +               <description lang="af">Nog 'n toets, hierdie keer in die beskrywing</description>
10201 +                <post>
10202 +                       <script interpreter="/bin/sh">/sbin/ldconfig</script>
10203 +               </post>
10204 +               <postun>
10205 +                       <script>/sbin/ldconfig</script>
10206 +               </postun>
10207 +               <files>
10208 +                       <file user="root" group="root">/usr/lib/*.so*</file>
10209 +               </files>
10210 +       </package>
10211 +
10212 +       <package name="devel"
10213 +                        group="Development/Libraries">
10214 +               <requires>
10215 +                       <package name="%{name}" />
10216 +                       <package name="libtool" />
10217 +                       <package name="m4" />
10218 +               </requires>
10219 +               <summary>The libvorbis-devel package contains development headers.</summary>
10220 +               <description>%{summary}</description>
10221 +               <pre>
10222 +                       <script>some pre stuff under devel</script>
10223 +                       <script dir="/here/while/we/are/at/it">That ^^^ changed directory</script>
10224 +               </pre>
10225 +               <files user="root"
10226 +                               group="root">
10227 +                       <file>/usr/include/*.h</file>
10228 +                       <file group="rpm">/usr/lib/*.la</file>
10229 +                       <file user="rpm">/usr/share/aclocal/*</file>
10230 +                       <file mode="777">/usr/share/m4/*</file>
10231 +                       <file user="user" group="group" mode="444">/usr/share/man/*</file>
10232 +               </files>
10233 +       </package>
10234 +
10235 +       <package name="toys" sub="no" group="Application/Toys">
10236 +               <requires>
10237 +                       <package name="%{name}" />
10238 +               </requires>
10239 +               <obsoletes>
10240 +                       <package name="oldtoys" />
10241 +               </obsoletes>
10242 +               <summary>The toys package contains toys</summary>
10243 +               <description>%{summary}</description>
10244 +               <preun>
10245 +                       <script>some preun stuff under toys</script>
10246 +               </preun>
10247 +               <verify>
10248 +                       <script>Some verify stuff under toys</script>
10249 +               </verify>
10250 +               <files>
10251 +                       <file>/usr/doc/*</file>
10252 +               </files>
10253 +       </package>
10254 +
10255 +       <prep>
10256 +               <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10257 +               <script>rm -rf %{buildroot}</script>
10258 +               <setup path="%{name}-%{version}rc3" />
10259 +       </prep>
10260 +
10261 +       <build>
10262 +               <script>./configure --prefix=/usr</script>
10263 +               <script>make PROFILE=&apos;-Wall -W -pg -g -O2 -ffast-math -D_REENTRANT -fsigned-char -fno-inline -static' CFLAGS='-O2 -ffast-math -D_REENTRANT -fsigned-char -DUSE_MEMORY_H&apos;</script>
10264 +       </build>
10265 +
10266 +       <install>
10267 +               <script>make DESTDIR=%{buildroot} install</script>
10268 +       </install>
10269 +
10270 +       <clean>
10271 +               <script>rm -rf %{buildroot}</script>
10272 +               <script>rm -rf $RPM_BUILD_DIR/%{name}-%{version}rc3</script>
10273 +       </clean>
10274 +
10275 +       <changelog>
10276 +               <changes date="Wed Jun 05 2002"
10277 +                                author="Jaco Greeff"
10278 +                                author-email="jaco@puxedo.org"
10279 +                                version="1.0-06">
10280 +                       <change>Changed spec to make sure the output spec file can be understood by RPM</change>
10281 +                       <change>Added languages (description/summary) and a test in Afrikaans</change>
10282 +               </changes>
10283 +               <changes date="Mon Jun 03 2002"
10284 +                                author="Jaco Greeff"
10285 +                                author-email="jaco@puxedo.org"
10286 +                                version="1.0-05">
10287 +                       <change>Changed file attributes to mode, user and group</change>
10288 +               </changes>
10289 +               <changes date="Thu May 30 2002"
10290 +                                author="Jaco Greeff"
10291 +                                author-email="jaco@puxedo.org"
10292 +                                version="1.0-04">
10293 +                       <change>Added attribute &quot;interpreter&quot; to script</change>
10294 +               </changes>
10295 +               <changes date="Sat May 25 2002"
10296 +                                author="Jaco Greeff"
10297 +                                author-email="jaco@puxedo.org"
10298 +                                version="1.0-03">
10299 +                       <change>Moved &lt;files&gt; into &lt;package&gt; structure</change>
10300 +                       <change>Added &lt;nosource&gt; tag as example</change>
10301 +                       <change>Changed &lt;shell&gt; to &lt;script&gt;</change>
10302 +               </changes>
10303 +               <changes date="Sun May 19 2002"
10304 +                                author="Jaco Greeff"
10305 +                                author-email="jaco@puxedo.org"
10306 +                                version="1.0-02">
10307 +                       <change>Changed the formatting of the XML file to fit in with new implementation</change>
10308 +                       <change>Commented the spec to allow others to understand it as well</change>
10309 +               </changes>
10310 +               <changes date="Wed May 15 2002"
10311 +                                author="Jaco Greeff"
10312 +                                author-email="jaco@puxedo.org"
10313 +                                version="1.0-01">
10314 +                       <change>Converted spec file to .spec.xml file for illustrative purposes</change>
10315 +               </changes>
10316 +       </changelog>
10317 +</spec>
10318 Index: xmlspec/spec2xml.cpp
10319 ===================================================================
10320 RCS file: xmlspec/spec2xml.cpp
10321 diff -N xmlspec/spec2xml.cpp
10322 --- /dev/null   1 Jan 1970 00:00:00 -0000
10323 +++ rpm/xmlspec/spec2xml.cpp    28 Aug 2002 10:52:43 -0000      1.1.2.1
10324 @@ -0,0 +1,62 @@
10325 +// standard C++ includes
10326 +#include <fstream>
10327 +
10328 +// our includes
10329 +#include "XMLSpec.h"
10330 +
10331 +// rpm includes
10332 +#include <rpmbuild.h>
10333 +
10334 +// display some usage
10335 +int usage()
10336 +{
10337 +               printf("Usage: spec2xml input [output]\n");
10338 +               printf("Converts the input pkg.spec file to a pkg.spec.xml\n");
10339 +               printf("file for use in an rpmbuild command.\n\n");
10340 +               return 1;
10341 +}
10342 +
10343 +// program entry point
10344 +int main(int argc,
10345 +                char** argv)
10346 +{
10347 +       printf("\nspec2xml, version 0.01\n");
10348 +       if (argc != 2 && argc != 3) {
10349 +               usage();
10350 +               return 1;
10351 +       }
10352 +
10353 +       Spec pSpec = NULL;
10354 +       printf("Parsing RPM spec %s:\n", argv[1]);
10355 +       if (!parseSpec(&pSpec, argv[1], "/", "/var/tmp", 0, NULL, NULL, 1, 0)) {
10356 +               printf("\tOk, spec parsed.\n");
10357 +               printf("Creating XML structures:\n");
10358 +               XMLSpec* pXSpec = XMLSpec::structCreate(pSpec);
10359 +               if (pXSpec) {
10360 +                       printf("\tOk, structures created.\n");
10361 +                       if (argc == 3) {
10362 +                               printf("Writing XML to %s ... ", argv[2]);
10363 +                               ofstream fOut(argv[2]);
10364 +                               if (fOut.is_open()) {
10365 +                                       pXSpec->toXMLFile(fOut);
10366 +                                       fOut.close();
10367 +                                       printf("Ok.\n");
10368 +                               }
10369 +                               else {
10370 +                                       delete pSpec;
10371 +                                       printf("Failed.\n");
10372 +                                       return 2;
10373 +                               }
10374 +                       }
10375 +                       else if (argc == 2) {
10376 +                               pXSpec->toXMLFile(cout);
10377 +                       }
10378 +
10379 +                       delete pSpec;
10380 +                       return 0;
10381 +               }
10382 +       }
10383 +
10384 +       printf("\tFailed.\n");
10385 +       return 3;
10386 +}
10387 Index: xmlspec/xml2rpm.c
10388 ===================================================================
10389 RCS file: rpm/xmlspec/xml2rpm.c,v
10390 retrieving revision 1.2.2.1
10391 retrieving revision 1.2.2.2
10392 diff -u -u -r1.2.2.1 -r1.2.2.2
10393 --- rpm/xmlspec/xml2rpm.c       28 Aug 2002 10:52:43 -0000      1.2.2.1
10394 +++ rpm/xmlspec/xml2rpm.c       10 Oct 2002 22:47:59 -0000      1.2.2.2
10395 @@ -8,6 +8,10 @@
10396  #include "xml2rpm.h"
10397  #include "xmlstruct.h"
10398  
10399 +#ifdef XML_DEBUG
10400 +#include "header_internal.h"
10401 +#endif
10402 +
10403  // This is where our packaged scripts start (or the largest number
10404  // of the sources)
10405  int g_nMaxSourceNum = 511;
10406 @@ -304,8 +308,14 @@
10407                                 createRPMSource(pScript->m_szScript, g_nMaxSourceNum+1,
10408                                                 pSpec, RPMBUILD_ISSOURCE);
10409                         }
10410 -                       if (pScript->m_szEntry)
10411 -                               appendLineStringBuf(pSb, pScript->m_szEntry);
10412 +                       if (pScript->m_szEntry) {
10413 +                               // we do a newStrEx to make sure we expand all
10414 +                               // macros, as is done in the case of the files
10415 +                               // (done as part of the fileToStr call)
10416 +                               newStrEx(pScript->m_szEntry, (char**)(&szTmp));
10417 +                               appendLineStringBuf(pSb, szTmp);
10418 +                               freeStr(&(szTmp));
10419 +                       }
10420                         pScript = pScript->m_pNext;
10421                 }
10422         }
10423 @@ -335,6 +345,32 @@
10424                                pScripts->m_szInterpreter, 1);
10425  }
10426  
10427 +void handleProvObsConf(Header pHeader, t_structXMLRequire* pReqs, rpmsenseFlags fSense)
10428 +{
10429 +       t_structXMLRequire* pReq = NULL;
10430 +       int nFlags = 0;
10431 +       int i = 0;
10432 +       int nIndex = 0;
10433 +
10434 +       pReq = pReqs;
10435 +       while (pReq) {
10436 +               if (pReq->m_szName) {
10437 +                       nFlags = 0;
10438 +                       if (pReq->m_szCompare && pReq->m_szVersion) {
10439 +                               for (i = 0; sReqComp[i].m_szCmp; i++) {
10440 +                                       if (!strcasecmp(sReqComp[i].m_szCmp,
10441 +                                           pReq->m_szCompare)) {
10442 +                                               nFlags = (sReqComp[i].m_rpmCmp | RPMSENSE_ANY) & ~RPMSENSE_SENSEMASK;
10443 +                                       }
10444 +                               }
10445 +                       }
10446 +                       addReqProv(NULL, pHeader, fSense | nFlags,
10447 +                                  pReq->m_szName, pReq->m_szVersion, nIndex++);
10448 +               }
10449 +               pReq = pReq->m_pNext;
10450 +       }
10451 +}
10452 +
10453  void convertXMLPackage(const t_structXMLPackage* pXMLPkg,
10454                        const t_structXMLSpec* pXMLSpec,
10455                        Spec pSpec)
10456 @@ -364,6 +400,11 @@
10457         _free(szArch);
10458         _free(szOs);
10459  
10460 +       // do the provides, obsoletes, conflicts
10461 +       handleProvObsConf(pPkg->header, pXMLPkg->m_pProvides, RPMSENSE_PROVIDES);
10462 +       handleProvObsConf(pPkg->header, pXMLPkg->m_pObsoletes, RPMSENSE_OBSOLETES);
10463 +       handleProvObsConf(pPkg->header, pXMLPkg->m_pConflicts, RPMSENSE_CONFLICTS);
10464 +
10465         if (pXMLPkg->m_szName)
10466                 headerAddOrAppendEntry(pPkg->header, RPMTAG_NAME,
10467                                        RPM_STRING_TYPE, pXMLPkg->m_szName, 1);
10468 @@ -514,7 +555,7 @@
10469         pSpec->build = scriptsToStringBuf(pXMLSpec->m_pBuild, pSpec);
10470         pSpec->install = scriptsToStringBuf(pXMLSpec->m_pInstall, pSpec);
10471         pSpec->clean = scriptsToStringBuf(pXMLSpec->m_pClean, pSpec);
10472 -       
10473 +
10474         convertXMLPackage(pXMLSpec->m_pPackages, pXMLSpec, pSpec);
10475  
10476         initSourceHeader(pSpec);
10477 Index: xmlspec/xml2spec.cpp
10478 ===================================================================
10479 RCS file: xmlspec/xml2spec.cpp
10480 diff -N xmlspec/xml2spec.cpp
10481 --- /dev/null   1 Jan 1970 00:00:00 -0000
10482 +++ rpm/xmlspec/xml2spec.cpp    28 Aug 2002 10:52:43 -0000      1.2.2.1
10483 @@ -0,0 +1,52 @@
10484 +// standard C++ includes
10485 +#include <fstream>
10486 +
10487 +// our includes
10488 +#include "XMLParser.h"
10489 +#include "XMLSpec.h"
10490 +
10491 +// display some usage
10492 +int usage()
10493 +{
10494 +               printf("Usage: xml2spec input [output]\n");
10495 +               printf("Converts the input pkg.spec.xml file to a pkg.spec\n");
10496 +               printf("file for use in an rpmbuild command.\n\n");
10497 +               return 1;
10498 +}
10499 +
10500 +// program entry point
10501 +int main(int argc,
10502 +                char** argv)
10503 +{
10504 +       printf("\nxml2spec, version 0.01\n");
10505 +       if (argc != 2 && argc != 3) {
10506 +               usage();
10507 +               return 1;
10508 +       }
10509 +
10510 +       XMLSpec* pSpec = NULL;
10511 +       if (parseXMLSpec(argv[1], pSpec) == 0 && pSpec) {
10512 +               if (argc == 3) {
10513 +                       printf("Writing spec to %s ... ", argv[2]);
10514 +                       ofstream fOut(argv[2]);
10515 +                       if (fOut.is_open()) {
10516 +                               pSpec->toSpecFile(fOut);
10517 +                               fOut.close();
10518 +                               printf("Ok.\n");
10519 +                       }
10520 +                       else {
10521 +                               delete pSpec;
10522 +                               printf("Failed.\n");
10523 +                               return 2;
10524 +                       }
10525 +               }
10526 +               else if (argc == 2) {
10527 +                       pSpec->toSpecFile(cout);
10528 +               }
10529 +
10530 +               delete pSpec;
10531 +               return 0;
10532 +       }
10533 +
10534 +       return 3;
10535 +}
10536 Index: xmlspec/xmlparse.c
10537 ===================================================================
10538 RCS file: rpm/xmlspec/xmlparse.c,v
10539 retrieving revision 1.1.2.1
10540 retrieving revision 1.1.2.2
10541 diff -u -u -r1.1.2.1 -r1.1.2.2
10542 --- rpm/xmlspec/xmlparse.c      28 Aug 2002 10:52:43 -0000      1.1.2.1
10543 +++ rpm/xmlspec/xmlparse.c      10 Oct 2002 22:47:59 -0000      1.1.2.2
10544 @@ -43,7 +43,15 @@
10545                         addXMLMacro(pParse->m_pAttrs, &(pSpec->m_pMacros));
10546                         break;
10547                 case TAGVAL_SOURCE:
10548 -                       addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10549 +                       if (pSpec->m_pSources)
10550 +                               addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources));
10551 +                       else {
10552 +                               if ((addXMLSource(pParse->m_pAttrs, &(pSpec->m_pSources))) &&
10553 +                                   (pSpec->m_pSources->m_szDirectory)) {
10554 +                                       newStr(pSpec->m_pSources->m_szDirectory,
10555 +                                              (char**)&(pSpec->m_szBuildSubdir));
10556 +                               }
10557 +                       }
10558                         break;
10559                 case TAGVAL_PATCH:
10560                         addXMLSource(pParse->m_pAttrs, &(pSpec->m_pPatches));
10561 @@ -178,6 +186,12 @@
10562                                         appendStringBuf(pSb, szTmp);
10563                                         appendStringBuf(pSb, pSource->m_szName);
10564                                 }
10565 +                               else if (!strcasecmp(szTmp, "tgz")) {
10566 +                                       szTmp = NULL;
10567 +                                       newStrEx("%{_gzipbin} -dc ", &szTmp);
10568 +                                       appendStringBuf(pSb, szTmp);
10569 +                                       appendStringBuf(pSb, pSource->m_szName);
10570 +                               }
10571                                 else if (!strcasecmp(szTmp, "zip")) {
10572                                         szTmp = NULL;
10573                                         newStrEx("%{_unzipbin} ", &szTmp);
10574 @@ -265,8 +279,8 @@
10575                                         appendStringBuf(pSb, pSource->m_szName);
10576                                 }
10577                                 freeStr(&szTmp);
10578 -                               szTmp = malloc(strlen(" > patch -p1234567890 -s ")+strlen(pSource->m_szName)+1);
10579 -                               sprintf(szTmp, " | patch -p%d -s", nLevel);
10580 +                               szTmp = malloc(strlen(" > patch -pN1234567890 -s ")+strlen(pSource->m_szName)+1);
10581 +                               sprintf(szTmp, " | patch -Np%d -s", nLevel);
10582                                 appendStringBuf(pSb, szTmp);
10583                                 appendLineStringBuf(pSb, "");
10584                                 appendLineStringBuf(pSb, "STATUS=$?");
10585 @@ -290,6 +304,9 @@
10586                 case TAGVAL_SUMMARY:
10587                 case TAGVAL_DESCRIPTION:
10588                 case TAGVAL_REQUIRES:
10589 +               case TAGVAL_PROVIDES:
10590 +               case TAGVAL_OBSOLETES:
10591 +               case TAGVAL_CONFLICTS:
10592                         // we don't need to do anything
10593                         break;
10594                 default:
10595 @@ -315,6 +332,18 @@
10596                         pPkg = getLastXMLPackage(pSpec->m_pPackages);
10597                         addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pRequires));
10598                         break;
10599 +               case TAGVAL_PROVIDE:
10600 +                       pPkg = getLastXMLPackage(pSpec->m_pPackages);
10601 +                       addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pProvides));
10602 +                       break;
10603 +               case TAGVAL_OBSOLETE:
10604 +                       pPkg = getLastXMLPackage(pSpec->m_pPackages);
10605 +                       addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pObsoletes));
10606 +                       break;
10607 +               case TAGVAL_CONFLICT:
10608 +                       pPkg = getLastXMLPackage(pSpec->m_pPackages);
10609 +                       addXMLRequire(pParse->m_pAttrs, &(pPkg->m_pConflicts));
10610 +                       break;
10611                 case TAGVAL_CHANGE:
10612                         pChanges = getLastXMLChanges(pSpec->m_pChangelog);
10613                         addXMLChange(pParse->m_pAttrs, &(pChanges->m_pChanges));
10614 @@ -544,32 +573,26 @@
10615                int nLen)
10616  {
10617         t_structXMLParse* pParse = NULL;
10618 +       char* szVal = NULL;
10619         char* szTmp = NULL;
10620 -       char* szTmpValue = NULL;
10621 -       char* szPos = NULL;
10622  
10623         if ((pParse = (t_structXMLParse*)pData)) {
10624 -               szTmp = malloc(nLen+2);
10625 -               szTmp[nLen] = '\0';
10626 -               snprintf(szTmp, nLen+1, "%s", szValue);
10627 -               szPos = szTmp;
10628 -               while ((*szPos == ' ') ||
10629 -                      (*szPos == '\t') ||
10630 -                      (*szPos == '\r') ||
10631 -                      (*szPos == '\n'))
10632 -                       szPos++;
10633 -
10634 -               if (strlen(szPos)) {
10635 +               szVal = malloc(nLen+2);
10636 +               szVal[nLen] = '\0';
10637 +               snprintf(szVal, nLen+1, "%s", szValue);
10638 +               if (strlen(szVal)) {
10639 +                       while ((szTmp = strchr(szVal, '\t')))
10640 +                               *szTmp = ' ';
10641                         if (pParse->m_szValue) {
10642 -                               szTmpValue = malloc(strlen(szPos)+strlen(pParse->m_szValue)+1);
10643 -                               sprintf(szTmpValue, "%s%s", pParse->m_szValue, szPos);
10644 -                               newStr(szTmpValue, &(pParse->m_szValue));
10645 -                               free(szTmpValue);
10646 +                               szTmp = malloc(strlen(szVal)+strlen(pParse->m_szValue)+1);
10647 +                               sprintf(szTmp, "%s%s", pParse->m_szValue, szVal);
10648 +                               newStr(szTmp, &(pParse->m_szValue));
10649 +                               free(szTmp);
10650                         }
10651                         else
10652 -                               newStr(szPos, &(pParse->m_szValue));
10653 +                               newStr(szVal, &(pParse->m_szValue));
10654                 }
10655 -               free(szTmp);
10656 +               free(szVal);
10657         }
10658  }
10659  
10660 Index: xmlspec/xmlstruct.c
10661 ===================================================================
10662 RCS file: rpm/xmlspec/xmlstruct.c,v
10663 retrieving revision 1.2.2.1
10664 retrieving revision 1.2.2.2
10665 diff -u -u -r1.2.2.1 -r1.2.2.2
10666 --- rpm/xmlspec/xmlstruct.c     28 Aug 2002 10:52:43 -0000      1.2.2.1
10667 +++ rpm/xmlspec/xmlstruct.c     10 Oct 2002 22:47:59 -0000      1.2.2.2
10668 @@ -97,7 +97,7 @@
10669  {
10670         while (pAttr && (strcasecmp(szName, pAttr->m_szName) != 0))
10671                 pAttr = pAttr->m_pNext;
10672 -               
10673 +
10674         return pAttr;
10675  }
10676  
10677 @@ -236,7 +236,7 @@
10678                         attrSetInt(pAttr, "size", &(pSource->m_nSize));
10679                         attrSetStr(pAttr, "md5", &(pSource->m_szMD5));
10680                         attrSetStr(pAttr, "directory", &(pSource->m_szDirectory));
10681 -                       attrSetInt(pAttr, "number", &(pSource->m_nNum));
10682 +                       attrSetInt(pAttr, "id", &(pSource->m_nNum));
10683                 } while ((pAttr = pAttr->m_pNext));
10684         }
10685  
10686 @@ -365,6 +365,8 @@
10687  
10688         if ((pScript = malloc(sizeof(t_structXMLScript)))) {
10689                 pScript->m_szInterpreter = NULL;
10690 +               pScript->m_szArch = NULL;
10691 +               pScript->m_szOS = NULL;
10692                 pScript->m_szScript = NULL;
10693                 pScript->m_szEntry = NULL;
10694                 pScript->m_pNext = NULL;
10695 @@ -373,6 +375,10 @@
10696                         do {
10697                                 attrSetStr(pAttr, "interpreter",
10698                                            &(pScript->m_szInterpreter));
10699 +                               attrSetStr(pAttr, "arch",
10700 +                                          &(pScript->m_szArch));
10701 +                               attrSetStr(pAttr, "os",
10702 +                                          &(pScript->m_szOS));
10703                                 attrSetStr(pAttr, "script",
10704                                            &(pScript->m_szScript));
10705                         } while ((pAttr = pAttr->m_pNext));
10706 @@ -386,6 +392,8 @@
10707  {
10708         if (*ppScript) {
10709                 freeStr(&((*ppScript)->m_szInterpreter));
10710 +               freeStr(&((*ppScript)->m_szArch));
10711 +               freeStr(&((*ppScript)->m_szOS));
10712                 freeStr(&((*ppScript)->m_szScript));
10713                 freeStr(&((*ppScript)->m_szEntry));
10714                 freeXMLScript(&((*ppScript)->m_pNext));
10715 @@ -485,6 +493,59 @@
10716         return 0;
10717  }
10718  
10719 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs)
10720 +{
10721 +       t_structI18NStr* pStr = NULL;
10722 +       t_structXMLAttr* pAttr = NULL;
10723 +
10724 +       if ((pStr = malloc(sizeof(t_structI18NStr)))) {
10725 +               pStr->m_szLang = NULL;
10726 +               pStr->m_szText = NULL;
10727 +               pStr->m_pNext = NULL;
10728 +
10729 +               pAttr = (t_structXMLAttr*)pAttrs;
10730 +               do {
10731 +                       attrSetStr(pAttr, "lang", &(pStr->m_szLang));
10732 +               } while ((pAttr = pAttr->m_pNext));
10733 +       }
10734 +
10735 +       return pStr;
10736 +}
10737 +
10738 +int freeI18NStr(t_structI18NStr** ppStr)
10739 +{
10740 +       if (*ppStr) {
10741 +               freeStr(&((*ppStr)->m_szLang));
10742 +               freeStr(&((*ppStr)->m_szText));
10743 +               freeI18NStr(&((*ppStr)->m_pNext));
10744 +               free(*ppStr);
10745 +       }
10746 +       *ppStr = NULL;
10747 +
10748 +       return 0;
10749 +}
10750 +
10751 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10752 +                           t_structI18NStr** ppStr)
10753 +{
10754 +       t_structI18NStr* pStr = NULL;
10755 +
10756 +       if ((pStr = getLastI18NStr(*ppStr)))
10757 +               pStr = (pStr->m_pNext = newI18NStr(pAttrs));
10758 +       else
10759 +               pStr = (*ppStr = newI18NStr(pAttrs));
10760 +
10761 +       return pStr;
10762 +}
10763 +
10764 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr)
10765 +{
10766 +       while (pStr && (pStr->m_pNext))
10767 +               pStr = pStr->m_pNext;
10768 +
10769 +       return pStr;
10770 +}
10771 +
10772  t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs)
10773  {
10774         t_structXMLPackage* pPackage = NULL;
10775 @@ -492,6 +553,7 @@
10776  
10777         if ((pPackage = malloc(sizeof(t_structXMLPackage)))) {
10778                 pPackage->m_szName = NULL;
10779 +               pPackage->m_szVersion = NULL;
10780                 pPackage->m_szGroup = NULL;
10781                 pPackage->m_szSummary = NULL;
10782                 pPackage->m_szDescription = NULL;
10783 @@ -507,15 +569,21 @@
10784                 pPackage->m_pRequires = NULL;
10785                 pPackage->m_pSuggests = NULL;
10786                 pPackage->m_pObsoletes = NULL;
10787 +               pPackage->m_pConflicts = NULL;
10788                 pPackage->m_pProvides = NULL;
10789                 pPackage->m_pNext = NULL;
10790  
10791                 pAttr = (t_structXMLAttr*)pAttrs;
10792                 do {
10793                         attrSetStr(pAttr, "name", &(pPackage->m_szName));
10794 +                       attrSetStr(pAttr, "version", &(pPackage->m_szVersion));
10795                         attrSetStr(pAttr, "group", &(pPackage->m_szGroup));
10796                         attrSetBool(pAttr, "autorequire", &(pPackage->m_nAutoRequire));
10797 +                       attrSetBool(pAttr, "autoreq", &(pPackage->m_nAutoRequire));
10798                         attrSetBool(pAttr, "autoprovide", &(pPackage->m_nAutoProvide));
10799 +                       attrSetBool(pAttr, "autoprov", &(pPackage->m_nAutoProvide));
10800 +                       attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoProvide));
10801 +                       attrSetBool(pAttr, "autoreqprov", &(pPackage->m_nAutoRequire));
10802                         attrSetBool(pAttr, "autosuggest", &(pPackage->m_nAutoSuggest));
10803                 } while ((pAttr = pAttr->m_pNext));
10804         }
10805 @@ -527,6 +595,7 @@
10806  {
10807         if (*ppPackage) {
10808                 freeStr(&((*ppPackage)->m_szName));
10809 +               freeStr(&((*ppPackage)->m_szVersion));
10810                 freeStr(&((*ppPackage)->m_szGroup));
10811                 freeStr(&((*ppPackage)->m_szSummary));
10812                 freeStr(&((*ppPackage)->m_szDescription));
10813 @@ -539,6 +608,7 @@
10814                 freeXMLRequire(&((*ppPackage)->m_pRequires));
10815                 freeXMLRequire(&((*ppPackage)->m_pSuggests));
10816                 freeXMLRequire(&((*ppPackage)->m_pObsoletes));
10817 +               freeXMLRequire(&((*ppPackage)->m_pConflicts));
10818                 freeXMLRequire(&((*ppPackage)->m_pProvides));
10819                 freeXMLPackage(&((*ppPackage)->m_pNext));
10820                 free(*ppPackage);
10821 Index: xmlspec/xmlstruct.h
10822 ===================================================================
10823 RCS file: rpm/xmlspec/xmlstruct.h,v
10824 retrieving revision 1.1.2.1
10825 retrieving revision 1.1.2.2
10826 diff -u -u -r1.1.2.1 -r1.1.2.2
10827 --- rpm/xmlspec/xmlstruct.h     28 Aug 2002 10:52:43 -0000      1.1.2.1
10828 +++ rpm/xmlspec/xmlstruct.h     10 Oct 2002 22:47:59 -0000      1.1.2.2
10829 @@ -52,6 +52,8 @@
10830  typedef struct structXMLScript
10831  {
10832         char*                   m_szInterpreter;
10833 +       char*                   m_szArch;
10834 +       char*                   m_szOS;
10835         char*                   m_szScript;
10836         char*                   m_szEntry;
10837         struct structXMLScript* m_pNext;
10838 @@ -71,9 +73,17 @@
10839         char* m_szGID;
10840  } t_structXMLFiles;
10841  
10842 +typedef struct structI18NStr
10843 +{
10844 +       char*                 m_szLang;
10845 +       char*                 m_szText;
10846 +       struct structI18NStr* m_pNext;
10847 +} t_structI18NStr;
10848 +
10849  typedef struct structXMLPackage
10850  {
10851         char*                    m_szName;
10852 +       char*                    m_szVersion;
10853         char*                    m_szGroup;
10854         char*                    m_szSummary;
10855         char*                    m_szDescription;
10856 @@ -89,6 +99,7 @@
10857         struct structXMLRequire* m_pRequires;
10858         struct structXMLRequire* m_pSuggests;
10859         struct structXMLRequire* m_pObsoletes;
10860 +       struct structXMLRequire* m_pConflicts;
10861         struct structXMLRequire* m_pProvides;
10862         struct structXMLPackage* m_pNext;
10863  } t_structXMLPackage;
10864 @@ -200,6 +211,12 @@
10865  
10866  t_structXMLFiles* newXMLFiles(const t_structXMLAttr* pAttrs);
10867  int freeXMLFiles(t_structXMLFiles** ppFiles);
10868 +
10869 +t_structI18NStr* newI18NStr(const t_structXMLAttr* pAttrs);
10870 +int freeI18NStr(t_structI18NStr** ppStr);
10871 +t_structI18NStr* addI18NStr(const t_structXMLAttr* pAttrs,
10872 +                           t_structI18NStr** ppStr);
10873 +t_structI18NStr* getLastI18NStr(t_structI18NStr* pStr);
10874  
10875  t_structXMLPackage* newXMLPackage(const t_structXMLAttr* pAttrs);
10876  int freeXMLPackage(t_structXMLPackage** ppPackage);
10877 Index: xmlspec/xmlverify.c
10878 ===================================================================
10879 RCS file: rpm/xmlspec/xmlverify.c,v
10880 retrieving revision 1.1.2.1
10881 retrieving revision 1.1.2.2
10882 diff -u -u -r1.1.2.1 -r1.1.2.2
10883 --- rpm/xmlspec/xmlverify.c     28 Aug 2002 10:52:43 -0000      1.1.2.1
10884 +++ rpm/xmlspec/xmlverify.c     10 Oct 2002 22:47:59 -0000      1.1.2.2
10885 @@ -58,7 +58,7 @@
10886                         {"size",           ATTRTYPE_NUMERIC, 0},
10887                         {"md5",            ATTRTYPE_MD5,     0},
10888                         {"path",           ATTRTYPE_ANY,     0},
10889 -                       {"number",         ATTRTYPE_NUMERIC, 0},
10890 +                       {"id",             ATTRTYPE_NUMERIC, 0},
10891                         {NULL,             ATTRTYPE_ANY,     1}
10892                 }
10893         },
10894 @@ -89,7 +89,7 @@
10895                         {"size",           ATTRTYPE_NUMERIC, 0},
10896                         {"md5",            ATTRTYPE_MD5,     0},
10897                         {"path",           ATTRTYPE_ANY,     0},
10898 -                       {"number",         ATTRTYPE_NUMERIC, 0},
10899 +                       {"id",             ATTRTYPE_NUMERIC, 0},
10900                         {NULL,             ATTRTYPE_ANY,     1}
10901                 }
10902         },
10903 @@ -165,6 +165,7 @@
10904                 },
10905                 {
10906                         {"name",           ATTRTYPE_ANY,     0},
10907 +                       {"version",        ATTRTYPE_ANY,     0},
10908                         {"group",          ATTRTYPE_ANY,     1},
10909                         {"autoreqprov",    ATTRTYPE_BOOL,    0},
10910                         {"autoprov",       ATTRTYPE_BOOL,    0},
10911 @@ -219,6 +220,7 @@
10912                 },
10913                 {
10914                         {"name",           ATTRTYPE_ANY,     1},
10915 +                       {"version",        ATTRTYPE_ANY,     0},
10916                         {NULL,             ATTRTYPE_ANY,     1}
10917                 }
10918         },
10919 @@ -243,6 +245,34 @@
10920                 },
10921                 {
10922                         {"name",           ATTRTYPE_ANY,     1},
10923 +                       {"version",        ATTRTYPE_ANY,     0},
10924 +                       {"cmp",            ATTRTYPE_CMP,     0},
10925 +                       {NULL,             ATTRTYPE_ANY,     1}
10926 +               }
10927 +       },
10928 +       {
10929 +               "conflicts", TAGVAL_CONFLICTS, 2,
10930 +               {
10931 +                       TAGVAL_SPEC,
10932 +                       TAGVAL_PACKAGE,
10933 +                       TAGVAL_LAST
10934 +               },
10935 +               {
10936 +                       {NULL,             ATTRTYPE_ANY,     1}
10937 +               }
10938 +       },
10939 +       {
10940 +               "conflict", TAGVAL_CONFLICT, 3,
10941 +               {
10942 +                       TAGVAL_SPEC,
10943 +                       TAGVAL_PACKAGE,
10944 +                       TAGVAL_CONFLICTS,
10945 +                       TAGVAL_LAST
10946 +               },
10947 +               {
10948 +                       {"name",           ATTRTYPE_ANY,     1},
10949 +                       {"version",        ATTRTYPE_ANY,     0},
10950 +                       {"cmp",            ATTRTYPE_CMP,     0},
10951                         {NULL,             ATTRTYPE_ANY,     1}
10952                 }
10953         },
10954 @@ -280,6 +310,7 @@
10955                         TAGVAL_LAST
10956                 },
10957                 {
10958 +                       {"lang",           ATTRTYPE_ANY,     0},
10959                         {NULL,             ATTRTYPE_ANY,     1}
10960                 }
10961         },
10962 @@ -291,6 +322,7 @@
10963                         TAGVAL_LAST
10964                 },
10965                 {
10966 +                       {"lang",           ATTRTYPE_ANY,     0},
10967                         {NULL,             ATTRTYPE_ANY,     1}
10968                 }
10969         },
10970 @@ -317,6 +349,8 @@
10971                 },
10972                 {
10973                         {"interpreter",    ATTRTYPE_ANY,     0},
10974 +                       {"arch",           ATTRTYPE_ANY,     0},
10975 +                       {"os",             ATTRTYPE_ANY,     0},
10976                         {"script",         ATTRTYPE_SCRIPT,  0},
10977                         {NULL,             ATTRTYPE_ANY,     1}
10978                 }
10979 @@ -344,6 +378,8 @@
10980                 },
10981                 {
10982                         {"interpreter",    ATTRTYPE_ANY,     0},
10983 +                       {"arch",           ATTRTYPE_ANY,     0},
10984 +                       {"os",             ATTRTYPE_ANY,     0},
10985                         {"script",         ATTRTYPE_SCRIPT,  0},
10986                         {NULL,             ATTRTYPE_ANY,     1}
10987                 }
10988 @@ -371,6 +407,8 @@
10989                 },
10990                 {
10991                         {"interpreter",    ATTRTYPE_ANY,     0},
10992 +                       {"arch",           ATTRTYPE_ANY,     0},
10993 +                       {"os",             ATTRTYPE_ANY,     0},
10994                         {"script",         ATTRTYPE_SCRIPT,  0},
10995                         {NULL,             ATTRTYPE_ANY,     1}
10996                 }
10997 @@ -398,11 +436,14 @@
10998                 },
10999                 {
11000                         {"interpreter",    ATTRTYPE_ANY,     0},
11001 +                       {"arch",           ATTRTYPE_ANY,     0},
11002 +                       {"os",             ATTRTYPE_ANY,     0},
11003                         {"script",         ATTRTYPE_SCRIPT,  0},
11004                         {NULL,             ATTRTYPE_ANY,     1}
11005                 }
11006         },
11007 -       {"verify", TAGVAL_VERIFY, 2,
11008 +       {
11009 +               "verify", TAGVAL_VERIFY, 2,
11010                 {
11011                         TAGVAL_SPEC,
11012                         TAGVAL_PACKAGE,
11013 @@ -424,6 +465,8 @@
11014                 },
11015                 {
11016                         {"interpreter",    ATTRTYPE_ANY,     0},
11017 +                       {"arch",           ATTRTYPE_ANY,     0},
11018 +                       {"os",             ATTRTYPE_ANY,     0},
11019                         {"script",         ATTRTYPE_SCRIPT,  0},
11020                         {NULL,             ATTRTYPE_ANY,     1}
11021                 }
11022 @@ -463,6 +506,8 @@
11023                 },
11024                 {
11025                         {"interpreter",    ATTRTYPE_ANY,     0},
11026 +                       {"arch",           ATTRTYPE_ANY,     0},
11027 +                       {"os",             ATTRTYPE_ANY,     0},
11028                         {"script",         ATTRTYPE_SCRIPT,  0},
11029                         {NULL,             ATTRTYPE_ANY,     1}
11030                 }
11031 @@ -476,6 +521,8 @@
11032                 },
11033                 {
11034                         {"source",         ATTRTYPE_NUMERIC, 0},
11035 +                       {"arch",           ATTRTYPE_ANY,     0},
11036 +                       {"os",             ATTRTYPE_ANY,     0},
11037                         {"path",           ATTRTYPE_ANY,     0},
11038                         {NULL,             ATTRTYPE_ANY,     1}
11039                 }
11040 @@ -489,6 +536,8 @@
11041                 },
11042                 {
11043                         {"patch",          ATTRTYPE_NUMERIC, 0},
11044 +                       {"arch",           ATTRTYPE_ANY,     0},
11045 +                       {"os",             ATTRTYPE_ANY,     0},
11046                         {"level",          ATTRTYPE_NUMERIC, 0},
11047                         {"path",           ATTRTYPE_ANY,     0},
11048                         {NULL,             ATTRTYPE_ANY,     1}
11049 @@ -515,6 +564,8 @@
11050                 },
11051                 {
11052                         {"interpreter",    ATTRTYPE_ANY,     0},
11053 +                       {"arch",           ATTRTYPE_ANY,     0},
11054 +                       {"os",             ATTRTYPE_ANY,     0},
11055                         {"script",         ATTRTYPE_SCRIPT,  0},
11056                         {NULL,             ATTRTYPE_ANY,     1}
11057                 }
11058 @@ -540,6 +591,8 @@
11059                 },
11060                 {
11061                         {"interpreter",    ATTRTYPE_ANY,     0},
11062 +                       {"arch",           ATTRTYPE_ANY,     0},
11063 +                       {"os",             ATTRTYPE_ANY,     0},
11064                         {"script",         ATTRTYPE_SCRIPT,  0},
11065                         {NULL,             ATTRTYPE_ANY,     1}
11066                 }
11067 @@ -565,6 +618,8 @@
11068                 },
11069                 {
11070                         {"interpreter",    ATTRTYPE_ANY,     0},
11071 +                       {"arch",           ATTRTYPE_ANY,     0},
11072 +                       {"os",             ATTRTYPE_ANY,     0},
11073                         {"script",         ATTRTYPE_SCRIPT,  0},
11074                         {NULL,             ATTRTYPE_ANY,     1}
11075                 }
11076 Index: xmlspec/xmlverify.h
11077 ===================================================================
11078 RCS file: rpm/xmlspec/xmlverify.h,v
11079 retrieving revision 1.1.2.1
11080 retrieving revision 1.1.2.2
11081 diff -u -u -r1.1.2.1 -r1.1.2.2
11082 --- rpm/xmlspec/xmlverify.h     28 Aug 2002 10:52:43 -0000      1.1.2.1
11083 +++ rpm/xmlspec/xmlverify.h     10 Oct 2002 22:47:59 -0000      1.1.2.2
11084 @@ -22,6 +22,8 @@
11085         TAGVAL_REQUIRE,
11086         TAGVAL_OBSOLETES,
11087         TAGVAL_OBSOLETE,
11088 +       TAGVAL_CONFLICTS,
11089 +       TAGVAL_CONFLICT,
11090         TAGVAL_SUGGESTS,
11091         TAGVAL_SUGGEST,
11092         TAGVAL_SUMMARY,
This page took 1.725745 seconds and 4 git commands to generate.