int cmp_tags(char *token,int num,char *str[]) { int i; if (token==NULL) return -1; if (str==NULL) return -1; for (i=0;i<num;i++) { if (str[i]==NULL) continue; if (cmp_tag(token,str[i]) !=0) return i; } return -1; }
void UserType::sortDescs() { if(!mDescriptors) return; struct cmp_tag { bool operator()(ClassDescriptor* lhs, ClassDescriptor* rhs) { return lhs->getDescriptorType() < rhs->getDescriptorType(); } }; std::sort(&mDescriptors[0], &mDescriptors[mDescSize], cmp_tag()); DescriptorType lt = RL_DESC_BASE; mFirstField = mFirstMethod = mFirstAccessor = mFirstService = mDescSize; for(size_t i = 0; i != mDescSize; ++i) { if(lt != RL_DESC_FIELD && mDescriptors[i]->getDescriptorType() == RL_DESC_FIELD) { mFirstField = i; lt = RL_DESC_FIELD; } else if(lt != RL_DESC_METHOD && mDescriptors[i]->getDescriptorType() == RL_DESC_METHOD) { mFirstMethod = i; lt = RL_DESC_METHOD; } else if(lt != RL_DESC_ACCESSOR && mDescriptors[i]->getDescriptorType() == RL_DESC_ACCESSOR) { mFirstAccessor = i; lt = RL_DESC_ACCESSOR; } else if(lt < RL_DESC_SERVICE_PARSING && mDescriptors[i]->getDescriptorType() > RL_DESC_ACCESSOR) { mFirstService = i; lt = RL_DESC_SERVICE_PARSING; } } if(mFirstAccessor == mDescSize) mFirstAccessor = mFirstService; if(mFirstMethod == mDescSize) mFirstMethod = mFirstAccessor; if(mFirstField == mDescSize) mFirstField = mFirstMethod; }
int HTMLWriter(char *buf,int sze,void *data) { int status=0; struct ScriptHTML *ptr; ptr=(struct ScriptHTML *)data; if (buf[0]=='<') { if ((sze>7) && (buf[1]=='!') && (buf[2]=='-') && (buf[3]=='-') && (buf[4]=='#') && (buf[sze-2]=='-') && (buf[sze-3]=='-')) { /* pass an SSI token to the SSI handler */ if ((ptr->iflg==-1) && (ptr->ssi.user !=NULL)) status=(ptr->ssi.user)(buf,sze,ptr->ssi.data); if (status !=0) return status; } else if ((sze>6) && (buf[1]=='!') && (buf[2]=='-') && (buf[3]=='-') && (buf[sze-2]=='-') && (buf[sze-3]=='-')) { /* a comment tag */ int i; char *tag; tag=malloc(sze-6); if (tag==NULL) return -1; memcpy(tag,buf+4,sze-7); tag[sze-7]=0; /* ignored sections */ if (ptr->ignore.txt !=NULL) { if (ptr->iflg==-1) { i=cmp_tags(tag,ptr->ignore.num,ptr->ignore.txt); if (i !=-1) ptr->iflg=i; } else if (cmp_tag(ptr->ignore.txt[ptr->iflg],tag)==1) { ptr->iflg=-1; free(tag); return 0; } } if (ptr->iflg !=-1) { free(tag); return 0; } /* post processed sections */ if (ptr->post.txt !=NULL) { if (ptr->pflg==-1) { i=cmp_tags(tag,ptr->post.num,ptr->post.txt); if (i !=-1) ptr->pflg=i; } else if (cmp_tag(ptr->post.txt[ptr->pflg],tag)==1) { if (ptr->postp.user !=NULL) status=(ptr->postp.user) (NULL,0,ptr->post.txt[ptr->pflg],ptr->postp.data); ptr->pflg=-1; free(tag); return status; } } if (ptr->pflg !=-1) { free(tag); return 0; } /* search and replace */ if ((ptr->search.txt !=NULL)) { i=cmp_tags(tag,ptr->search.num,ptr->search.txt); if (i !=-1) { if ((ptr->replace.txt !=NULL) && (ptr->replace.txt[i] !=NULL) && (ptr->text.user !=NULL)) status=(ptr->text.user)(ptr->replace.txt[i], strlen(ptr->replace.txt[i]), ptr->text.data); free(tag); return status; } } if (ptr->remove.txt !=NULL) { i=cmp_tags(tag,ptr->remove.num,ptr->remove.txt); if (i !=-1) { free(tag); return 0; } } if (ptr->text.user !=NULL) status=(ptr->text.user)("<",1,ptr->text.data); if (status==0) status=ScriptDecode(ptr->ptr,buf+1,sze-2); if ((status==0) && (ptr->text.user !=NULL)) status=(ptr->text.user)(">",1,ptr->text.data); free(tag); return status; } else { /* regular HTML tag */ if (ptr->pflg !=-1) { if (ptr->postp.user !=NULL) status=(ptr->postp.user)("<",1,ptr->post.txt[ptr->pflg], ptr->postp.data); if (status==0) status=ScriptDecode(ptr->ptr,buf+1,sze-2); if ((status==0) && (ptr->postp.user !=NULL)) status=(ptr->postp.user)(">",1,ptr->post.txt[ptr->pflg], ptr->postp.data); } else if (ptr->iflg==-1) { if (ptr->text.user !=NULL) status=(ptr->text.user)("<",1,ptr->text.data); if (status==0) status=ScriptDecode(ptr->ptr,buf+1,sze-2); if ((status==0) && (ptr->text.user !=NULL)) status=(ptr->text.user)(">",1,ptr->text.data); } } return status; } if (ptr->pflg !=-1) { if (ptr->postp.user !=NULL) status=(ptr->postp.user)(buf,sze, ptr->post.txt[ptr->pflg],ptr->postp.data); } else if ((ptr->iflg==-1) && (ptr->text.user !=NULL)) status=(ptr->text.user)(buf,sze,ptr->text.data); return status; }