Lines Matching refs:tag

42  *   smlAddTag - Add new tag object into existing tag object
43 * smlConvertStringToTag - Convert string into tag object
44 * smlConvertTagToString - Convert a tag object into a string
46 * smlDbgPrintTag - Print a representation of an XML tag if debugging
47 * smlDelParam - Delete a parameter from a tag object
48 * smlDelTag - Delete element from tag object
49 * smlDup - Duplicate a tag object
50 * smlFindAndDelTag - Delete a tag if found in tag object
51 * smlFreeTag - Free a tag object and all its contents when no
54 * smlGetElementName - Return a tag's element name
55 * smlGetNumParams - Get number of parameters set in tag
56 * smlGetParam - Get a parameter from a tag
57 * smlGetParamF - Get a formatted parameter from a tag
58 * smlGetParamByTag - Get a parameter by tag and index
59 * smlGetParamByTagParam Get parameter given tag name, index,
61 * smlGetParamName - Get the name of a tag parameter given its index
62 * smlGetParam_r - Get a parameter from a tag into fixed buffer
63 * smlGetTag - Get an element from a tag
65 * smlGetTagByTagParam - Get element given tag name, index, parameter name,
68 * smlLoadTagFromFile - Load a file into a tag object
69 * smlNewTag - Create a new (empty) tag object
72 * smlPrintTag - Print a simple XML representation of a tag to stderr
73 * smlReadOneTag - read one complete tag from a datastream
74 * smlReadTagFromDs - read tag object from datastream
75 * smlSetFileStatInfo - encode file status information into tag
77 * smlSetParam - Set parameter value in tag object
78 * smlSetParamF - Set parameter value in tag object
79 * smlWriteTagToDs - Write an XML representation of a tag to a datastream
80 * smlWriteTagToFd - Write an XML representation of a tag to an open file
82 * smlWriteTagToFile - Write an XML representation of a tag to a file
128 SML_TAG *tag);
132 static void _smlFreeTag(SML_TAG *tag);
141 * component, such as a tag name, tag *value*, etc. The code should
156 * Description: Add new tag object into existing tag object
158 * Pointer to handle to the tag object to update
159 * The handle may be updated if the tag object is
162 * Add the tag after the "n"th tag in the tag object
163 * -1 == add the tag to the end of the tag object
164 * 0 == add the tag to the beginning of the tag object
166 * The tag to add to 'tag'
170 * object to the tag that was just added
171 * Errors: If the tag object cannot be updated, the process exits
177 SML_TAG *tag;
184 /* if no tag to update specified, ignore request */
186 tag = *r_tag;
187 if (tag == SML_TAG__NULL) {
188 return (tag);
194 a_subTag->name, tag->name);
196 /* if index is out of range or -1, append to tag object */
198 if ((a_index > tag->tags_num) || (a_index == -1)) {
199 a_index = tag->tags_num;
202 /* bump number of tags in tag object */
204 tag->tags_num++;
206 /* expand tag object to hold new subtag */
208 tag->tags = (SML_TAG *)realloc(tag->tags,
209 sizeof (SML_TAG) * tag->tags_num);
211 /* if not appending, adjust tag object to hold new subtag */
213 if (a_index < (tag->tags_num - 1)) {
214 (void) memmove(&(tag->tags[a_index + 1]), &(tag->tags[a_index]),
215 sizeof (SML_TAG) * (tag->tags_num - a_index - 1));
218 /* copy new subtag into correct location in tag object */
220 (void) memcpy(&(tag->tags[a_index]), a_subTag,
223 return (&(tag->tags[a_index]));
228 * Description: Delete element from tag object
229 * Arguments: tag - [RO, *RW] - (SML_TAG *)
230 * The tag object to update
232 * Element to be removed from the tag object
234 * The sub_tag is removed from the tag object
235 * NOTE: The sub-tag and all elements contained within it are deallocated
236 * the sub-tag is no longer valid when this method returns
240 smlDelTag(SML_TAG *tag, SML_TAG *sub_tag)
248 /* if no tag to update specified, ignore request */
250 if (tag == SML_TAG__NULL) {
257 sub_tag->name, tag->name);
259 /* if tag object is empty, ignore request */
261 if (tag->tags_num == 0) {
265 /* determine index into tag object of element to remove */
266 for (index = 0; index < tag->tags_num; index++) {
267 if (sub_tag == &tag->tags[index]) {
272 /* if element not found in tag, ignore request */
274 if (index >= tag->tags_num) {
283 * if not removing last element, collapse tag object removing
287 if (index < (tag->tags_num - 1)) {
288 (void) memmove(&(tag->tags[index]), &(tag->tags[index + 1]),
289 sizeof (SML_TAG) *(tag->tags_num - index - 1));
292 /* one less tag object in tag */
294 tag->tags_num --;
297 * If only one tag left, then delete entire tag structure
301 if (tag->tags_num > 0) {
302 /* realloc removing last element in tag object */
304 tag->tags = (SML_TAG *)realloc(tag->tags,
305 sizeof (SML_TAG) *tag->tags_num);
307 tag->tags = SML_TAG__NULL;
313 * Description: Free a tag object and all its contents when no longer needed
314 * Arguments: tag - [RO, *RW] - (SML_TAG *)
315 * The tag object to be deleted
317 * The tag object and all its contents are deallocated
321 smlFreeTag(SML_TAG *tag)
325 assert(SML_TAG__ISVALID(tag));
329 if (tag->name != (char *)NULL) {
331 (unsigned long)tag, tag->name);
334 /* free the tag object contents */
336 _smlFreeTag(tag);
338 /* free the tag object handle */
340 bzero(tag, sizeof (SML_TAG));
341 free(tag);
346 * Synopsis: Get number of parameters set in tag
347 * Description: Return the number of parameters set in a tag
349 * The tag object to obtain the # params from
351 * Number of parameters set in tag
364 * Description: Get a parameter from a tag into a buffer of fixed size
365 * Arguments: tag - [RO, *RO] - (SML_TAG *)
366 * The tag object to obtain the parameter from
377 smlGetParam_r(SML_TAG *tag, char *name, char *buf, int bufLen)
395 /* if no tag specified, return NULL */
397 if (tag == SML_TAG__NULL) {
401 /* if no parameters in tag, return NULL */
403 if (tag->params == NULL) {
410 name, tag->name);
412 /* scan tag object looking for specified parameter */
414 for (k = 0; k < tag->params_num; k++) {
415 assert(tag->params[k].name != (char *)NULL);
416 assert(tag->params[k].value != (char *)NULL);
417 if (streq(tag->params[k].name, name)) {
420 tag->name, name, tag->params[k].value);
421 (void) strncpy(buf, tag->params[k].value, bufLen-1);
431 * Description: Get a parameter from a tag
432 * Arguments: tag - [RO, *RO] - (SML_TAG *)
433 * The tag object to obtain the parameter from
445 smlGetParam(SML_TAG *tag, char *name)
458 /* if no tag specified, return NULL */
460 if (tag == SML_TAG__NULL) {
464 /* if no parameters in tag, return NULL */
466 if (tag->params == NULL) {
473 name, tag->name);
475 /* scan tag object looking for specified parameter */
477 for (k = 0; k < tag->params_num; k++) {
478 assert(tag->params[k].name != (char *)NULL);
479 assert(tag->params[k].value != (char *)NULL);
480 if (streq(tag->params[k].name, name)) {
483 tag->name, name, tag->params[k].value);
484 return (strdup(tag->params[k].value));
495 * Description: Get the name of a tag parameter given its index
496 * Arguments: tag - [RO, *RO] - (SML_TAG *)
497 * The tag object to obtain the parameter name from
502 * == (char *)NULL if no such parameter exists in tag
509 smlGetParamName(SML_TAG *tag, int index)
511 /* if no tag specified, return NULL */
513 if (tag == NULL) {
520 tag->name, index);
522 /* if no parameters in tag, return NULL */
524 if (tag->params == NULL) {
530 if (index >= tag->params_num) {
536 assert(tag->params[index].name != (char *)NULL);
537 assert(tag->params[index].value != (char *)NULL);
540 tag->name, index, tag->params[index].name);
542 return (strdup(tag->params[index].name));
547 * Synopsis: Get a parameter value from a tag by name and index
548 * Description: Call to look for a parameter value from a tag with
550 * Arguments: tag - [RO, *RO] - (SML_TAG *)
551 * The tag object to obtain the parameter
553 * Index of nth tag by name to look for
555 * Name of tag to look for
564 smlGetParamByTag(SML_TAG *tag, int index,
571 assert(SML_TAG__ISVALID(tag));
582 /* find the requested tag by name and index */
584 rtag = smlGetTagByName(tag, index, tagName);
594 * Synopsis: Get element given tag name, index, parameter name, and value
595 * Description: Call to look for a tag with a given nae, that has a parameter
597 * Arguments: tag - [RO, *RO] - (SML_TAG *)
598 * The tag object to obtain the element from
614 smlGetTagByTagParam(SML_TAG *tag, int index,
617 int ti; /* tag structure index */
621 assert(SML_TAG__ISVALID(tag));
629 /* if tag has no elements, return NULL */
631 if (tag->tags == NULL) {
637 * -> search tag structure; for each tag with element == "tagName":
638 * -> search tag parameters; if parameter name == "paramName"
639 * -> if parameter value != "paramValue"; to next tag
641 * -> if not the "index"th paramValue found; to next tag
642 * -> return tag found
645 for (ti = 0; ti < tag->tags_num; ti++) {
648 /* if tag element does not match, go on to next tag */
650 if (strcmp(tag->tags[ti].name, tagName)) {
656 for (pi = 0; pi < tag->tags[ti].params_num; pi++) {
657 assert(tag->tags[ti].params[pi].name != (char *)NULL);
658 assert(tag->tags[ti].params[pi].value != (char *)NULL);
662 if (strcmp(tag->tags[ti].params[pi].name, paramName)) {
666 /* if parameter value doesnt match to next tag */
668 if (strcmp(tag->tags[ti].params[pi].value,
675 * -> if this is not the 'index'th one, go to next tag
684 * -> return the tag found
687 return (&tag->tags[ti]);
699 * Synopsis: Get parameter given tag name, index, parameter name, and value
700 * Description: Call to return the value of a parameter from a tag of a
703 * Arguments: tag - [RO, *RO] - (SML_TAG *)
704 * The tag object to obtain the element from
723 smlGetParamByTagParam(SML_TAG *tag, int index,
726 int ti; /* tag structure index */
730 assert(SML_TAG__ISVALID(tag));
740 /* if tag has no elements, return NULL */
742 if (tag->tags == NULL) {
748 * -> search tag structure; for each tag with element == "tagName":
749 * -> search tag parameters; if parameter name == "paramName"
750 * -> if parameter value != "paramValue"; to next tag
752 * -> if not the "index"th paramValue found; to next tag
756 for (ti = 0; ti < tag->tags_num; ti++) {
759 /* if tag element does not match, go on to next tag */
761 if (strcmp(tag->tags[ti].name, tagName)) {
767 for (pi = 0; pi < tag->tags[ti].params_num; pi++) {
768 assert(tag->tags[ti].params[pi].name != (char *)NULL);
769 assert(tag->tags[ti].params[pi].value != (char *)NULL);
773 if (strcmp(tag->tags[ti].params[pi].name, paramName)) {
777 /* if parameter value doesnt match to next tag */
779 if (strcmp(tag->tags[ti].params[pi].value,
786 * -> if this is not the 'index'th one, go to next tag
798 return (smlGetParam(&tag->tags[ti], paramReturn));
810 * Description: Return the name of a given tag
812 * The tag object to obtain the element name from
814 * Value of name of specified tag
829 /* return the tag name */
836 * Description: Get an element from a tag
837 * Arguments: tag - [RO, *RO] - (SML_TAG *)
838 * The tag object to obtain the element from
842 * The 'index'th element from the specified tag
843 * == SML_TAG__NULL if no such tag or element
847 smlGetTag(SML_TAG *tag, int index)
849 /* if no tag specified, return NULL */
851 if (tag == NULL) {
855 /* if tag has no elements, return NULL */
857 if (tag->tags == NULL) {
863 if (tag->tags_num <= index) {
869 assert(SML_TAG__ISVALID(&tag->tags[index]));
871 return (&tag->tags[index]);
877 * Arguments: tag - [RO, *RO] - (SML_TAG *)
878 * The tag object to obtain the element from
889 smlGetTagByName(SML_TAG *tag, int index, char *name)
895 /* if no tag specified, return NULL */
897 if (tag == NULL) {
901 /* if this tag is the one mentioned, return it */
903 if (streq(tag->name, name) && (index == 0)) {
904 return (tag);
907 /* if tag has no elements, return NULL */
909 if (tag->tags == NULL) {
915 if (tag->tags_num <= index) {
921 for (k = 0; k < tag->tags_num; k++) {
922 if (streq(tag->tags[k].name, name)) {
924 assert(SML_TAG__ISVALID(&tag->tags[k]));
925 return (&tag->tags[k]);
939 * Description: Convert string into tag object
944 * Pointer to handle to place new tag object
946 * String object to convert to tag object
948 * RESULT_OK - string converted to tag object
949 * RESULT_ERR - problem converting string to tag object
950 * NOTE: Any tag object returned is placed in new storage for the
952 * of the storage once the tag object name is no longer needed.
959 SML_TAG *tag = SML_TAG__NULL;
968 tag = smlNewTag("tagfile");
973 smlFreeTag(tag);
982 (unsigned long)tag, tag->name);
983 *r_tag = tag;
988 tag->tags_num++;
989 tag->tags = (SML_TAG *)realloc(tag->tags,
990 sizeof (SML_TAG) *tag->tags_num);
991 (void) memcpy(&(tag->tags[tag->tags_num - 1]), tmp_tag,
998 * Description: read one complete tag from a datastream
1003 * Pointer to handle to place new tag object
1004 * == SML_TAG__NULL if empty tag found (not an error)
1006 * Handle to datastream to read tag from
1008 * RESULT_OK - tag successfully read
1009 * RESULT_ERR - problem reading tag
1010 * NOTE: Any tag object returned is placed in new storage for the
1012 * of the storage once the tag object name is no longer needed.
1029 /* reset return tag */
1033 /* read tag from datastream, no parent tag to attach it to */
1056 * Description: Create a new (empty) tag object
1058 * Name of tag; NULL to give the tag no name
1061 * NOTE: Any tag object returned is placed in new storage for the
1063 * of the storage once the tag object name is no longer needed.
1064 * Errors: If the tag object cannot be created, the process exits
1070 SML_TAG *tag;
1081 /* allocate zeroed storage for the tag object */
1083 tag = (SML_TAG *)calloc(1, sizeof (SML_TAG));
1084 assert(tag != SML_TAG__NULL);
1089 tag->name = strdup(name);
1094 assert(SML_TAG__ISVALID(tag));
1099 (unsigned long)tag, name ? name : "<no name>");
1101 return (tag);
1106 * Description: Convert a tag object into a string representation of the XML
1107 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1108 * The tag object to convert to a string
1110 * String representation (in XML) of tag object
1118 smlConvertTagToString(SML_TAG *tag)
1124 assert(SML_TAG__ISVALID(tag));
1126 /* convert the tag object into the datastream */
1128 (void) _smlWriteSimpleTag(&str, tag);
1140 * Synopsis: Print a representation of an XML tag if debugging
1142 * Pointer to tag structure to dump
1196 /* convert the tag into a string to be printed */
1208 * Description: Delete a parameter from a tag object
1209 * Arguments: tag - [RO, *RW] - (SML_TAG *)
1210 * The tag object to delete the parameter from
1212 * The parameter to delete from the tag object
1214 * If the parameter exists, it is deleted from the tag
1218 smlDelParam(SML_TAG *tag, char *name)
1224 assert(SML_TAG__ISVALID(tag));
1225 assert(tag->name != (char *)NULL);
1232 tag->name, name);
1234 /* if tag has no parameters, nothing to delete */
1236 if (tag->params == NULL) {
1242 assert(tag->params_num > 0);
1244 /* search the tag for the parameter */
1246 for (k = 0; k < tag->params_num; k++) {
1247 if (streq(tag->params[k].name, name)) {
1254 if (k >= tag->params_num) {
1263 assert(tag->params[k].name != (char *)NULL);
1264 assert(tag->params[k].value != (char *)NULL);
1268 name, tag->params[k].value);
1272 free(tag->params[k].name);
1273 free(tag->params[k].value);
1277 if (k < (tag->params_num -1)) {
1278 (void) memmove(&(tag->params[k]), &(tag->params[k + 1]),
1279 sizeof (SML_PARAM) *(tag->params_num - k - 1));
1282 /* one less parameter object in tag */
1284 tag->params_num --;
1291 if (tag->params_num > 0) {
1292 /* realloc removing last element in tag object */
1294 tag->params = (SML_PARAM *)
1295 realloc(tag->params,
1296 sizeof (SML_PARAM) *tag->params_num);
1298 tag->params = (SML_PARAM *)NULL;
1304 * Description: Set formatted parameter value in tag object
1305 * Arguments: tag - [RO, *RW] - (SML_TAG *)
1306 * The tag object to set the parameter in
1308 * The parameter to add to the tag object
1314 * The parameter value is set in the tag object
1321 smlSetParamF(SML_TAG *tag, char *name, char *format, ...)
1330 assert(SML_TAG__ISVALID(tag));
1358 /* add the parameter to the tag */
1360 smlSetParam(tag, name, bfr);
1369 * Description: Get a format-generated parameter from a tag
1370 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1371 * The tag object to obtain the parameter from
1387 smlGetParamF(SML_TAG *tag, char *format, ...)
1397 assert(SML_TAG__ISVALID(tag));
1423 /* add the parameter to the tag */
1425 p = smlGetParam(tag, bfr);
1436 * Description: Set parameter value in tag object
1437 * Arguments: tag - [RO, *RW] - (SML_TAG *)
1438 * The tag object to set the parameter in
1440 * The parameter to add to the tag object
1442 * The value of the parameter to set in the tag object
1444 * The parameter value is set in the tag object
1448 smlSetParam(SML_TAG *tag, char *name, char *value)
1454 assert(SML_TAG__ISVALID(tag));
1462 tag->name, name, value);
1466 if (tag->params != NULL) {
1468 for (k = 0; k < tag->params_num; k++) {
1469 assert(tag->params[k].name != (char *)NULL);
1470 assert(tag->params[k].value != (char *)NULL);
1474 if (!streq(tag->params[k].name, name)) {
1480 if (streq(tag->params[k].value, value)) {
1483 tag->params[k].value);
1491 tag->params[k].value);
1492 free(tag->params[k].value);
1493 tag->params[k].value = strdup(value);
1508 tag->params_num++;
1509 tag->params = (SML_PARAM *)realloc(tag->params,
1510 sizeof (SML_PARAM) *tag->params_num);
1511 (void) memcpy(&(tag->params[tag->params_num - 1]), parameter,
1519 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1520 * The tag object to look for the parameter to compare
1522 * Tag within tag object to look for the parameter in
1524 * Parameter within tag to look for
1538 smlParamEqF(SML_TAG *tag, char *findTag, char *findParam, char *format, ...)
1548 assert(SML_TAG__ISVALID(tag));
1574 /* add the parameter to the tag */
1576 b = smlParamEq(tag, findTag, findParam, bfr);
1588 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1589 * The tag object to look for the parameter to compare
1591 * Tag within tag object to look for the parameter in
1593 * Parameter within tag to look for
1602 smlParamEq(SML_TAG *tag, char *findTag, char *findParam, char *str)
1613 assert(SML_TAG__ISVALID(tag));
1615 /* look for the specified tag - if not found, return false */
1617 rtag = smlGetTagByName(tag, 0, findTag);
1644 * Description: Delete a tag if found in tag object
1645 * Arguments: tag - [RO, *RW] - (SML_TAG *)
1646 * The tag object to delete the tag from
1648 * Tag within tag object to delete
1650 * B_TRUE - tag found and deleted
1651 * B_FALSE - tag not found
1655 smlFindAndDelTag(SML_TAG *tag, char *findTag)
1661 assert(SML_TAG__ISVALID(tag));
1665 /* find the specified tag - if not found, return false */
1667 rtag = smlGetTagByName(tag, 0, findTag);
1672 /* tag found - delete it and return true */
1674 smlDelTag(tag, rtag);
1681 * Description: Duplicate a tag object
1682 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1683 * The tag object to duplicate
1685 * A handle to a complete duplicate of the tag provided
1686 * NOTE: Any tag object returned is placed in new storage for the
1688 * of the storage once the tag object name is no longer needed.
1689 * Errors: If the tag object cannot be duplicated, the process exits
1693 smlDup(SML_TAG *tag)
1700 assert(SML_TAG__ISVALID(tag));
1702 /* allocate zeroed storage for the tag object */
1707 /* duplicate all parameters of the tag */
1709 rtag->name = (tag->name ? strdup(tag->name) : (char *)NULL);
1710 rtag->params_num = tag->params_num;
1711 if (tag->params != (SML_PARAM *)NULL) {
1716 rtag->params[i].name = tag->params[i].name ?
1717 strdup(tag->params[i].name) :
1719 rtag->params[i].value = tag->params[i].value ?
1720 strdup(tag->params[i].value) :
1725 /* duplicate all elements of the tag */
1727 rtag->tags_num = tag->tags_num;
1729 if (tag->tags != SML_TAG__NULL) {
1735 stag = smlDup(&tag->tags[i]);
1754 * structure and place it and the name into the specified tag
1756 * Arguments: tag - [RO, *RO] - (SML_TAG *)
1757 * The tag object to deposit the information into
1763 * The information is placed into the specified tag object
1767 smlSetFileStatInfo(SML_TAG **tag, struct stat *statbuf, char *path)
1773 assert(SML_TAG__R_ISVALID(tag));
1774 assert(SML_TAG__ISVALID(*tag));
1779 (void) smlFindAndDelTag(*tag, _sml_fileStatInfoTag);
1781 /* create the file stat info inside of the top level tag */
1783 assert(smlGetTagByName(*tag, 0, _sml_fileStatInfoTag)
1787 (void) smlAddTag(tag, 0, rtag);
1790 /* obtain handle on newly created file stat info tag */
1792 rtag = smlGetTagByName(*tag, 0, _sml_fileStatInfoTag);
1795 /* add file info as parameters to the tag */
1816 * information placed into a tag object via smlSetFileStatInfo
1821 * tag - [RO, *RO] - (SML_TAG *)
1822 * The tag object to compare against
1831 smlFstatCompareEq(struct stat *statbuf, SML_TAG *tag, char *path)
1833 if (tag == SML_TAG__NULL) {
1837 assert(SML_TAG__ISVALID(tag));
1844 if (smlParamEq(tag,
1850 if (smlParamEqF(tag, _sml_fileStatInfoTag, "st_ino",
1855 if (smlParamEqF(tag, _sml_fileStatInfoTag, "st_mode",
1860 if (smlParamEqF(tag, _sml_fileStatInfoTag, "st_mtime",
1865 if (smlParamEqF(tag, _sml_fileStatInfoTag, "st_ctime",
1870 if (smlParamEqF(tag, _sml_fileStatInfoTag, "st_size",
2370 * Description: read complete tag from a datastream
2375 * Pointer to handle to place new tag object
2376 * == SML_TAG__NULL if empty tag found (not an error)
2378 * Handle to datastream to read tag from
2380 * Name for parent of tag (NONE if top of tag)
2382 * RESULT_OK - tag successfully read
2383 * RESULT_ERR - problem reading tag
2384 * NOTE: Any tag object returned is placed in new storage for the
2386 * of the storage once the tag object name is no longer needed.
2387 * Errors: If the tag object cannot be duplicated, the process exits
2394 SML_TAG *tag;
2411 /* reset return tag */
2415 /* allocate zeroed storage for the tag object */
2417 tag = (SML_TAG *)calloc(1, sizeof (SML_TAG));
2418 assert(tag != SML_TAG__NULL);
2424 /* ignore delimters before tag */
2427 /* read tag character - handle failure/EOF */
2434 smlFreeTag(tag);
2439 /* EOF in middle of processing tag */
2444 smlFreeTag(tag);
2449 /* if beginning of tag, break out */
2455 /* not tag beginning: ignore delimiters if not inside tag yet */
2464 /* on blank lines, return no tag object */
2470 smlFreeTag(tag);
2475 /* invalid character before tag start */
2485 * all delimiters have been ignored and opening tag character seen;
2486 * process tag
2496 /* handle EOF after tag opening character found */
2502 smlFreeTag(tag);
2507 /* is this a tag closure? */
2514 /* get next character of tag name */
2521 /* EOF inside tag name? */
2527 smlFreeTag(tag);
2532 /* tag close: break out of collection loop */
2538 /* see if illegal character in tag name */
2546 smlFreeTag(tag);
2561 /* close of tag found */
2565 /* is the tag empty? If so that's an error */
2570 smlFreeTag(tag);
2575 /* if no parent, a close tag outside of any open tag */
2581 smlFreeTag(tag);
2592 smlFreeTag(tag);
2597 /* close of current tag found - success */
2601 smlFreeTag(tag);
2606 /* not starting a close tag */
2611 /* at start of tag - input tag name */
2618 /* EOF inside of tag name? */
2624 smlFreeTag(tag);
2629 /* if separator or end of line then tag name collected */
2635 /* see if illegal character in tag name */
2642 smlFreeTag(tag);
2647 /* close current tag? */
2650 /* get next character of tag name */
2657 /* tag close not found? */
2663 smlFreeTag(tag);
2668 /* is the tag empty? If so that's an error */
2674 smlFreeTag(tag);
2679 /* tag closed */
2685 tag->name = strdup(name);
2686 *r_tag = tag;
2708 /* have a valid tag name: <tagname */
2715 /* place tag name inside of tag object */
2717 tag->name = strdup(name);
2749 tag->name,
2751 smlFreeTag(tag);
2756 /* if separator/end of line tag parameter collected */
2769 c, (unsigned int)c, name, tag->name,
2771 smlFreeTag(tag);
2776 /* tag close found? */
2782 /* close tag found ? */
2792 tag->name);
2793 *r_tag = tag;
2801 name, tag->name,
2803 smlFreeTag(tag);
2836 tag->name,
2838 smlFreeTag(tag);
2847 c, (unsigned int)c, name, tag->name,
2849 smlFreeTag(tag);
2875 tag->name, parent ? parent : "<<NONE>>");
2876 smlFreeTag(tag);
2884 name, tag->name);
2905 smlFreeTag(tag);
2923 pname, tag->name,
2925 smlFreeTag(tag);
2940 pname, tag->name,
2943 smlFreeTag(tag);
2961 pname, name, tag->name);
2971 tag->params_num++;
2972 tag->params = (SML_PARAM *)
2973 realloc(tag->params,
2974 sizeof (SML_PARAM) *tag->params_num);
2975 (void) memcpy(&(tag->params[tag->params_num - 1]), parameter,
2984 /* finished processing this tag element entry */
2987 tag->name, parent ? parent : "<<NULL>>");
2989 tag->tags = NULL;
2991 while (((r = _smlReadTag(&tmp_tag, &p, tag->name))
2993 tag->tags_num++;
2994 tag->tags = (SML_TAG *)realloc(tag->tags,
2995 sizeof (SML_TAG) *tag->tags_num);
2996 (void) memcpy(&(tag->tags[tag->tags_num - 1]), tmp_tag,
3006 *r_tag = tag;
3019 * RESULT_OK - tag successfully read
3020 * RESULT_ERR - problem reading tag
3062 _smlWriteSimpleTag(char **a_str, SML_TAG *tag)
3070 if (tag == NULL) {
3078 if (tag->params_num == 0) {
3079 if (tag->tags_num == 0) {
3080 ns = sml_strPrintf("%s<%s/>\n", *a_str, tag->name);
3085 ns = sml_strPrintf("%s<%s>\n", *a_str, tag->name);
3093 ns = sml_strPrintf("%s<%s %s=", *a_str ? *a_str : "", tag->name,
3094 tag->params[0].name);
3102 r = _smlWriteParamValue(&np0, tag->params[0].value);
3116 for (k = 1; k < tag->params_num; k++) {
3117 np0 = sml_strPrintf(" %s=", tag->params[k].name);
3122 r = _smlWriteParamValue(&np1, tag->params[k].value);
3138 if (tag->tags_num == 0) {
3165 for (k = 0; k < tag->tags_num; k++) {
3166 r = _smlWriteSimpleTag(a_str, &(tag->tags[k]));
3172 if (tag->tags_num > 0) {
3173 np0 = sml_strPrintf("</%s>\n", tag->name);
3190 _smlFreeTag(SML_TAG *tag)
3196 assert(tag != SML_TAG__NULL);
3201 (unsigned long)tag,
3202 tag->name ? tag->name : "<<NONE>>",
3203 tag->params_num, tag->tags_num);
3205 for (k = 0; k < tag->params_num; k++) {
3207 (unsigned long)(&tag->params[k]),
3208 (unsigned long)(tag->params[k].name),
3209 tag->params[k].name);
3210 free(tag->params[k].name);
3211 tag->params[k].name = (char *)NULL;
3213 (unsigned long)(&tag->params[k]),
3214 (unsigned long)(tag->params[k].value),
3215 tag->params[k].value);
3216 free(tag->params[k].value);
3217 tag->params[k].value = (char *)NULL;
3220 for (k = 0; k < tag->tags_num; k++) {
3221 _smlFreeTag(&tag->tags[k]);
3224 if (tag->name != NULL) {
3226 (unsigned long)tag->name, tag->name);
3227 free(tag->name);
3228 tag->name = NULL;
3232 if (tag->params != NULL) {
3233 assert(tag->params_num > 0);
3234 bzero(tag->params, sizeof (SML_PARAM)*tag->params_num);
3236 (unsigned long)tag->params);
3237 free(tag->params);
3238 tag->params = NULL;
3239 tag->params_num = 0;
3242 if (tag->tags != NULL) {
3243 assert(tag->tags_num > 0);
3244 bzero(tag->tags, sizeof (SML_TAG)*tag->tags_num);
3246 (unsigned long)tag->tags);
3247 free(tag->tags);
3248 tag->tags = NULL;
3249 tag->tags_num = 0;