int cgiInit() { const char *str; if (init_called == true) { cgi_errno = CGIERR_REINIT; return false; } init_called = true; str = getenv("REQUEST_METHOD"); if (str == NULL || (strcmp(str, "POST") && strcmp(str, "GET"))) { cgi_errno = CGIERR_UREQM; return false; } listInit(); if (!strcmp(str, "POST")) if(initPost()==false) return(false); if (!strcmp(str, "GET")) if(initGet()==false) return(false); init_complete = true; return ECGI_SUCCESS; }
int main() { char* strMid = "9+(3-1)*3+10/2+1000*10"; Sequence mid; initSequence(&mid); initMid(&mid, strMid); printExpression(&mid); Sequence post; initSequence(&post); initPost(&mid, &post); printExpression(&post); printf("Result=%d\n", calculate(&post)); return 0; }
// You can see that there is a matching counterpart for every init function. // initPre() - destructPost() // create() - destruct() // initPost() - destructPre() Boolean construct::init(void) { if (isSuccessfull()) { if (initPre()) if (create()) { if (initPost()) return TRUE; else { destruct(); destructPost(); return FALSE; } } else { destructPost(); return FALSE; } else return FALSE; } else return FALSE; }
MessageBoxType8::MessageBoxType8(const QJsonObject &post, QWidget *parent) : MessageBox(post, parent){ initPost(post); }
MessageBox::MessageBox(const QJsonObject &post, const int &messageNum, QWidget *parent) : QWidget(parent) { initPost(post); }
MessageBoxType3::MessageBoxType3(const QJsonObject &post, QWidget *parent) : MessageBox(post, parent){ contentBox = dynamic_cast <ContentBox *>(parentWidget()); initPost(post); }