📄 cxxmultipleconstraints.c
字号:
#include "cxxmultipleconstraints.h"#include <string.h>#include <math.h>extern char *bVDAGlobalDLLExport;/*finds all of the alphabets in the subtype constraints */char* FindPermittedAlpha PARAMS((curr, cPermittedAlphabet, iAlphasize), AsnListNode* curr _AND_ unsigned char* cPermittedAlphabet _AND_ int *iAlphasize){ Subtype* currS_type=NULL; Subtype* fakeList = NULL; while(curr) { currS_type=curr->data; if(currS_type->choiceId==SUBTYPE_SINGLE && currS_type->a.single->choiceId==SUBTYPEVALUE_PERMITTEDALPHABET) { AsnListNode* currAlpha; if(currS_type->choiceId == SUBTYPE_OR) { currAlpha=currS_type->a.single->a.permittedAlphabet->a.or->first; PrintCxxPermittedAlphabetHandler(currAlpha, cPermittedAlphabet, iAlphasize); } else if(currS_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(currS_type->a.single->a.permittedAlphabet, fakeList->a.or); currAlpha = fakeList->a.or->first; PrintCxxPermittedAlphabetHandler(currAlpha, cPermittedAlphabet, iAlphasize); } } curr=curr->next; } return (char*)cPermittedAlphabet;}/*Prints the declarations for constraint variables in the header file*/int BasicTypeString_LISTS PARAMS((hdr, src, scList, iSCPresent, curr, currS_type), FILE* hdr _AND_ FILE* src _AND_ SizeConstraint *scList _AND_ int iSCPresent _AND_ AsnListNode* curr _AND_ Subtype* currS_type){ AsnListNode* pTmpnode; Subtype* fakeList = NULL; /*while there are nodes in the subtype list*/ while(curr) { /*point to the current subtype*/ currS_type=curr->data; if(currS_type->choiceId==SUBTYPE_SINGLE) { switch(currS_type->a.single->choiceId) { case SUBTYPEVALUE_VALUERANGE: { break; }/*case SUBTYPEVALUE_VALUERANGE*/ case SUBTYPEVALUE_SINGLEVALUE: { break; }/*case SUBTYPEVALUE_SINGLEVALUE*/ case SUBTYPEVALUE_SIZECONSTRAINT: { if(currS_type->choiceId == SUBTYPE_OR) { pTmpnode=currS_type->a.single->a.sizeConstraint->a.or->first; iSCPresent += SizeConstraint_LISTS(hdr, src, scList, iSCPresent, pTmpnode, currS_type); } else if(currS_type->choiceId == SUBTYPE_SINGLE) { fakeList = MT(Subtype); fakeList->choiceId = SUBTYPE_OR; APPEND(currS_type->a.single->a.sizeConstraint, fakeList->a.or); pTmpnode = fakeList->a.or->first; iSCPresent += SizeConstraint_LISTS(hdr, src, scList, iSCPresent, pTmpnode, currS_type); } break; }/*case SUBTYPEVALUE_SIZECONSTRAINT*/ default: { break; }/*default*/ }/*switch(curr......SINGLE)*/ }/*if(curr......SINGLE)*/ curr=curr->next; }/*while(curr)*/ src=src; /*avoids warning for unused parameter*/ return iSCPresent; }/*int BasicTypeString_LISTS*//*Finds all of the valueranges and single values in the subtype constraints*/int ValueRange_LISTS PARAMS((hdr, src, vrList, iVRPresent, curr, currS_type), FILE* hdr _AND_ FILE* src _AND_ ValueRange* vrList _AND_ int iVRPresent _AND_ AsnListNode* curr _AND_ Subtype* currS_type){ int found = 0; vrList = vrList; //int j = 0; hdr = hdr; /*while there are still subtyes found in the list*/ while(curr) { /*point to the current subtype*/ currS_type=curr->data; if(currS_type->choiceId==SUBTYPE_SINGLE) { switch(currS_type->a.single->choiceId) { case SUBTYPEVALUE_VALUERANGE: { if(iVRPresent < 15 && currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->choiceId==BASICVALUE_INTEGER) { found += 1; if(currS_type->a.single->a.valueRange->lowerEndValue->valueInclusive) { vrList[iVRPresent].lowerBound = currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.integer; } else { vrList[iVRPresent].lowerBound = currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.integer + 1; } if(currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->choiceId==BASICVALUE_INTEGER) { if(currS_type->a.single->a.valueRange->upperEndValue->valueInclusive) { vrList[iVRPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.integer; } else { vrList[iVRPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.integer + 1; } vrList[iVRPresent].upperBoundExists = 1; } else { vrList[iVRPresent].upperBound = 0; vrList[iVRPresent].upperBoundExists = 0; } iVRPresent++; } break; }/*case SUBTYPE_VALUERANGE*/ case SUBTYPEVALUE_SINGLEVALUE: { if(iVRPresent < 15 && currS_type->a.single->a.singleValue->basicValue->choiceId == BASICVALUE_INTEGER) { found += 1; vrList[iVRPresent].lowerBound = currS_type->a.single->a.singleValue->basicValue->a.integer; vrList[iVRPresent].upperBound = 0; vrList[iVRPresent].upperBoundExists = 2; iVRPresent ++; } break; }/*case SUBTYPE_SINGLEVALUE*/ case SUBTYPEVALUE_CONTAINED: default: { break; }/*default*/ }/*switch(curr......SINGLE)*/ }/*if(curr.......SINGLE)*/ curr=curr->next; }/*while(curr)*/ src=src;/*avoids warning on unused parameter*/ return found;}/*int BasicTypeInt_LISTS*//*assembles all permitted alphabets into one larger inclusive alphabet*/char* PrintCxxPermittedAlphabetHandler PARAMS((currAlpha, cPermittedAlphabet, iAlphaSize), AsnListNode* currAlpha _AND_ unsigned char* cPermittedAlphabet _AND_ int *iAlphasize){ Subtype* currS_type; int found = 0; int x = 0; /************************************/ /* To avoid warning */ currAlpha=currAlpha; /* Reference all Parameters */ /************************************/ /*while there are alphabets found*/ while(currAlpha) { currS_type=currAlpha->data; if(currS_type->choiceId==SUBTYPE_SINGLE && currS_type->a.single->choiceId==SUBTYPEVALUE_SINGLEVALUE) { /*concatenate the alphabets together*/ char* temp = currS_type->a.single->a.singleValue->basicValue->a.asciiText->octs; int tempSize = strlen(temp); while(tempSize) { found = 0; for(x = 0; x < *iAlphasize; x++) { if(cPermittedAlphabet[x] == temp[tempSize - 1]) found = 1; } if(found == 0) { cPermittedAlphabet[*iAlphasize] = temp[tempSize - 1]; *iAlphasize += 1; } tempSize--; } }/*if(curr.......SINGLEVALUE)*/ if(currS_type->choiceId==SUBTYPE_SINGLE && currS_type->a.single->choiceId==SUBTYPEVALUE_VALUERANGE) { char* temp; unsigned char lower; unsigned char upper; unsigned char c_alpha; /*concatenate the alphabets together*/ temp=currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.asciiText->octs; lower=temp[0]; temp=currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.asciiText->octs; upper=temp[0]; for( ; lower<=upper; lower++) { found = 0; c_alpha = lower; for(x = 0; x < *iAlphasize; x++) { if(cPermittedAlphabet[x] == c_alpha) found = 1; } if(found == 0) { cPermittedAlphabet[*iAlphasize] = c_alpha; *iAlphasize += 1; } } }/*if(curr.......VALUERANGE)*/ currAlpha=currAlpha->next; }/*while(currAlpha)*/ return (char*)cPermittedAlphabet;}/*char* PrintCxxPermittedAlphabetHandler*//*Handles Size Constraints*/int SizeConstraint_LISTS PARAMS((hdr, src, scList, iSCPresent, curr, currS_type), FILE* hdr _AND_ FILE* src _AND_ SizeConstraint* scList _AND_ int iSCPresent _AND_ AsnListNode* curr _AND_ Subtype* currS_type){ int found = 0; scList = scList; //int j = 0; hdr = hdr; /*while there are still subtyes found in the list*/ while(curr) { /*point to the current subtype*/ currS_type=curr->data; if(currS_type->choiceId==SUBTYPE_SINGLE) { switch(currS_type->a.single->choiceId) { case SUBTYPEVALUE_VALUERANGE: { found += 1; if((currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->choiceId==BASICVALUE_INTEGER && currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.integer <= 65536) || currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->choiceId==BASICVALUE_LOCALVALUEREF) { if(iSCPresent < 15 && currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->choiceId==BASICVALUE_INTEGER) { if(currS_type->a.single->a.valueRange->lowerEndValue->valueInclusive) { scList[iSCPresent].lowerBound = currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.integer; } else { scList[iSCPresent].lowerBound = currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.integer + 1; } } else if(currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->choiceId == BASICVALUE_LOCALVALUEREF) { scList[iSCPresent].lowerBound = currS_type->a.single->a.valueRange->lowerEndValue->endValue->basicValue->a.localValueRef->link->value->basicValue->a.integer; } if(currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->choiceId==BASICVALUE_INTEGER) { if(currS_type->a.single->a.valueRange->upperEndValue->valueInclusive) { scList[iSCPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.integer; } else { scList[iSCPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.integer + 1; } } else if(currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->choiceId == BASICVALUE_LOCALVALUEREF) { if(currS_type->a.single->a.valueRange->upperEndValue->valueInclusive) { scList[iSCPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.localValueRef->link->value->basicValue->a.integer; } else { scList[iSCPresent].upperBound = currS_type->a.single->a.valueRange->upperEndValue->endValue->basicValue->a.localValueRef->link->value->basicValue->a.integer + 1; } } scList[iSCPresent].upperBoundExists = 1; iSCPresent++; } else { scList[iSCPresent].upperBoundExists = 2; iSCPresent++; } break; }/*case SUBTYPE_VALUERANGE*/ case SUBTYPEVALUE_SINGLEVALUE: { found += 1; if(iSCPresent < 15 && currS_type->a.single->a.singleValue->basicValue->choiceId == BASICVALUE_INTEGER) { scList[iSCPresent].lowerBound = currS_type->a.single->a.singleValue->basicValue->a.integer; scList[iSCPresent].upperBound = 0; scList[iSCPresent].upperBoundExists = 0; iSCPresent++; } else if(currS_type->a.single->a.singleValue->basicValue->choiceId == BASICVALUE_LOCALVALUEREF) { scList[iSCPresent].lowerBound = currS_type->a.single->a.singleValue->basicValue->a.localValueRef->link->value->basicValue->a.integer; scList[iSCPresent].upperBound = 0; scList[iSCPresent].upperBoundExists = 0; scList[iSCPresent].upperBoundExists = 0; iSCPresent++; } break; }/*case SUBTYPE_SINGLEVALUE*/ case SUBTYPEVALUE_CONTAINED: default: { break; }/*default*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -