{"issue":{"milestone":null,"title":"mxmlNewCopy Function","created_at":"2012-01-01T08:02:20Z","user":{"id":488103,"login":"michaelrsweet","url":"https://api.github.com/users/michaelrsweet","avatar_url":"https://secure.gravatar.com/avatar/2daeb0c57e7f61fe81706928130cd07d?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"2daeb0c57e7f61fe81706928130cd07d"},"labels":[{"name":"P4 - Feature","color":"02e10c","url":"https://api.github.com/repos/michaelrsweet/Mini-XML/labels/P4+-+Feature"}],"updated_at":"2012-01-01T08:02:20Z","state":"open","id":2696748,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"html_url":"https://github.com/michaelrsweet/Mini-XML/issues/1","closed_at":null,"body":"[Originally submitted by David_Descamps]\r\n\r\n/*\r\n * 'mxmlCopyElement()'\r\n *\r\n * The new element node is copied from an original and added to the end of the \r\n * specified parent's child list. The constant MXML_NO_PARENT can be used to \r\n * specify that the new element node has no parent.\r\n *\r\n */\r\nmxml_node_t *\r\nmxmlNewCopy(mxml_node_t *parent, /* I - Parent node */\r\n                        int         descend, /* I - Descend into tree - MXML_DESCEND, MXML_NO_DESCEND, or MXML_DESCEND_FIRST */\r\n                        mxml_node_t *original) /* I - Node to copy and add */\r\n{\r\n        mxml_node_t *node; /* New node */\r\n        int i; /* Looping var */\r\n        mxml_node_t *child = NULL;\r\n        switch (original->type) {\r\n                case MXML_ELEMENT:\r\n                {\r\n                        if(original->value.opaque && '?' == original->value.opaque[0])\r\n                        {\r\n                                node = mxmlNewElement(parent, original->value.opaque);\r\n                                break;\r\n                        }\r\n                        node = mxmlNewElement(parent, original->value.element.name);\r\n                        \r\n                        for ( i = 0; i < original->value.element.num_attrs; i ++)\r\n                        {\r\n                                mxmlElementSetAttr(node, original->value.element.attrs[i].name,\r\n                                                                   original->value.element.attrs[i].value);\r\n                        }\r\n                        break;\r\n                }\r\n                case MXML_INTEGER:\r\n                {\r\n                        node = mxmlNewInteger(parent, original->value.integer);\r\n                        break;\r\n                }\r\n                case MXML_OPAQUE:\r\n                {\r\n                        node = mxmlNewOpaque(parent, original->value.opaque);\r\n                        break;\r\n                }\r\n                case MXML_REAL:\r\n                {\r\n                        node = mxmlNewReal(parent, original->value.real);\r\n                        break;\r\n                }\r\n                case MXML_TEXT:\r\n                {\r\n                        node = mxmlNewText(parent, original->value.text.whitespace, \r\n                                                           original->value.text.string);\r\n                        break;\r\n                }\r\n                case MXML_CUSTOM:\r\n                {\r\n                        node = mxmlNewCustom(parent, original->value.custom.data,\r\n                                                                 original->value.custom.destroy);\r\n                        break;\r\n                }\r\n                default:\r\n                        break;\r\n        }\r\n        \r\n        if(MXML_NO_DESCEND!=descend && original->child)\r\n        {\r\n                if(MXML_DESCEND_FIRST==descend)\r\n                        descend=MXML_NO_DESCEND;\r\n                mxmlNewCopy(node, descend, original->child);\r\n                child = mxmlWalkNext(original->child, original, MXML_NO_DESCEND);\r\n                /*\r\n                 * Loop all children...\r\n                 */\r\n                while (child != NULL)\r\n                {\r\n                        mxmlNewCopy(node, descend, child); \r\n                        child = mxmlWalkNext(child, original, MXML_NO_DESCEND);\r\n                }\r\n        }\r\n        return (node);\r\n}","number":1,"url":"https://api.github.com/repos/michaelrsweet/Mini-XML/issues/1","comments":0,"assignee":null},"action":"opened"}