Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7751 → Rev 7752

/programs/cmm/TWB/parce_tag.h
1,55 → 1,106
bool GetNextParam()
 
struct _tag
{
byte quotes = NULL;
int i;
char name[32];
char params[5000];
bool opened;
collection attributes;
collection values;
bool is();
bool reset();
bool parse_params();
bool get_next_param();
dword get_value_of();
} tag;
if (!tagparam) return false;
bool _tag::is(dword _text)
{
if ( !strcmp(#tag.name, _text) ) {
return true;
} else {
return false;
}
}
 
bool _tag::reset()
{
if (!name) return false;
name = NULL;
opened = true;
attributes.drop();
values.drop();
attributes.add("ZERO");
values.add("NULL");
return true;
}
 
bool _tag::parse_params()
{
bool result = false;
if (!name) return false;
if (debug_mode) {
debug("tag: "); debugln(#tag);
debug("tagparam: "); debugln(#tagparam);
debugln(" ");
debugln(" ");
debug("tag: "); debugln(#name);
debug("params: "); debugln(#params);
debugln(" ");
}
while (get_next_param()) {
result = true;
if (debug_mode) {
debug("attribute: "); debugln(attributes.get(attributes.count-1));
debug("value: "); debugln(values.get(values.count-1));
debugln(" ");
}
};
return result;
}
i = strlen(#tagparam) - 1;
bool _tag::get_next_param()
{
byte quotes = NULL;
int i;
unsigned char val[4000];
unsigned char attr[4000];
 
if (tagparam[i] == '/') i--;
if (!params) return false;
 
while (i>0) && (__isWhite(tagparam[i])) i--;
i = strlen(#params) - 1;
if (params[i] == '/') i--;
while (i>0) && (__isWhite(params[i])) i--;
 
if (tagparam[i] == '"') || (tagparam[i] == '\'')
if (params[i] == '"') || (params[i] == '\'')
{
//find VAL end
quotes = tagparam[i];
tagparam[i] = '\0'; i--;
//remove quotes
quotes = params[i];
params[i] = EOS;
i--;
 
//find VAL start and copy
i = strrchr(#tagparam, quotes);
strlcpy(#val, #tagparam + i, sizeof(val)-1);
tagparam[i] = '\0'; i--;
i = strrchr(#params, quotes);
strlcpy(#val, #params + i, sizeof(val)-1);
params[i] = EOS;
i--;
 
//find ATTR end
while (i > 0) && (tagparam[i] != '=') i--;
tagparam[i+1] = '\0';
while (i > 0) && (params[i] != '=') i--;
params[i+1] = EOS;
}
else
{
//find VAL end
//already have
 
//find VAL start and copy
while (i > 0) && (tagparam[i] != '=') i--;
while (i > 0) && (params[i] != '=') i--;
i++;
strlcpy(#val, #tagparam + i, sizeof(val)-1);
// tagparam[i] = '\0';
strlcpy(#val, #params + i, sizeof(val)-1);
 
//find ATTR end
//already have
//already have ATTR end
}
 
//find ATTR start and copy
while (i>0) && (!__isWhite(tagparam[i])) i--;
strlcpy(#attr, #tagparam + i + 1, sizeof(attr)-1);
tagparam[i] = '\0';
while (i>0) && (!__isWhite(params[i])) i--;
strlcpy(#attr, #params + i + 1, sizeof(attr)-1);
strlwr(#attr);
params[i] = '\0';
//fix case: src=./images/KolibriOS_logo2.jpg?sid=e8ece8b38b
i = strchr(#attr,'=');
58,15 → 109,18
ESBYTE[i+1] = '\0';
}
 
strlwr(#attr);
attributes.add(#attr);
values.add(#val);
 
if (debug_mode) {
debug("val: "); debugln(#val);
debug("attr: "); debugln(#attr);
debugln(" ");
return true;
}
 
return true;
dword _tag::get_value_of(dword _attr_name)
{
int pos = attributes.get_pos_by_name(_attr_name);
if (pos == -1) {
return 0;
} else {
return values.get(pos);
}
 
 
}