RMON_ENTRY_T *ROWAPI_header_ControlEntry (struct variable * vp, oid * name, size_t * length, int exact, size_t * var_len, TABLE_DEFINTION_T * table_ptr, void *entry_ptr, size_t entry_size) { long ctrl_index; RMON_ENTRY_T *hdr = NULL; if (0 != AGUTIL_advance_index_name (vp, name, length, exact)) { ag_trace ("cannot advance_index_name"); return NULL; } ctrl_index = vp->namelen >= *length ? 0 : name[vp->namelen]; if (exact) { if (ctrl_index) hdr = ROWAPI_find (table_ptr, ctrl_index); } else { if (ctrl_index) hdr = ROWAPI_next (table_ptr, ctrl_index); else hdr = ROWAPI_first (table_ptr); if (hdr) { /* set new index */ name[vp->namelen] = hdr->ctrl_index; *length = vp->namelen + 1; } } if (hdr) memcpy (entry_ptr, hdr->body, entry_size); return hdr; }
RMON_ENTRY_T * ROWDATAAPI_header_DataEntry(struct variable * vp, oid * name, size_t * length, int exact, size_t * var_len, TABLE_DEFINTION_T * table_ptr, SCROLLER_T * (*extract_scroller) (void *body), size_t data_size, void *entry_ptr) { long ctrl_indx, data_index; RMON_ENTRY_T *hdr = NULL; SCROLLER_T *scrlr; NEXTED_PTR_T *bptr = NULL; register u_long iii; if (0 != AGUTIL_advance_index_name(vp, name, length, exact)) { ag_trace("cannot advance_index_name"); return NULL; } ctrl_indx = vp->namelen >= *length ? 0 : name[vp->namelen]; if (ctrl_indx) data_index = ((int)(vp->namelen + 1) >= (int)*length) ? 0 : name[vp->namelen + 1]; else data_index = 0; if (exact) { if (ctrl_indx && data_index) { hdr = ROWAPI_find(table_ptr, ctrl_indx); if (hdr) { scrlr = extract_scroller(hdr->body); bptr = scrlr->first_data_ptr; for (iii = 0; iii < scrlr->data_stored && bptr; iii++, bptr = bptr->next) { if ((long)bptr->data_index == data_index) break; } if (!bptr) hdr = NULL; } } } else { if (ctrl_indx) hdr = ROWAPI_find(table_ptr, ctrl_indx); else hdr = ROWAPI_first(table_ptr); if (hdr) { scrlr = extract_scroller(hdr->body); /* * ag_trace ("get next after (%d %d)", (int) ctrl_indx, (int) data_index); */ bptr = scrlr->first_data_ptr; for (iii = 0; iii < scrlr->data_stored && bptr; iii++, bptr = bptr->next) { if (bptr->data_index && (long)bptr->data_index > data_index) break; } if (bptr && (long)bptr->data_index <= data_index) bptr = NULL; if (!bptr) { /* travel to next row */ /* * ag_trace ("Dbg: travel to next row"); */ for (hdr = hdr->next; hdr; hdr = hdr->next) { if (RMON1_ENTRY_VALID != hdr->status) continue; scrlr = extract_scroller(hdr->body); if (scrlr->data_stored <= 0) continue; for (bptr = scrlr->first_data_ptr; bptr; bptr = bptr->next) { if (bptr->data_index) break; } if (bptr) break; } } if (bptr) { /* set new index */ /* * ag_trace ("Dbg: So (%d %d)", (int) hdr->index, (int) bptr->data_index); */ name[vp->namelen] = hdr->ctrl_index; name[vp->namelen + 1] = bptr->data_index; *length = vp->namelen + 2; } else hdr = NULL; } } if (hdr) memcpy(entry_ptr, bptr, data_size); return hdr; }