void STBaselineTable::appenddata(int scanno, int cycleno, int beamno, int ifno, int polno, int freqid, Double time, bool apply, STBaselineFunc::FuncName ftype, vector<int> fpar, vector<float> ffpar, Vector<uInt> mask, vector<float> res, float rms, int nchan, float cthres, int citer, float lfthres, int lfavg, vector<int> lfedge) { Vector<Int> fparam(fpar.size()); for (uInt i = 0; i < fpar.size(); ++i) { fparam[i] = fpar[i]; } Vector<uInt> edge(lfedge.size()); for (uInt i = 0; i < lfedge.size(); ++i) { edge[i] = lfedge[i]; } appenddata(uInt(scanno), uInt(cycleno), uInt(beamno), uInt(ifno), uInt(polno), uInt(freqid), time, Bool(apply), ftype, fparam, Vector<Float>(ffpar), mask, Vector<Float>(res), Float(rms), uInt(nchan), Float(cthres), uInt(citer), Float(lfthres), uInt(lfavg), edge); }
void main() { char choice; while(1) { clrscr(); printf("\n\n ++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"); printf("================ telephone directory database ================="); printf("\n\n"); printf("\n 1 : add record in the database "); printf("\n 2 : find record from the database "); printf("\n 3 : read all record in the database "); printf("\n 4 : quit from this software"); printf("\n\n enter your choice"); fflush(stdin); choice=getchar(); switch(choice) { case '1' : appenddata(); break; case '2' : finddata(); break; case '3' : showalldata(); break; case '4' : quit(); case '23' : exit(1); } } }
void STBaselineTable::appenddata(int scanno, int cycleno, int beamno, int ifno, int polno, int freqid, Double time, bool apply, STBaselineFunc::FuncName ftype, int fpar, vector<float> ffpar, Vector<uInt> mask, vector<float> res, float rms, int nchan, float cthres, int citer, float lfthres, int lfavg, vector<int> lfedge) { vector<int> fparam(1); fparam[0] = fpar; appenddata(scanno, cycleno, beamno, ifno, polno, freqid, time, apply, ftype, fparam, ffpar, mask, res, rms, nchan, cthres, citer, lfthres, lfavg, lfedge); }
int getpart(char **outbuf, size_t *outlen, const char *main, const char *sub, FILE *stream) { # define MAX_TAG_LEN 79 char couter[MAX_TAG_LEN+1]; /* current outermost section */ char cmain[MAX_TAG_LEN+1]; /* current main section */ char csub[MAX_TAG_LEN+1]; /* current sub section */ char ptag[MAX_TAG_LEN+1]; /* potential tag */ char patt[MAX_TAG_LEN+1]; /* potential attributes */ char *buffer = NULL; char *ptr; char *end; union { ssize_t sig; size_t uns; } len; size_t bufsize = 0; size_t outalloc = 256; int in_wanted_part = 0; int base64 = 0; int error; enum { STATE_OUTSIDE = 0, STATE_OUTER = 1, STATE_INMAIN = 2, STATE_INSUB = 3, STATE_ILLEGAL = 4 } state = STATE_OUTSIDE; *outlen = 0; *outbuf = malloc(outalloc); if(!*outbuf) return GPE_OUT_OF_MEMORY; *(*outbuf) = '\0'; couter[0] = cmain[0] = csub[0] = ptag[0] = patt[0] = '\0'; while((error = readline(&buffer, &bufsize, stream)) == GPE_OK) { ptr = buffer; EAT_SPACE(ptr); if('<' != *ptr) { if(in_wanted_part) { show(("=> %s", buffer)); error = appenddata(outbuf, outlen, &outalloc, buffer, base64); if(error) break; } continue; } ptr++; if('/' == *ptr) { /* ** closing section tag */ ptr++; end = ptr; EAT_WORD(end); if((len.sig = end - ptr) > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } memcpy(ptag, ptr, len.uns); ptag[len.uns] = '\0'; if((STATE_INSUB == state) && !strcmp(csub, ptag)) { /* end of current sub section */ state = STATE_INMAIN; csub[0] = '\0'; if(in_wanted_part) { /* end of wanted part */ in_wanted_part = 0; break; } } else if((STATE_INMAIN == state) && !strcmp(cmain, ptag)) { /* end of current main section */ state = STATE_OUTER; cmain[0] = '\0'; if(in_wanted_part) { /* end of wanted part */ in_wanted_part = 0; break; } } else if((STATE_OUTER == state) && !strcmp(couter, ptag)) { /* end of outermost file section */ state = STATE_OUTSIDE; couter[0] = '\0'; if(in_wanted_part) { /* end of wanted part */ in_wanted_part = 0; break; } } } else if(!in_wanted_part) { /* ** opening section tag */ /* get potential tag */ end = ptr; EAT_WORD(end); if((len.sig = end - ptr) > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } memcpy(ptag, ptr, len.uns); ptag[len.uns] = '\0'; /* ignore comments, doctypes and xml declarations */ if(('!' == ptag[0]) || ('?' == ptag[0])) { show(("* ignoring (%s)", buffer)); continue; } /* get all potential attributes */ ptr = end; EAT_SPACE(ptr); end = ptr; while(*end && ('>' != *end)) end++; if((len.sig = end - ptr) > MAX_TAG_LEN) { error = GPE_NO_BUFFER_SPACE; break; } memcpy(patt, ptr, len.uns); patt[len.uns] = '\0'; if(STATE_OUTSIDE == state) { /* outermost element (<testcase>) */ strcpy(couter, ptag); state = STATE_OUTER; continue; } else if(STATE_OUTER == state) { /* start of a main section */ strcpy(cmain, ptag); state = STATE_INMAIN; continue; } else if(STATE_INMAIN == state) { /* start of a sub section */ strcpy(csub, ptag); state = STATE_INSUB; if(!strcmp(cmain, main) && !strcmp(csub, sub)) { /* start of wanted part */ in_wanted_part = 1; if(strstr(patt, "base64=")) /* bit rough test, but "mostly" functional, */ /* treat wanted part data as base64 encoded */ base64 = 1; } continue; } } if(in_wanted_part) { show(("=> %s", buffer)); error = appenddata(outbuf, outlen, &outalloc, buffer, base64); if(error) break; } } /* while */ if(buffer) free(buffer); if(error != GPE_OK) { if(error == GPE_END_OF_FILE) error = GPE_OK; else { if(*outbuf) free(*outbuf); *outbuf = NULL; *outlen = 0; } } return error; }