Thread: [Refdb-cvs] CVS: refdb/src elstack.c,NONE,1.1 elstack.h,NONE,1.1 mods_dbfncs.c,NONE,1.1 mods_dbfncs.
Status: Beta
Brought to you by:
mhoenicka
|
From: Markus H. <mho...@us...> - 2004-05-17 23:13:02
|
Update of /cvsroot/refdb/refdb/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27611 Added Files: elstack.c elstack.h mods_dbfncs.c mods_dbfncs.h mods_endhandler.c mods_handler.h mods_helper.c mods_helper.h mods_objects.c mods_objects.h mods_processdata.c mods_processdata.h mods_starthandler.c Log Message: initial version --- NEW FILE --- /* elstack.c: implements a linked list for use in expat handlers */ /* ma...@mh... 2004-01-10 */ /* $Id: elstack.c,v 1.1 2004/05/17 23:12:51 mhoenicka Exp $ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #include <stdio.h> #include "elstack.h" /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ elstack_get_attr(): returns the value of an attribute of the current element char* elstack_get_attr returns the value of the requested attribute or NULL if no such attribute is found struct elstack* ptr_current_element ptr to the current element on the element stack char* attribute name of the requested attribute ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ char* elstack_get_attr(struct elstack* ptr_current_element, char* attribute) { struct attrlist* ptr_attr; ptr_attr = ptr_current_element->ptr_attr_first; while (ptr_attr != NULL) { if (strcmp(ptr_attr->attribute_name, attribute) == 0) { return ptr_attr->attribute_value; } ptr_attr = ptr_attr->ptr_next; } return NULL; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ elstack_get_ancestor_attr(): returns the value of an attribute of an ancestor of the current element char* elstack_get_ancestor_attr returns the value of the requested attribute or NULL if no such attribute is found struct elstack* ptr_current_element ptr to the current element on the element stack char* ancestor_name name of the requested ancestor element char* ancestor_attribute name of the requested ancestor attribute ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ char* elstack_get_ancestor_attr(struct elstack* ptr_current_element, char* ancestor_name, char* ancestor_attribute) { struct elstack* ptr_el; struct attrlist* ptr_attr; ptr_el = ptr_current_element; while (ptr_el != NULL) { if (strcmp(ptr_el->elname, ancestor_name) == 0) { ptr_attr = ptr_el->ptr_attr_first; while (ptr_attr != NULL) { if (strcmp(ptr_attr->attribute_name, ancestor_attribute) == 0) { return ptr_attr->attribute_value; } ptr_attr = ptr_attr->ptr_next; } } ptr_el = ptr_el->ptr_next; } return NULL; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ elstack_get_parent(): returns the parent of the current element struct elstack* elstack_get_parent returns the parent of the current element or NULL if no such element is found struct elstack* ptr_current_element ptr to the current element on the element stack ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ struct elstack* elstack_get_parent(struct elstack* ptr_current_element) { return ptr_current_element->ptr_next; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ elstack_is_descendant_of(): tests whether the current element is the descendant of a given element int elstack_is_descendant_of returns 1 if the current element is the descendant of the given element, 0 if not struct elstack* ptr_current_element ptr to the current element on the element stack char* ancestor_name name of the requested ancestor element ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ int elstack_is_descendant_of(struct elstack* ptr_current_element, char* ancestor_name) { struct elstack* ptr_el; ptr_el = ptr_current_element; while (ptr_el != NULL) { if (strcmp(ptr_el->elname, ancestor_name) == 0) { return 1; } ptr_el = ptr_el->ptr_next; } return 0; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ modstack_get_attr(): returns the value of an attribute of the current element char* modstack_get_attr returns the value of the requested attribute or NULL if no such attribute is found struct modstack* ptr_current_element ptr to the current element on the element stack char* attribute name of the requested attribute ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ char* modstack_get_attr(struct modstack* ptr_current_element, char* attribute) { struct attrlist* ptr_attr; ptr_attr = ptr_current_element->ptr_attr_first; while (ptr_attr != NULL) { if (strcmp(ptr_attr->attribute_name, attribute) == 0) { return ptr_attr->attribute_value; } ptr_attr = ptr_attr->ptr_next; } return NULL; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ modstack_get_parent(): returns the parent of the current element struct modstack* modstack_get_parent returns the parent of the current element or NULL if no such element is found struct modstack* ptr_current_element ptr to the current element on the element stack ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ struct modstack* modstack_get_parent(struct modstack* ptr_current_element) { return ptr_current_element->ptr_next; } /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ modstack_is_descendant_of(): tests whether the current element is the descendant of a given element int modstack_is_descendant_of returns 1 if the current element is the descendant of the given element, 0 if not struct modstack* ptr_current_element ptr to the current element on the element stack char* ancestor_name name of the requested ancestor element ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ int modstack_is_descendant_of(struct modstack* ptr_current_element, char* ancestor_name) { struct modstack* ptr_el; ptr_el = ptr_current_element; while (ptr_el != NULL) { if (strcmp(ptr_el->elname, ancestor_name) == 0) { return 1; } ptr_el = ptr_el->ptr_next; } return 0; } struct modstack* new_modstack(const char* elname) { struct modstack* ptr_mods_new; ptr_mods_new = (struct modstack*)malloc(sizeof(struct modstack)); if (ptr_mods_new == NULL) { return NULL; } strncpy(ptr_mods_new->elname, elname, 63); ptr_mods_new->elname[63] = '\0'; /* terminate just in case */ ptr_mods_new->n_elvalue_len = ELVALUE_LENGTH; ptr_mods_new->ptr_elvalue = (char*)malloc(ELVALUE_LENGTH); if (ptr_mods_new->ptr_elvalue == NULL) { free(ptr_mods_new); return NULL; } *(ptr_mods_new->ptr_elvalue) = '\0'; ptr_mods_new->ptr_attr_first = NULL; ptr_mods_new->ptr_next = NULL; ptr_mods_new->ptr_modsobject = NULL; ptr_mods_new->ptr_modsdate = NULL; ptr_mods_new->position = 0; return ptr_mods_new; } --- NEW FILE --- /* elstack.h: header for elstack.c */ /* ma...@mh... 2004-01-10 */ /* $Id: elstack.h,v 1.1 2004/05/17 23:12:51 mhoenicka Exp $ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ #define ELNAME_LENGTH 64 /* max length of an XML element name */ #define ELVALUE_LENGTH 256 /* max/initial length of an XML element value */ #define EL_LENGTH 512 /* ELNAME plus ELVALUE plus a little slack */ /* the current implementation can do without resizable name/value variables which saves a few malloc()/realloc() calls in favour of speed */ struct attrlist { char attribute_name[ELNAME_LENGTH]; char attribute_value[ELVALUE_LENGTH]; struct attrlist *ptr_next; }; /* element names are ok with fixed size. element values may be treated as resizable */ struct elstack { char elname[ELNAME_LENGTH]; char *ptr_elvalue; size_t n_elvalue_len; struct attrlist *ptr_attr_first; struct elstack *ptr_next; }; /* this struct defines a simple stack for elements without a length limit for the value and with just one attribute of variable length. */ struct simple_elstack { char elname[ELNAME_LENGTH]; char* elvalue; char* attrvalue; struct simple_elstack *ptr_snext; }; /* element names are ok with fixed size. element values are resizable */ struct modstack { char elname[ELNAME_LENGTH]; /* the element name */ char *ptr_elvalue; /* the element value */ size_t n_elvalue_len; /* length of element value */ unsigned int position; /* position counter used by some elements */ struct attrlist *ptr_attr_first; /* ptr to an attribute linked list */ struct modsObject* ptr_modsobject; /* ptr to a mods object, if any */ struct modsDate* ptr_modsdate; /* ptr to a mods date object, if any */ struct modstack *ptr_next; /* ptr to next entry in linked list */ }; char* elstack_get_attr(struct elstack* ptr_current_element, char* attribute); int elstack_is_descendant_of(struct elstack* ptr_current_element, char* ancestor_name); char* elstack_get_ancestor_attr(struct elstack* ptr_current_element, char* ancestor_name, char* ancestor_attribute); struct elstack* elstack_get_parent(struct elstack* ptr_current_element); int modstack_is_descendant_of(struct modstack* ptr_current_element, char* ancestor_name); struct modstack* modstack_get_parent(struct modstack* ptr_current_element); struct modstack* new_modstack(const char* elname); char* modstack_get_attr(struct modstack* ptr_current_element, char* attribute); --- NEW FILE --- /*++++++++++++++++++++ mods_dbfncs.c: refdb database-specific support functions for mods tables ma...@mh... 2004-03-21 $Id: mods_dbfncs.c,v 1.1 2004/05/17 23:12:51 mhoenicka Exp $ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA [...2015 lines suppressed...] int my_dbi_conn_modsunlock(dbi_conn conn) { dbi_result dbires; const char *drivername; drivername = dbi_driver_get_name(dbi_conn_get_driver(conn)); if (!strcmp(drivername, "mysql")) { dbires = dbi_conn_query(conn, "UNLOCK TABLES"); LOG_PRINT(LOG_DEBUG, "UNLOCK TABLES"); if (!dbires) { return 1; } dbi_result_free(dbires); } /* else: pgsql unlocks when a transaction is finished, */ /* sqlite does not support lock/unlock */ return 0; } --- NEW FILE --- /* mods_dbfncs.h header file for mods_dbfncs.c */ /* ma...@mh... 2004-03-21 */ /* $Id: mods_dbfncs.h,v 1.1 2004/05/17 23:12:51 mhoenicka Exp $ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ int create_modstables_mysql(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); int create_modstables_pgsql(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); int create_modstables_sqlite(dbi_conn conn, struct CLIENT_REQUEST* ptr_clrequest); int my_dbi_conn_modslock(dbi_conn conn); int my_dbi_conn_modslock_note(dbi_conn conn); int my_dbi_conn_modsunlock(dbi_conn conn); --- NEW FILE --- /* mods_endhandler.c: expat handler for start tags of mods records */ /* ma...@mh... 2003-12-07 */ /* $Id: mods_endhandler.c,v 1.1 2004/05/17 23:12:51 mhoenicka Exp $ */ /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* Overview */ /* This set of functions parses a XML file containing MODS datasets. We use expat as a non-validating XML parser. We register three handlers for start tags, character data, and end tags. The elements are pushed on a stack in the start tags handler. Each structure defining an element contains a start element of another stack for the attributes of this element. These stacks are used in the character data handler and the end tag handler to retrieve parent and ancestor elements and attributes of the current element where necessary. The attribute stack of the current element is freed in the end tag handler and the current element is popped off the stack as well. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <expat.h> /* header of the XML parser */ #include <syslog.h> /* priority levels of log messages */ #include <iconv.h> #include <dbi/dbi.h> #include "backend.h" #include "linklist.h" #include "refdb.h" #include "refdbd.h" /* depends on backend.h */ #include "risdb.h" #include "strfncs.h" #include "connect.h" #include "dbfncs.h" #include "authorinfo.h" #include "elstack.h" #include "mods_objects.h" #include "mods_handler.h" extern int n_log_level; extern struct BSTRING connerr; extern struct BSTRING outomem; extern struct BSTRING outomem_n; /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ mods_end_handler(): handler for end tags void mods_end_handler has no return value void* ptr_data this is a ptr to "non-global" global data that all handlers share - will be cast to type struct addmods_data* const char *el ptr to a string containing the element name ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ void mods_end_handler(void *ptr_data, const char *el) { char* new_msgpool; struct modstack* ptr_el_remove; struct modstack* ptr_parent; struct attrlist* ptr_attr_remove; struct addmods_data* ptr_amdata; dbi_result dbires; ptr_amdata = (struct addmods_data*)ptr_data; /* printf("end handler found el:%s<<ndb_error:%d<< nmem_error:%d<<\n", el, ptr_amdata->ndb_error, ptr_amdata->nmem_error); */ if (ptr_amdata->n_skip) { if (!strcmp(el, "entry")) { (ptr_amdata->n_skip)--; (ptr_amdata->skipped_count)++; /* close transaction of skipped dataset, if any */ my_dbi_conn_rollback(ptr_amdata->conn); } return; } if (ptr_amdata->depth) { (ptr_amdata->depth)--; } if (!ptr_amdata->ndb_error && !ptr_amdata->nmem_error && !ptr_amdata->n_skip) { /* do a character conversion if required. expat dumps all character data as UTF-8 regardless of the input encoding */ size_t inlength; size_t outlength; char* my_elvalue = NULL; /* this ptr will be modified by iconv() */ char* my_elvalue_start = NULL; /* records initial state of my_elvalue */ const char* my_instring = NULL; /* this ptr will be modified by iconv() */ if (ptr_amdata->conv_descriptor && *((ptr_amdata->ptr_first)->ptr_elvalue)) { inlength = strlen((ptr_amdata->ptr_first)->ptr_elvalue) + 1; /* with the encodings supported by our database engines, the converted string can't be longer than the input string */ outlength = inlength; if ((my_elvalue = (char*)malloc(outlength)) == NULL) { if ((new_msgpool = mstrcat(ptr_amdata->msgpool, outomem_n.text, &(ptr_amdata->msgpool_len), 0)) == NULL) { return; } else { ptr_amdata->msgpool = new_msgpool; } (ptr_amdata->nmem_error)++; return; } /* keep start of the converted string */ my_elvalue_start = my_elvalue; /* variable will be modified by iconv, so don't use original */ my_instring = (const char*)((ptr_amdata->ptr_first)->ptr_elvalue); /* now actually do the conversion */ if (iconv(ptr_amdata->conv_descriptor, &my_instring, &inlength, &my_elvalue, &outlength) == (size_t)(-1)) { if (errno == EILSEQ) { new_msgpool = mstrcat(ptr_amdata->msgpool, "iconv: invalid input character sequence\n", &(ptr_amdata->msgpool_len), 0); LOG_PRINT(LOG_WARNING, "iconv: invalid input character sequence"); } else if (errno == E2BIG) { new_msgpool = mstrcat(ptr_amdata->msgpool, "iconv: output buffer too small\n", &(ptr_amdata->msgpool_len), 0); LOG_PRINT(LOG_WARNING, "iconv: output buffer too small"); } else if (errno == EINVAL) { new_msgpool = mstrcat(ptr_amdata->msgpool, "iconv: incomplete input character\n", &(ptr_amdata->msgpool_len), 0); LOG_PRINT(LOG_WARNING, "iconv: incomplete input character"); } if (new_msgpool == NULL) { return; } else { ptr_amdata->msgpool = new_msgpool; } (ptr_amdata->ndb_error)++; return; } /* else: conversion went ok. We free the original string and replace it with the converted copy */ if ((ptr_amdata->ptr_first)->ptr_elvalue) { free((ptr_amdata->ptr_first)->ptr_elvalue); } (ptr_amdata->ptr_first)->ptr_elvalue = my_elvalue_start; (ptr_amdata->ptr_first)->n_elvalue_len = outlength; } /* else: no conversion required */ ptr_parent = modstack_get_parent(ptr_amdata->ptr_first); if (!strcmp(el, "modsCollection")) { /* ToDo: finish the set ? */ } else if (!strcmp(el, "mods")) { /* transfer objects into database, then free */ if (mods_process_data(ptr_amdata)) { /* ToDo: error */ } /* reset stuff */ ptr_amdata->position = 0; } else if (modstack_is_descendant_of(ptr_amdata->ptr_first, "extension")) { /* ToDo: save as string */ } /*********************************************************************/ else if (!strcmp(ptr_parent->elname, "mods")) { /* top-level elements */ if (!strcmp(el, "titleInfo")) { /* ToDo: can also be child of subject */ } else if (!strcmp(el, "name")) { /* ToDo: can also be child of subject */ } else if (!strcmp(el, "typeOfResource")) { struct modsObject* ptr_typeofresource; ptr_typeofresource = (struct modsObject*)((ptr_amdata->ptr_first)->ptr_modsobject); if (append_lilinameval(&(ptr_typeofresource->content_sentinel), "typeOfResource", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "genre")) { struct modsObject* ptr_genre; ptr_genre = (struct modsObject*)((ptr_amdata->ptr_first)->ptr_modsobject); if (append_lilinameval(&(ptr_genre->content_sentinel), "genre", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "originInfo")) { /* todo: this element allows more than one originInfo struct to be filled */ } else if (!strcmp(el, "language")) { } else if (!strcmp(el, "physicalDescription")) { } else if (!strcmp(el, "abstract")) { } else if (!strcmp(el, "tableOfContents")) { } else if (!strcmp(el, "targetAudience")) { } else if (!strcmp(el, "note")) { } else if (!strcmp(el, "subject")) { } else if (!strcmp(el, "classification")) { } else if (!strcmp(el, "relatedItem")) { } else if (!strcmp(el, "identifier")) { } else if (!strcmp(el, "location")) { } else if (!strcmp(el, "accessCondition")) { } else if (!strcmp(el, "extension")) { } else if (!strcmp(el, "recordInfo")) { } } /* end if is child of mods */ /*********************************************************************/ /* lower-level elements */ /* titleInfo children */ else if (!strcmp(el, "title")) { /* child of titleInfo */ struct modsObject* ptr_titleinfo; ptr_titleinfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_titleinfo->content_sentinel), "title", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "subTitle")) { /* child of titleInfo */ struct modsObject* ptr_titleinfo; ptr_titleinfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_titleinfo->content_sentinel), "subTitle", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "partNumber")) { /* child of titleInfo */ struct modsObject* ptr_titleinfo; ptr_titleinfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_titleinfo->content_sentinel), "partNumber", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "partName")) { /* child of titleInfo */ struct modsObject* ptr_titleinfo; ptr_titleinfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_titleinfo->content_sentinel), "partName", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "nonSort")) { /* child of titleInfo */ struct modsObject* ptr_titleinfo; ptr_titleinfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_titleinfo->content_sentinel), "nonSort", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "namePart")) { /* child of name */ struct modsObject* ptr_name; char* att; ptr_name = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); att = modstack_get_attr(ptr_amdata->ptr_first, "type"); /* fn checks if att==NULL */ if (append_lilinameval(&(ptr_name->content_sentinel), "namePart", (ptr_amdata->ptr_first)->ptr_elvalue, "type", att, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "roleTerm")) { /* child of name:role. role is treated as transparent */ struct modsObject* ptr_name; char* att; char* att1; ptr_name = (struct modsObject*)((modstack_get_parent(modstack_get_parent(ptr_amdata->ptr_first)))->ptr_modsobject); att = modstack_get_attr(ptr_amdata->ptr_first, "type"); att1 = modstack_get_attr(ptr_amdata->ptr_first, "authority"); /* fn checks if att==NULL */ if (append_lilinameval(&(ptr_name->content_sentinel), "roleTerm", (ptr_amdata->ptr_first)->ptr_elvalue, "type", att, "authority", att1, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "displayform")) { /* child of name */ struct modsObject* ptr_name; ptr_name = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_name->content_sentinel), "displayForm", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "affiliation")) { /* child of name */ struct modsObject* ptr_name; ptr_name = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_name->content_sentinel), "affiliation", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "description")) { /* child of name */ struct modsObject* ptr_name; ptr_name = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_name->content_sentinel), "description", (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "placeTerm")) { /* child of originInfo:place. place is treated as transparent */ struct modsObject* ptr_origininfo; char* att; char* att1; ptr_origininfo = (struct modsObject*)((modstack_get_parent(modstack_get_parent(ptr_amdata->ptr_first)))->ptr_modsobject); att = modstack_get_attr(ptr_amdata->ptr_first, "type"); att1 = modstack_get_attr(ptr_amdata->ptr_first, "authority"); /* fn checks if att==NULL */ if (append_lilinameval(&(ptr_origininfo->content_sentinel), "roleTerm", (ptr_amdata->ptr_first)->ptr_elvalue, "type", att, "authority", att1, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "publisher") || !strcmp(el, "edition") || !strcmp(el, "issuance") || !strcmp(el, "frequency")) { /* child of originInfo */ struct modsObject* ptr_origininfo; ptr_origininfo = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_origininfo->content_sentinel), (char*)el, (ptr_amdata->ptr_first)->ptr_elvalue, NULL, NULL, NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "languageTerm")) { /* child of language */ struct modsObject* ptr_language; char* att; char* att1; ptr_language = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); att = modstack_get_attr(ptr_amdata->ptr_first, "type"); att1 = modstack_get_attr(ptr_amdata->ptr_first, "authority"); /* fn checks if att==NULL */ if (append_lilinameval(&(ptr_language->content_sentinel), "languageTerm", (ptr_amdata->ptr_first)->ptr_elvalue, "type", att, "authority", att1, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "form")) { /* child of physicalDescription */ struct modsObject* ptr_physicaldescription; ptr_physicaldescription = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_physicaldescription->content_sentinel), "form", (ptr_amdata->ptr_first)->ptr_elvalue, "authority", modstack_get_attr(ptr_amdata->ptr_first, "authority"), NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "extent")) { /* child of physicalDescription or of part*/ struct modsObject* ptr_physicaldescription; ptr_physicaldescription = (struct modsObject*)((modstack_get_parent(ptr_amdata->ptr_first))->ptr_modsobject); if (append_lilinameval(&(ptr_physicaldescription->content_sentinel), "extent", (ptr_amdata->ptr_first)->ptr_elvalue, "unit", modstack_get_attr(ptr_amdata->ptr_first, "unit"), NULL, NULL, NULL, NULL, 0)) { (ptr_amdata->nmem_error)++; return; } } else if (!strcmp(el, "reformattingQuali... [truncated message content] |