static inline int INGfetchAll(INGresult *ing_res) { ING_ROW *row; IISQLDA *desc; int linecount = -1; desc = ing_res->sqlda; /* # line 409 "myingres.sc" */ /* open */ { IIsqInit(&sqlca); IIcsOpen((char *)"c2",20273,8927); IIwritio(0,(short *)0,1,32,0,(char *)"s2"); IIcsQuery((char *)"c2",20273,8927); if (sqlca.sqlcode < 0) goto bail_out; } /* # line 413 "myingres.sc" */ /* host code */ linecount = 0; do { /* # line 415 "myingres.sc" */ /* fetch */ { IIsqInit(&sqlca); if (IIcsRetScroll((char *)"c2",20273,8927,-1,-1) != 0) { IIcsDaGet(0,desc); IIcsERetrieve(); } /* IIcsRetrieve */ } /* # line 417 "myingres.sc" */ /* host code */ if (sqlca.sqlcode == 0 || sqlca.sqlcode == -40202) { /* * Allocate space for fetched row */ row = INGgetRowSpace(ing_res); /* * Initialize list when encountered first time */ if (ing_res->first_row == 0) { ing_res->first_row = row; /* head of the list */ ing_res->first_row->next = NULL; ing_res->act_row = ing_res->first_row; } ing_res->act_row->next = row; /* append row to old act_row */ ing_res->act_row = row; /* set row as act_row */ row->row_number = linecount++; } } while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) ); /* # line 438 "myingres.sc" */ /* close */ { IIsqInit(&sqlca); IIcsClose((char *)"c2",20273,8927); } /* # line 440 "myingres.sc" */ /* host code */ ing_res->status = ING_COMMAND_OK; ing_res->num_rows = linecount; bail_out: return linecount; }
Owners_record *getowners(void) { Owners_record *head = 0 ; struct { char parentname[12 ]; char parentcity[11 ]; char childname[22 ]; char childcity[11 ]; float fraction; } Owners; short null_indicator[5]; /* # line 3511 "getowners.sc" */ /* connect */ { IIsqInit(&sqlca); IIsqConnect(0,"hotel",(char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3514 "getowners.sc" */ /* open */ { IIsqInit(&sqlca); IIcsOpen("cursor1",26754,24986); IIwritio(0,(short *)0,1,32,0,"select * from owners"); IIwritio(0,(short *)0,1,32,0," for readonly "); IIcsQuery("cursor1",26754,24986); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3515 "getowners.sc" */ /* host code */ while (sqlca.sqlcode == 0) { /* # line 3516 "getowners.sc" */ /* fetch */ { IIsqInit(&sqlca); if (IIcsRetrieve("cursor1",26754,24986) != 0) { IIcsGetio(&null_indicator[0],1,32,11,(Owners).parentname); IIcsGetio(&null_indicator[1],1,32,10,(Owners).parentcity); IIcsGetio(&null_indicator[2],1,32,21,(Owners).childname); IIcsGetio(&null_indicator[3],1,32,10,(Owners).childcity); IIcsGetio(&null_indicator[4],1,31,4,&(Owners).fraction); IIcsERetrieve(); } /* IIcsRetrieve */ if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3517 "getowners.sc" */ /* host code */ if (sqlca.sqlcode == 0) { head = add_orecord(head, Owners.parentname, Owners.parentcity, Owners.childname, Owners.childcity, Owners.fraction); } } /* # line 3523 "getowners.sc" */ /* close */ { IIsqInit(&sqlca); IIcsClose("cursor1",26754,24986); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3524 "getowners.sc" */ /* commit */ { IIsqInit(&sqlca); IIxact(3); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3525 "getowners.sc" */ /* disconnect */ { IIsqInit(&sqlca); IIsqDisconnect(); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3527 "getowners.sc" */ /* host code */ return head; }
void IIpcsERetrieve(void) { IIcsERetrieve(); }
Hotels_record *gethotels(void) { Hotels_record *head = 0 ; struct { char hname[22 ]; char hcity[11 ]; } Hotels; short null_indicator[2]; /* # line 3508 "gethotels.sc" */ /* connect */ { IIsqInit(&sqlca); IIsqConnect(0,"hotel",(char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3511 "gethotels.sc" */ /* open */ { IIsqInit(&sqlca); IIcsOpen("cursor2",26752,22733); IIwritio(0,(short *)0,1,32,0,"select hname, hcity from hotel"); IIwritio(0,(short *)0,1,32,0," for readonly "); IIcsQuery("cursor2",26752,22733); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3512 "gethotels.sc" */ /* host code */ while (sqlca.sqlcode == 0) { /* # line 3513 "gethotels.sc" */ /* fetch */ { IIsqInit(&sqlca); if (IIcsRetrieve("cursor2",26752,22733) != 0) { IIcsGetio(&null_indicator[0],1,32,21,(Hotels).hname); IIcsGetio(&null_indicator[1],1,32,10,(Hotels).hcity); IIcsERetrieve(); } /* IIcsRetrieve */ if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3514 "gethotels.sc" */ /* host code */ if (sqlca.sqlcode == 0) { head = add_hrecord(head, Hotels.hname, Hotels.hcity); } } /* # line 3519 "gethotels.sc" */ /* close */ { IIsqInit(&sqlca); IIcsClose("cursor2",26752,22733); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3520 "gethotels.sc" */ /* commit */ { IIsqInit(&sqlca); IIxact(3); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3521 "gethotels.sc" */ /* disconnect */ { IIsqInit(&sqlca); IIsqDisconnect(); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 3523 "gethotels.sc" */ /* host code */ return head; }
/** * load initial data * * TODO:350:M: Implement dmfTable data load * This function will also be called by the cache helper to load * the container again (after the container free function has been * called to free the previous contents). * * @param container container to which items should be inserted * * @retval MFD_SUCCESS : success. * @retval MFD_RESOURCE_UNAVAILABLE : Can't access data source * @retval MFD_ERROR : other error. * * This function is called to load the index(es) (and data, optionally) * for the every row in the data set. * * @remark * While loading the data, the only important thing is the indexes. * If access to your data is cheap/fast (e.g. you have a pointer to a * structure in memory), it would make sense to update the data here. * If, however, the accessing the data invovles more work (e.g. parsing * some other existing data, or peforming calculations to derive the data), * then you can limit yourself to setting the indexes and saving any * information you will need later. Then use the saved information in * dmfTable_row_prep() for populating data. * * @note * If you need consistency between rows (like you want statistics * for each row to be from the same time frame), you should set all * data here. * */ int dmfTable_container_load(netsnmp_container * container) { dmfTable_rowreq_ctx *rowreq_ctx; size_t count = 0; /* * temporary storage for index values */ /* * server(1)/OCTETSTR/ASN_OCTET_STR/char(char)//L/A/w/e/r/d/h */ /** 128 - 1(entry) - 1(col) - 1(other indexes) = 113 */ char server[113]; size_t server_len; /* * pagesize(2)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ long pagesize; # include "dmfcache.c" /* # line 245 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGTL(("verbose:dmfTable:dmfTable_container_load", "called\n")); /* * open data connection. */ /* # line 252 "dmfTable_data_access.sc" */ /* connect */ { IIsqInit(&sqlca); IIsqConnect(0,(char *)"imadb",(char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 254 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGTL(("verbose:dmfTable","Connected to database\n")); /* # line 256 "dmfTable_data_access.sc" */ /* execute procedure */ { IIsqInit(&sqlca); IILQpriProcInit(2,(char *)"ima_set_vnode_domain"); while (IILQprsProcStatus(0) != 0) { if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* IILQprsProcStatus */ } /* # line 257 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGTL(("verbose:dmfTable","Vnode domain set\n")); /* * TODO:351:M: |-> Load/update data in the dmfTable container. * loop over your dmfTable data, allocate a rowreq context, * set the index(es) [and data, optionally] and insert into * the container. */ /* # line 266 "dmfTable_data_access.sc" */ /* open */ { IIsqInit(&sqlca); IIcsOpen((char *)"dmfcsr",31844,21499); IIwritio(0,(short *)0,1,32,0,(char *) "select * from ima_dmf_cache_stats"); IIwritio(0,(short *)0,1,32,0,(char *)" for readonly "); IIcsQuery((char *)"dmfcsr",31844,21499); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 267 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGTL(("verbose:dmfTable","Cursor opened\n")); while (1) { /* # line 274 "dmfTable_data_access.sc" */ /* fetch */ { IIsqInit(&sqlca); if (IIcsRetScroll((char *)"dmfcsr",31844,21499,0,0) != 0) { IIcsGetio((short *)0,1,32,64,(dmfrec).server); IIcsGetio((short *)0,1,30,sizeof((dmfrec).pagesize),&(dmfrec).pagesize); IIcsGetio((short *)0,1,30,sizeof((dmfrec).forceCount),& (dmfrec).forceCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).ioWaitCount),& (dmfrec).ioWaitCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).groupBufferReadCount),& (dmfrec).groupBufferReadCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).groupBufferWriteCount),& (dmfrec).groupBufferWriteCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).fixCount),&(dmfrec).fixCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).unfixCount),& (dmfrec).unfixCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).readCount),&(dmfrec).readCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).writeCount),& (dmfrec).writeCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).hitCount),&(dmfrec).hitCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).dirtyUnfixCount),& (dmfrec).dirtyUnfixCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).pagesStillValid),& (dmfrec).pagesStillValid); IIcsGetio((short *)0,1,30,sizeof((dmfrec).pagesInvalid),& (dmfrec).pagesInvalid); IIcsGetio((short *)0,1,30,sizeof((dmfrec).bufferCount),& (dmfrec).bufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).pageBufferCount),& (dmfrec).pageBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).fLimit),&(dmfrec).fLimit); IIcsGetio((short *)0,1,30,sizeof((dmfrec).mLimit),&(dmfrec).mLimit); IIcsGetio((short *)0,1,30,sizeof((dmfrec).wbStart),&(dmfrec).wbStart); IIcsGetio((short *)0,1,30,sizeof((dmfrec).wbEnd),&(dmfrec).wbEnd); IIcsGetio((short *)0,1,30,sizeof((dmfrec).hashBucketCount),& (dmfrec).hashBucketCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).groupBufferCount),& (dmfrec).groupBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).groupBufferSize),& (dmfrec).groupBufferSize); IIcsGetio((short *)0,1,30,sizeof((dmfrec).cacheStatus),& (dmfrec).cacheStatus); IIcsGetio((short *)0,1,30,sizeof((dmfrec).freeBufferCount),& (dmfrec).freeBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).freeBufferWaiters),& (dmfrec).freeBufferWaiters); IIcsGetio((short *)0,1,30,sizeof((dmfrec).fixedBufferCount),& (dmfrec).fixedBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).modifiedBufferCount),& (dmfrec).modifiedBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).freeGroupBufferCount),& (dmfrec).freeGroupBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).fixedGroupBufferCount),& (dmfrec).fixedGroupBufferCount); IIcsGetio((short *)0,1,30,sizeof((dmfrec).modifiedGroupBufferCount),& (dmfrec).modifiedGroupBufferCount); IIcsERetrieve(); } /* IIcsRetrieve */ if (sqlca.sqlcode == 100) goto close_dmfcsr; else if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 275 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGTL(("verbose:dmfTable","SQL fetched\n")); DEBUGMSGTL(("verbose:dmfTable","Server %s\n",dmfrec.server)); DEBUGMSGTL(("verbose:dmfTable","Page Size %d\n",dmfrec.pagesize)); DEBUGMSGTL(("verbose:dmfTable","Fix Count %d\n",dmfrec.fixCount)); /* * parse strings into variables */ strcpy(server,dmfrec.server); server_len = strlen(server); /* * TODO:352:M: | |-> set indexes in new dmfTable rowreq context. * data context will be set from the param (unless NULL, * in which case a new data context will be allocated) */ rowreq_ctx = dmfTable_allocate_rowreq_ctx(NULL); if (NULL == rowreq_ctx) { snmp_log(LOG_ERR, "memory allocation failed\n"); return MFD_RESOURCE_UNAVAILABLE; } DEBUGMSGTL(("verbose:dmfTable","Setting index %s %d %d\n", dmfrec.server, server_len, dmfrec.pagesize)); if (MFD_SUCCESS != dmfTable_indexes_set(rowreq_ctx, dmfrec.server, strlen(dmfrec.server), dmfrec.pagesize)) { snmp_log(LOG_ERR, "error setting index while loading " "dmfTable data.\n"); dmfTable_release_rowreq_ctx(rowreq_ctx); continue; } DEBUGMSGTL(("verbose:dmfTable","Index set\n")); /* * TODO:352:r: | |-> populate dmfTable data context. * Populate data context here. (optionally, delay until row prep) */ /* * TRANSIENT or semi-TRANSIENT data: * copy data or save any info needed to do it in row_prep. */ /* * setup/save data for forceCount * forceCount(3)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.forceCount = dmfrec.forceCount; /* * setup/save data for ioWaitCount * ioWaitCount(4)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.ioWaitCount = dmfrec.ioWaitCount; /* * setup/save data for groupBufferReadCount * groupBufferReadCount(5)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.groupBufferReadCount = dmfrec.groupBufferReadCount; /* * setup/save data for groupBufferWriteCount * groupBufferWriteCount(6)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.groupBufferWriteCount = dmfrec.groupBufferWriteCount; /* * setup/save data for fixCount * fixCount(7)/INTEGER32/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.fixCount = dmfrec.fixCount; /* * setup/save data for unfixCount * unfixCount(8)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.unfixCount = dmfrec.unfixCount; /* * setup/save data for readCount * readCount(9)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.readCount = dmfrec.readCount; /* * setup/save data for writeCount * writeCount(10)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.writeCount = dmfrec.writeCount; /* * setup/save data for hitCount * hitCount(11)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.hitCount = dmfrec.hitCount; /* * setup/save data for dirtyUnfixCount * dirtyUnfixCount(12)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.dirtyUnfixCount = dmfrec.dirtyUnfixCount; /* * setup/save data for pagesStillValid * pagesStillValid(13)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.pagesStillValid = dmfrec.pagesStillValid; /* * setup/save data for pagesInvalid * pagesInvalid(14)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.pagesInvalid = dmfrec.pagesInvalid; /* * setup/save data for bufferCount * bufferCount(15)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.bufferCount = dmfrec.bufferCount; /* * setup/save data for pageBufferCount * pageBufferCount(16)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.pageBufferCount = dmfrec.pageBufferCount; /* * setup/save data for fLimit * fLimit(17)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.fLimit = dmfrec.fLimit; /* * setup/save data for mLimit * mLimit(18)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.mLimit = dmfrec.mLimit; /* * setup/save data for wbStart * wbStart(19)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.wbStart = dmfrec.wbStart; /* * setup/save data for wbEnd * wbEnd(20)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.wbEnd = dmfrec.wbEnd; /* * setup/save data for hashBucketCount * hashBucketCount(21)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.hashBucketCount = dmfrec.hashBucketCount; /* * setup/save data for groupBufferCount * groupBufferCount(22)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.groupBufferCount = dmfrec.groupBufferCount; /* * setup/save data for groupBufferSize * groupBufferSize(23)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.groupBufferSize = dmfrec.groupBufferSize; /* * setup/save data for cacheStatus * cacheStatus(24)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.cacheStatus = dmfrec.cacheStatus; /* * setup/save data for freeBufferCount * freeBufferCount(25)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.freeBufferCount = dmfrec.freeBufferCount; /* * setup/save data for freeBufferWaiters * freeBufferWaiters(26)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.freeBufferWaiters = dmfrec.freeBufferWaiters; /* * setup/save data for fixedBufferCount * fixedBufferCount(27)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.fixedBufferCount = dmfrec.fixedBufferCount; /* * setup/save data for modifiedBufferCount * modifiedBufferCount(28)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.modifiedBufferCount = dmfrec.modifiedBufferCount; /* * setup/save data for freeGroupBufferCount * freeGroupBufferCount(29)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.freeGroupBufferCount = dmfrec.freeGroupBufferCount; /* * setup/save data for fixedGroupBufferCount * fixedGroupBufferCount(30)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.fixedGroupBufferCount = dmfrec.fixedGroupBufferCount; /* * setup/save data for modifiedGroupBufferCount * modifiedGroupBufferCount(31)/INTEGER/ASN_INTEGER/long(long)//l/A/w/e/r/d/h */ /** no mapping */ rowreq_ctx->data.modifiedGroupBufferCount = dmfrec.modifiedGroupBufferCount; /* * insert into table container */ CONTAINER_INSERT(container, rowreq_ctx); ++count; } close_dmfcsr: /* # line 533 "dmfTable_data_access.sc" */ /* close */ { IIsqInit(&sqlca); IIcsClose((char *)"dmfcsr",31844,21499); if (sqlca.sqlcode < 0) IIsqStop(&sqlca); } /* # line 536 "dmfTable_data_access.sc" */ /* host code */ DEBUGMSGT(("verbose:dmfTable:dmfTable_container_load", "inserted %d records\n", count)); return MFD_SUCCESS; } /* dmfTable_container_load */