6 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
7 * Copyright (C) 2009, 2010, MinGW Project
10 * Implementation for the non-inherited components of the pkgXmlNode
11 * class, as declared in file "pkgdesc.h"; fundamentally, these are
12 * the accessors for package "tarname" properties, as specified in
13 * XML nodes identified as "release" elements.
16 * This is free software. Permission is granted to copy, modify and
17 * redistribute this software, under the provisions of the GNU General
18 * Public License, Version 3, (or, at your option, any later version),
19 * as published by the Free Software Foundation; see the file COPYING
20 * for licensing details.
22 * Note, in particular, that this software is provided "as is", in the
23 * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
24 * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
25 * PARTICULAR PURPOSE. Under no circumstances will the author, or the
26 * MinGW Project, accept liability for any damages, however caused,
27 * arising from the use of this software.
38 const char *pkgArchiveName( pkgXmlNode *rel, const char *tag, unsigned opt )
40 /* Local helper to establish actual release file names...
41 * applicable only to XML "release" elements.
43 if( ! rel->IsElementOfType( "release" ) )
45 dmh_control( DMH_BEGIN_DIGEST );
46 dmh_notify( DMH_ERROR, "internal package specification error\n" );
47 dmh_notify( DMH_ERROR, "can't get 'tarname' for non-release element\n" );
48 dmh_notify( DMH_ERROR, "please report this to the package maintainer\n" );
49 dmh_control( DMH_END_DIGEST );
53 /* Given a package release specification...
54 * determine the archive name for the tarball to be processed; this
55 * is retrieved from a child XML element with name specified by "tag";
56 * by default, if "opt" is non-zero, it is the canonical "tarname"
57 * assigned to the release element itself, unless an alternative
58 * specification is provided; if "opt" is zero, no default is
59 * assumed, and the return value is NULL if no alternative
60 * specification is provided.
63 pkgXmlNode *dl = rel->GetChildren();
66 /* Visit all children of the release specification element,
67 * checking for the presence of an expected specification...
69 if( dl->IsElementOfType( tag ) )
71 /* Found one; ensure it is the only one...
75 * ...else emit a warning, and ignore this one...
77 dmh_notify( DMH_WARNING, "%s: archive name reassignment ignored\n",
78 rel->GetPropVal( tarname_key, "<unknown>" )
81 /* ...ok; this is the first "tag" specification,
82 * accept it as the non-default source of the release's
87 /* Continue, until all children have been visited.
91 /* "rel" now points to the XML element having the appropriate
92 * "tarname" specification; return a pointer to it's value.
94 return (opt || matched) ? rel->GetPropVal( tarname_key, NULL ) : NULL;
97 const char *pkgXmlNode::SourceArchiveName()
99 /* Applicable only for XML nodes designated as "release".
101 * Retrieve the source tarball name, if specified, from the
102 * "tarname" property of the contained "source" element, within
103 * an XML node designated as a "release" element.
105 * Returns a pointer to the text of the "tarname" property of the
106 * contained "source" element, or NULL if the containing node does
107 * not represent a "release", or if it does not have a contained
108 * "source" element specifying a "tarname" property.
110 return pkgArchiveName( this, source_key, 0 );
113 const char *pkgXmlNode::ArchiveName()
115 /* Applicable only for XML nodes designated as "release".
117 * Retrieve the actual tarball name, if specified, from the
118 * "tarname" property of a contained "download" element, within
119 * an XML node designated as a "release" element.
121 * Returns a pointer to the text of the "tarname" property of the
122 * contained "download" element, or to the "tarname" property of
123 * the containing "release" element, if it does not contain an
124 * alternative specification within a "download" element; if
125 * unresolved to either of these, returns NULL.
127 return pkgArchiveName( this, download_key, 1 );
130 /* $RCSfile$: end of file */