⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlschemastypes.c.svn-base

📁 这是一个用于解析xml文件的类库。使用这个类库
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
    while ((end > start) && (IS_BLANK_CH(*end))) end--;    end++;    if ((start == value) && (f == end)) return(NULL);    return(xmlStrndup(start, end - start));}/** * xmlSchemaCollapseString: * @value: a value * * Removes and normalize white spaces in the string * * Returns the new string or NULL if no change was required. */static xmlChar *xmlSchemaCollapseString(const xmlChar *value) {    const xmlChar *start = value, *end, *f;    xmlChar *g;    int col = 0;    if (value == NULL) return(NULL);    while ((*start != 0) && (IS_BLANK_CH(*start))) start++;    end = start;    while (*end != 0) {	if ((*end == ' ') && (IS_BLANK_CH(end[1]))) {	    col = end - start;	    break;	} else if ((*end == 0xa) || (*end == 0x9) || (*end == 0xd)) {	    col = end - start;	    break;	}	end++;    }    if (col == 0) {	f = end;	end--;	while ((end > start) && (IS_BLANK_CH(*end))) end--;	end++;	if ((start == value) && (f == end)) return(NULL);	return(xmlStrndup(start, end - start));    }    start = xmlStrdup(start);    if (start == NULL) return(NULL);    g = (xmlChar *) (start + col);    end = g;    while (*end != 0) {	if (IS_BLANK_CH(*end)) {	    end++;	    while (IS_BLANK_CH(*end)) end++;	    if (*end != 0)		*g++ = ' ';	} else	    *g++ = *end++;    }    *g = 0;    return((xmlChar *) start);}/** * xmlSchemaValAtomicListNode: * @type: the predefined atomic type for a token in the list * @value: the list value to check * @ret:  the return computed value * @node:  the node containing the value * * Check that a value conforms to the lexical space of the predefined * list type. if true a value is computed and returned in @ret. * * Returns the number of items if this validates, a negative error code *         number otherwise */static intxmlSchemaValAtomicListNode(xmlSchemaTypePtr type, const xmlChar *value,	                   xmlSchemaValPtr *ret, xmlNodePtr node) {    xmlChar *val, *cur, *endval;    int nb_values = 0;    int tmp = 0;    if (value == NULL) {	return(-1);    }    val = xmlStrdup(value);    if (val == NULL) {	return(-1);    }    cur = val;    /*     * Split the list     */    while (IS_BLANK_CH(*cur)) *cur++ = 0;    while (*cur != 0) {	if (IS_BLANK_CH(*cur)) {	    *cur = 0;	    cur++;	    while (IS_BLANK_CH(*cur)) *cur++ = 0;	} else {	    nb_values++;	    cur++;	    while ((*cur != 0) && (!IS_BLANK_CH(*cur))) cur++;	}    }    if (nb_values == 0) {	if (ret != NULL) {	    TODO	}	xmlFree(val);	return(nb_values);    }    endval = cur;    cur = val;    while ((*cur == 0) && (cur != endval)) cur++;    while (cur != endval) {	tmp = xmlSchemaValPredefTypeNode(type, cur, NULL, node);	if (tmp != 0)	    break;	while (*cur != 0) cur++;	while ((*cur == 0) && (cur != endval)) cur++;    }    xmlFree(val);    if (ret != NULL) {	TODO    }    if (tmp == 0)	return(nb_values);    return(-1);}/** * xmlSchemaParseUInt: * @str: pointer to the string R/W * @llo: pointer to the low result * @lmi: pointer to the mid result * @lhi: pointer to the high result * * Parse an unsigned long into 3 fields. * * Returns the number of chars parsed or -1 if overflow of the capacity */static intxmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,	           unsigned long *lmi, unsigned long *lhi) {    unsigned long lo = 0, mi = 0, hi = 0;    const xmlChar *tmp, *cur = *str;    int ret = 0, i = 0;    while (*cur == '0') {	ret++;	cur++;    }    tmp = cur;    while ((*tmp != 0) && (*tmp >= '0') && (*tmp <= '9')) {	i++;tmp++;ret++;    }    if (i > 24) {	*str = tmp;	return(-1);    }    while (i > 16) {	hi = hi * 10 + (*cur++ - '0');	i--;    }    while (i > 8) {	mi = mi * 10 + (*cur++ - '0');	i--;    }    while (i > 0) {	lo = lo * 10 + (*cur++ - '0');	i--;    }    *str = cur;    *llo = lo;    *lmi = mi;    *lhi = hi;    return(ret);}/** * xmlSchemaValAtomicType: * @type: the predefined type * @value: the value to check * @val:  the return computed value * @node:  the node containing the value * flags:  flags to control the vlidation * * Check that a value conforms to the lexical space of the atomic type. * if true a value is computed and returned in @val. * * Returns 0 if this validates, a positive error code number otherwise *         and -1 in case of internal or API error. */static intxmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,                       xmlSchemaValPtr * val, xmlNodePtr node, int flags){    xmlSchemaValPtr v;    xmlChar *norm = NULL;    int ret = 0;    if (xmlSchemaTypesInitialized == 0)        return (-1);    if (type == NULL)        return (-1);    if (val != NULL)        *val = NULL;    if ((flags == 0) && (value != NULL)) {        if ((type->flags != XML_SCHEMAS_STRING) &&            (type->flags != XML_SCHEMAS_NORMSTRING)) {            norm = xmlSchemaCollapseString(value);            if (norm != NULL)                value = norm;        }    }    switch (type->flags) {        case XML_SCHEMAS_UNKNOWN:            if (type == xmlSchemaTypeAnyTypeDef)                goto return0;            goto error;        case XML_SCHEMAS_STRING:            goto return0;        case XML_SCHEMAS_NORMSTRING:{                const xmlChar *cur = value;                while (*cur != 0) {                    if ((*cur == 0xd) || (*cur == 0xa) || (*cur == 0x9)) {                        goto return1;                    } else {                        cur++;                    }                }                if (val != NULL) {                    v = xmlSchemaNewValue(XML_SCHEMAS_NORMSTRING);                    if (v != NULL) {                        v->value.str = xmlStrdup(value);                        *val = v;                    } else {                        goto error;                    }                }                goto return0;            }        case XML_SCHEMAS_DECIMAL:{                const xmlChar *cur = value, *tmp;                unsigned int frac = 0, len, neg = 0;                unsigned long base = 0;                if (cur == NULL)                    goto return1;                if (*cur == '+')                    cur++;                else if (*cur == '-') {                    neg = 1;                    cur++;                }                tmp = cur;                while ((*cur >= '0') && (*cur <= '9')) {                    base = base * 10 + (*cur - '0');                    cur++;                }                len = cur - tmp;                if (*cur == '.') {                    cur++;                    tmp = cur;                    while ((*cur >= '0') && (*cur <= '9')) {                        base = base * 10 + (*cur - '0');                        cur++;                    }                    frac = cur - tmp;                }                if (*cur != 0)                    goto return1;                if (val != NULL) {                    v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL);                    if (v != NULL) {                        v->value.decimal.lo = base;                        v->value.decimal.sign = neg;                        v->value.decimal.frac = frac;                        v->value.decimal.total = frac + len;                        *val = v;                    }                }                goto return0;            }        case XML_SCHEMAS_TIME:        case XML_SCHEMAS_GDAY:        case XML_SCHEMAS_GMONTH:        case XML_SCHEMAS_GMONTHDAY:        case XML_SCHEMAS_GYEAR:        case XML_SCHEMAS_GYEARMONTH:        case XML_SCHEMAS_DATE:        case XML_SCHEMAS_DATETIME:            ret = xmlSchemaValidateDates(type->flags, value, val);            break;        case XML_SCHEMAS_DURATION:            ret = xmlSchemaValidateDuration(type, value, val);            break;        case XML_SCHEMAS_FLOAT:        case XML_SCHEMAS_DOUBLE:{                const xmlChar *cur = value;                int neg = 0;                if (cur == NULL)                    goto return1;                if ((cur[0] == 'N') && (cur[1] == 'a') && (cur[2] == 'N')) {                    cur += 3;                    if (*cur != 0)                        goto return1;                    if (val != NULL) {                        if (type == xmlSchemaTypeFloatDef) {                            v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);                            if (v != NULL) {                                v->value.f = (float) xmlXPathNAN;                            } else {                                xmlSchemaFreeValue(v);                                goto error;                            }                        } else {                            v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);                            if (v != NULL) {                                v->value.d = xmlXPathNAN;                            } else {                                xmlSchemaFreeValue(v);                                goto error;                            }                        }                        *val = v;                    }                    goto return0;                }                if (*cur == '-') {                    neg = 1;                    cur++;                }                if ((cur[0] == 'I') && (cur[1] == 'N') && (cur[2] == 'F')) {                    cur += 3;                    if (*cur != 0)                        goto return1;                    if (val != NULL) {                        if (type == xmlSchemaTypeFloatDef) {                            v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);                            if (v != NULL) {                                if (neg)                                    v->value.f = (float) xmlXPathNINF;                                else                                    v->value.f = (float) xmlXPathPINF;                            } else {                                xmlSchemaFreeValue(v);                                goto error;                            }                        } else {                            v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);                            if (v != NULL) {                                if (neg)                                    v->value.d = xmlXPathNINF;                                else                                    v->value.d = xmlXPathPINF;                            } else {                                xmlSchemaFreeValue(v);                                goto error;                            }                        }                        *val = v;                    }                    goto return0;                }                if ((neg == 0) && (*cur == '+'))                    cur++;                if ((cur[0] == 0) || (cur[0] == '+') || (cur[0] == '-'))                    goto return1;                while ((*cur >= '0') && (*cur <= '9')) {                    cur++;                }                if (*cur == '.') {                    cur++;                    while ((*cur >= '0') && (*cur <= '9'))                        cur++;                }                if ((*cur == 'e') || (*cur == 'E')) {                    cur++;                    if ((*cur == '-') || (*cur == '+'))                        cur++;                    while ((*cur >= '0') && (*cur <= '9'))                        cur++;                }                if (*cur != 0)                    goto return1;                if (val != NULL) {                    if (type == xmlSchemaTypeFloatDef) {                        v = xmlSchemaNewValue(XML_SCHEMAS_FLOAT);                        if (v != NULL) {                            if (sscanf((const char *) value, "%f",                                 &(v->value.f)) == 1) {                                *val = v;                            } else {                                xmlSchemaFreeValue(v);                                goto return1;                            }                        } else {                            goto error;                        }                    } else {                        v = xmlSchemaNewValue(XML_SCHEMAS_DOUBLE);                        if (v != NULL) {                            if (sscanf((const char *) value, "%lf",                                 &(v->value.d)) == 1) {                                *val = v;                            } else {                                xmlSchemaFreeValue(v);                                goto return1;                            }                        } else {                            goto error;                        }                    }                }                goto return0;            }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -