Пример #1
0
static int parse_line(char *type, double *cur_time, unsigned int *timestamp, unsigned int *data_size, char **data)
{
	char *line = one_line(index_fp);
	if (!line) {
		printf("Warning: No more lines in [%s]\n", input_path);
		return -1;
	}
	int file_path_size = strlen(input_path) + strlen(line) + 50;
	char *file_path = malloc(file_path_size);
	snprintf(file_path, file_path_size, "%s/%s", input_path, line);
	// Open file
	FILE *cur_fp = fopen(file_path, "r");
	if (!cur_fp) {
		printf("Error: Cannot open file [%s]\n", file_path);
		exit(1);
	}
	// Parse data from file name
	*data_size = get_data_size(cur_fp);
	sscanf(line, "%c-%lf-%u-%*s", type, cur_time, timestamp);
	*data = malloc(*data_size);
	if (fread(*data, *data_size, 1, cur_fp) != 1) {
		printf("Error: Couldn't read entire file.\n");
		return -1;
	}
	fclose(cur_fp);
	free(line);
	free(file_path);
	return 0;
}
unsigned char ImageReader::get_data_byte(int index)
{
	if ( index < get_data_size() )
		return this->data[index];
	else
		return 0;
}
Пример #3
0
size_t mailstream_get_data_crlf_size(const char * message, size_t size)
{
  const char * current;
  size_t count;
  size_t remaining;
  size_t fixed_count;
  
  count = 0;
  fixed_count = 0;
  
  current = message;
  remaining = size;

  while (remaining > 0) {
    ssize_t length;
    size_t line_count;
    
    length = get_data_size(current, remaining, &line_count);
    
    fixed_count += line_count;
    current += length;

    count += length;
    
    remaining -= length;
  }
  
  return fixed_count;
}
Пример #4
0
void dsp_preset::contents_to_stream(stream_writer * p_stream,abort_callback & p_abort) const {
	t_size size = get_data_size();
	p_stream->write_lendian_t(get_owner(),p_abort);
	p_stream->write_lendian_t(size,p_abort);
	if (size > 0) {
		p_stream->write_object(get_data(),size,p_abort);
	}
}
Пример #5
0
int VFrame::data_matches(VFrame *frame)
{
	if(data && frame->get_data() &&
		frame->params_match(get_w(), get_h(), get_color_model()) &&
		get_data_size() == frame->get_data_size())
	{
		int data_size = get_data_size();
		unsigned char *ptr1 = get_data();
		unsigned char *ptr2 = frame->get_data();
		for(int i = 0; i < data_size; i++)
		{
			if(*ptr1++ != *ptr2++) return 0;
		}
		return 1;
	}
	return 0;
}
Пример #6
0
int VFrame::copy_from(VFrame *frame)
{
	int w = MIN(this->w, frame->get_w());
	int h = MIN(this->h, frame->get_h());
	timestamp = frame->timestamp;

	switch(frame->color_model)
	{
		case BC_COMPRESSED:
			allocate_compressed_data(frame->compressed_size);
			memcpy(data, frame->data, frame->compressed_size);
			this->compressed_size = frame->compressed_size;
			break;

		case BC_YUV410P:
			memcpy(get_y(), frame->get_y(), w * h);
			memcpy(get_u(), frame->get_u(), w / 4 * h / 4);
			memcpy(get_v(), frame->get_v(), w / 4 * h / 4);
			break;

		case BC_YUV420P:
		case BC_YUV411P:
//printf("%d %d %p %p %p %p %p %p\n", w, h, get_y(), get_u(), get_v(), frame->get_y(), frame->get_u(), frame->get_v());
			memcpy(get_y(), frame->get_y(), w * h);
			memcpy(get_u(), frame->get_u(), w * h / 4);
			memcpy(get_v(), frame->get_v(), w * h / 4);
			break;

		case BC_YUV422P:
//printf("%d %d %p %p %p %p %p %p\n", w, h, get_y(), get_u(), get_v(), frame->get_y(), frame->get_u(), frame->get_v());
			memcpy(get_y(), frame->get_y(), w * h);
			memcpy(get_u(), frame->get_u(), w * h / 2);
			memcpy(get_v(), frame->get_v(), w * h / 2);
			break;

		case BC_YUV444P:
//printf("%d %d %p %p %p %p %p %p\n", w, h, get_y(), get_u(), get_v(), frame->get_y(), frame->get_u(), frame->get_v());
			memcpy(get_y(), frame->get_y(), w * h);
			memcpy(get_u(), frame->get_u(), w * h);
			memcpy(get_v(), frame->get_v(), w * h);
			break;
		default:
// printf("VFrame::copy_from %d\n", calculate_data_size(w,
// 				h,
// 				-1,
// 				frame->color_model));
// Copy without extra 4 bytes in case the source is a hardware device
			memmove(data, frame->data, get_data_size());
			break;
	}

	return 0;
}
Пример #7
0
static void match_calloc(const char *fn, struct expression *expr, void *_arg_nr)
{
	int arg_nr = PTR_INT(_arg_nr);
	struct expression *call = strip_expr(expr->right);
	struct expression *arg;
	int ptr_size;

	ptr_size = get_data_size(expr->left);
	if (!ptr_size)
		return;

	arg = get_argument_from_call_expr(call->args, arg_nr);
	check_size_matches(ptr_size, arg);
}
Пример #8
0
static int	load_data(t_program *program)
{
  int		fd;

  if ((fd = open(program->file, O_RDONLY)) == RET_ERROR)
    return (error_int(RET_FAILURE, ERR_OPEN_RD));
  if ((program->data_len = get_data_size(fd)) == RET_ERROR)
    return (RET_FAILURE);
  if (lseek(fd, SEEK_SET, 0) == RET_ERROR)
    return (error_int(RET_FAILURE, ERR_LSEEK));
  if ((program->data = malloc(program->data_len * sizeof(char))) == NULL)
    return (error_int(RET_FAILURE, ERR_MALLOC));
  if (read(fd, program->data, program->data_len) != program->data_len)
    return (error_int(RET_FAILURE, ERR_READ));
  if (close(fd) == RET_ERROR)
    return (error_int(RET_SUCCESS, WAR_CLOSE));
  return (RET_SUCCESS);
}
Пример #9
0
static void match_alloc(const char *fn, struct expression *expr, void *unused)
{
	struct expression *call = strip_expr(expr->right);
	struct expression *arg;
	int ptr_size;

	ptr_size = get_data_size(expr->left);
	if (!ptr_size)
		return;

	arg = get_argument_from_call_expr(call->args, 0);
	arg = strip_expr(arg);
	if (!arg || arg->type != EXPR_BINOP || arg->op != '*')
		return;
	if (expr->left->type == EXPR_SIZEOF)
		check_size_matches(ptr_size, arg->left);
	if (expr->right->type == EXPR_SIZEOF)
		check_size_matches(ptr_size, arg->right);
}
Пример #10
0
void lblMagneticMomentSpinMatrix(qlat::Array<qlat::SpinMatrix, 3> bs,
                                 const qlat::Geometry& geo, const int tsnk,
                                 const int tsrc, const double mass,
                                 const std::array<double, qlat::DIMN>& momtwist)
// pretend to the operator to be
// \Sigma_i * mass / 2
{
  TIMER("lblMagneticMomentSpinMatrix");
  qlat::SpinPropagator4d snk;
  snk.init(geo);
  qlat::SpinPropagator4d src;
  src.init(geo);
  qlat::set_zero(snk);
  qlat::set_zero(src);
  qlat::set_wall_source_plusm(snk, 1.0, tsnk);
  qlat::set_wall_source_plusm(src, 1.0, tsrc);
  qlat::prop_spin_propagator4d(snk, mass, momtwist);
  qlat::prop_spin_propagator4d(src, mass, momtwist);
  const int top =
      qlat::mod(tsrc + qlat::mod(tsnk - tsrc, geo.total_site()[3]) / 2,
                geo.total_site()[3]);
  qlat::Coordinate xgop(0, 0, 0, top);
  qlat::Coordinate xlop = geo.coordinate_l_from_g(xgop);
  qlat::set_zero(bs);
  if (geo.is_local(xlop)) {
    qlat::Display(cname, fname, "src =\n%s\n",
            qlat::show(src.get_elem(xlop)).c_str());
    qlat::Display(cname, fname, "snk =\n%s\n",
            qlat::show(snk.get_elem(xlop)).c_str());
    for (int i = 0; i < 3; ++i) {
      bs[i] = qlat::SpinMatrixConstants::get_gamma5() *
              matrix_adjoint(snk.get_elem(xlop)) *
              qlat::SpinMatrixConstants::get_gamma5();
      bs[i] *= qlat::SpinMatrixConstants::get_cap_sigma(i) * (qlat::ComplexT)(mass / 2.0);
      bs[i] *= src.get_elem(xlop);
      bs[i] = projPositiveState(bs[i]);
    }
  }
  qlat::glb_sum(qlat::Vector<double>((double*)bs.data(),
                                     get_data_size(bs) / sizeof(double)));
}
Пример #11
0
void mexFunction(int nlhs, mxArray* plhs[], const int nrhs, const mxArray* prhs[]) {
  if (nrhs != 1) {
    mexErrMsgTxt("Number of arguments must be exactly 1.");
  } else if (!mxIsChar(prhs[0])) {
    mexErrMsgTxt("Input must be a string.");
  }

  // get the length of the filename.
  mwSize filename_length = (mxGetM(prhs[0]) * mxGetN(prhs[0])) + 1;
  char *filename = mxArrayToString(prhs[0]);
  
  FILE* fp = fopen(filename, "r");
  if (fp == NULL) {
    mexErrMsgIdAndTxt("filename:notFound", "file %s not found", filename);
  }
  
  int data_size = get_data_size(fp);
  if (data_size != sizeof(freenect_raw_tilt_state)) {
    mexErrMsgIdAndTxt("filename:notAccel",
        "file %s's size doesnt match freenect_raw_tilt_state.", filename);
  }
  
  freenect_raw_tilt_state state;
  fread(&state, sizeof(state), 1, fp);
  
  mwSize ndim = 2;
  const mwSize dim_size[] = {4, 1};
  plhs[0] = mxCreateNumericArray(ndim, dim_size, mxDOUBLE_CLASS, mxREAL);
  double* output_data = (double*) mxGetData(plhs[0]);
  output_data[0] = state.accelerometer_x;
  output_data[1] = state.accelerometer_y;
  output_data[2] = state.accelerometer_z;
  output_data[3] = state.tilt_angle;
  
  fclose(fp);
}
Пример #12
0
	void* get_data(){
		if(likely(get_data_size()))return imsg[ANS_DATA].data();
		else return NULL;
	}
Пример #13
0
	//void readboxfull(service_ptr_t<file> & p_file, abort_callback & p_abort)
	//{
	//	readbox(p_file, p_abort);
	//	p_file->skip(4, p_abort);
	//}
	void readdata(stream_reader * p_file, abort_callback & p_abort)
	{
		m_data.set_size(pfc::downcast_guarded<t_size>(get_data_size()));
		p_file->read(m_data.get_ptr(), m_data.get_size(), p_abort);
	}
Пример #14
0
void KV_BtreeArray::purge_some(unsigned long long QCnow_ms) {
	uint64_t ret=0, i, _size=0;
	QC_entry_t *qce;
  spin_rdlock(&lock);
	for (i=0; i<ptrArray->len;i++) {
		qce=(QC_entry_t *)ptrArray->index(i);
		if (qce->expire_ms==EXPIRE_DROPIT || qce->expire_ms<QCnow_ms) {
			ret++;
			_size+=qce->length;
		}
	}
	freeable_memory=_size;
	spin_rdunlock(&lock);
	if ( (freeable_memory + ret * (sizeof(QC_entry_t)+sizeof(QC_entry_t *)*2+sizeof(uint64_t)*2) ) > get_data_size()*0.01) {
		uint64_t removed_entries=0;
		uint64_t freed_memory=0;
  	spin_wrlock(&lock);
		for (i=0; i<ptrArray->len;i++) {
			qce=(QC_entry_t *)ptrArray->index(i);
			if ((qce->expire_ms==EXPIRE_DROPIT || qce->expire_ms<QCnow_ms) && (__sync_fetch_and_add(&qce->ref_count,0)<=1)) {
				qce=(QC_entry_t *)ptrArray->remove_index_fast(i);

		    btree::btree_map<uint64_t, QC_entry_t *>::iterator lookup;
  				lookup = bt_map.find(qce->key);
     		if (lookup != bt_map.end()) {
					bt_map.erase(lookup);
				}
				i--;
				freed_memory+=qce->length;
				removed_entries++;
				free(qce->value);
				free(qce);
			}
		}
  	spin_wrunlock(&lock);
		THR_DECREASE_CNT(__thr_num_deleted,Glo_num_entries,removed_entries,1);
		if (removed_entries) {
			__sync_fetch_and_add(&Glo_total_freed_memory,freed_memory);
			__sync_fetch_and_sub(&Glo_size_values,freed_memory);
			__sync_fetch_and_add(&Glo_cntPurge,removed_entries);
//				if (removed_entries) fprintf(stderr,"Removed: %lu, total: %lu, arraylen: %d\n", removed_entries, __sync_fetch_and_sub(&Glo_num_entries,0), ptrArray.len);
//				if (removed_entries) firintf(stderr,"Size of  KVBtreeArray:%d , freed_memory:%lu, Glo_cntGet:%lu, Glo_cntGetOK:%lu, Glo_cntSet:%lu, cntPurge:%lu, dataIN:%lu, dataOUT:%lu\n", cnt() , Glo_total_freed_memory, Glo_cntGet, Glo_cntGetOK, Glo_cntSet, Glo_cntPurge, Glo_dataIN, Glo_dataOUT);
		}
	}
};
Пример #15
0
 size_t get_default_data_size() const {
     return get_data_size();
 }
int process_data(RemoteSource *source) {
        int r;

        switch(source->state) {
        case STATE_LINE: {
                char *line, *sep;
                size_t n;

                assert(source->data_size == 0);

                r = get_line(source, &line, &n);
                if (r < 0)
                        return r;
                if (r == 0) {
                        source->state = STATE_EOF;
                        return r;
                }
                assert(n > 0);
                assert(line[n-1] == '\n');

                if (n == 1) {
                        log_trace("Received empty line, event is ready");
                        return 1;
                }

                r = process_dunder(source, line, n);
                if (r != 0)
                        return r < 0 ? r : 0;

                /* MESSAGE=xxx\n
                   or
                   COREDUMP\n
                   LLLLLLLL0011223344...\n
                */
                sep = memchr(line, '=', n);
                if (sep)
                        /* chomp newline */
                        n--;
                else
                        /* replace \n with = */
                        line[n-1] = '=';
                log_trace("Received: %.*s", (int) n, line);

                r = iovw_put(&source->iovw, line, n);
                if (r < 0) {
                        log_error("Failed to put line in iovect");
                        return r;
                }

                if (!sep)
                        source->state = STATE_DATA_START;
                return 0; /* continue */
        }

        case STATE_DATA_START:
                assert(source->data_size == 0);

                r = get_data_size(source);
                // log_debug("get_data_size() -> %d", r);
                if (r < 0)
                        return r;
                if (r == 0) {
                        source->state = STATE_EOF;
                        return 0;
                }

                source->state = source->data_size > 0 ?
                        STATE_DATA : STATE_DATA_FINISH;

                return 0; /* continue */

        case STATE_DATA: {
                void *data;

                assert(source->data_size > 0);

                r = get_data_data(source, &data);
                // log_debug("get_data_data() -> %d", r);
                if (r < 0)
                        return r;
                if (r == 0) {
                        source->state = STATE_EOF;
                        return 0;
                }

                assert(data);

                r = iovw_put(&source->iovw, data, source->data_size);
                if (r < 0) {
                        log_error("failed to put binary buffer in iovect");
                        return r;
                }

                source->state = STATE_DATA_FINISH;

                return 0; /* continue */
        }

        case STATE_DATA_FINISH:
                r = get_data_newline(source);
                // log_debug("get_data_newline() -> %d", r);
                if (r < 0)
                        return r;
                if (r == 0) {
                        source->state = STATE_EOF;
                        return 0;
                }

                source->data_size = 0;
                source->state = STATE_LINE;

                return 0; /* continue */
        default:
                assert_not_reached("wtf?");
        }
}
Пример #17
0
/*ARGSUSED*/
static void
switcher(void *cookie, char *argp, size_t arg_size,
    door_desc_t *dp, uint_t n_desc)
{
#define	GETSIZE 1000
#define	ALLOCATE 1001

	ldap_call_t	*ptr = (ldap_call_t *)argp;
	ucred_t		*uc = NULL;

	LineBuf		configInfo;
	dataunion	*buf = NULL;
	/*
	 * By default the size of  a buffer to be passed down to a client
	 * is equal to the size of the ldap_return_t structure. We need
	 * a bigger buffer in a few cases.
	 */
	size_t		configSize = sizeof (ldap_return_t);
	int		ldapErrno = 0, state, callnumber;
	struct {
		void	*begin;
		size_t	size;
		uint8_t	destroy;
	} dataSource;

	if (argp == DOOR_UNREF_DATA) {
		logit("Door Slam... invalid door param\n");
		syslog(LOG_ERR, gettext("ldap_cachemgr: Door Slam... "
		    "invalid door param"));
		(void) printf(gettext("Door Slam... invalid door param\n"));
		exit(0);
	}

	if (ptr == NULL) { /* empty door call */
		(void) door_return(NULL, 0, 0, 0); /* return the favor */
	}

	bzero(&dataSource, sizeof (dataSource));

	/*
	 * We presume that sizeof (ldap_return_t) bytes are always available
	 * on the stack
	 */
	callnumber = ptr->ldap_callnumber;

	switch (callnumber) {
		case NULLCALL:
			/*
			 * Just a 'ping'. Use the default size
			 * of the buffer and set the
			 * 'OK' error code.
			 */
			state = ALLOCATE;
			break;
		case GETLDAPCONFIG:
			/*
			 * Get the current LDAP configuration.
			 * Since this is dynamic data and its size can exceed
			 * the size of ldap_return_t, the next step will
			 * calculate who much space exactly is required.
			 */
			getldap_lookup(&configInfo, ptr);

			state = GETSIZE;
			break;
		case GETLDAPSERVER:
			/*
			 * Get the root DSE for a next server in the list.
			 * Since this is dynamic data and its size can exceed
			 * the size of ldap_return_t, the next step will
			 * calculate who much space exactly is required.
			 */
			getldap_getserver(&configInfo, ptr);

			state = GETSIZE;
			break;
		case GETCACHESTAT:
			/*
			 * Get the cache stattistics.
			 * Since this is dynamic data and its size can exceed
			 * the size of ldap_return_t, the next step will
			 * calculate how much space exactly is required.
			 */
			getldap_get_cacheStat(&configInfo);

			state = GETSIZE;
			break;
		case GETADMIN:
			/*
			 * Get current configuration and statistics.
			 * The size of the statistics structure is less then
			 * sizeof (ldap_return_t). So specify the source
			 * where to take the info and proceed with the memory
			 * allocation.
			 */
			state = ALLOCATE;

			if (ldapErrno == 0) {
				dataSource.begin = &current_admin;
				dataSource.size = sizeof (current_admin);
				dataSource.destroy = 0;
			}
			break;
		case KILLSERVER:
			/*
			 * Process the request and proceed with the default
			 * buffer allocation.
			 */
			if (is_root(1, "KILLSERVER", &uc))
				exit(0);

			ldapErrno = -1;
			state = ALLOCATE;
			break;
		case SETADMIN:
			/*
			 * Process the request and proceed with the default
			 * buffer allocation.
			 */
			if (is_root(1, "SETADMIN", &uc))
				ldapErrno = setadmin(ptr);
			else
				ldapErrno = -1;

			state = ALLOCATE;
			break;
		case GETCACHE:
			/*
			 * Get the cache stattistics.
			 * Since this is dynamic data and its size can exceed
			 * the size of ldap_return_t, the next step will
			 * calculate how much space exactly is required.
			 */
			getldap_get_cacheData(&configInfo, ptr);

			state = GETSIZE;
			break;
		case SETCACHE:
			/*
			 * Process the request and proceed with the default
			 * buffer allocation.
			 */
			if (is_root(0, "SETCACHE", &uc) &&
			    is_nscd(ucred_getpid(uc))) {
				ldapErrno = getldap_set_cacheData(ptr);
				current_admin.ldap_stat.ldap_numbercalls++;
			} else
				ldapErrno = -1;

			if (uc != NULL)
				ucred_free(uc);
			state = ALLOCATE;
			break;
		default:
			/*
			 * This means an unknown request type. Proceed with
			 * the default buffer allocation.
			 */
			logit("Unknown ldap service door call op %d\n",
			    ptr->ldap_callnumber);
			ldapErrno = -99;

			state = ALLOCATE;
			break;
	}

	switch (state) {
		case GETSIZE:
			/*
			 * This stage calculates how much data will be
			 * passed down to the client, checks if there is
			 * enough space on the stack to accommodate the data,
			 * increases the value of the configSize variable
			 * if necessary and specifies the data source.
			 * In case of any error occurred ldapErrno will be set
			 * appropriately.
			 */
			if (configInfo.str == NULL) {
				ldapErrno = -1;
			}

			configSize = get_data_size(&configInfo, &ldapErrno);

			if (ldapErrno == 0) {
				dataSource.begin = configInfo.str;
				dataSource.size = configInfo.len;
				dataSource.destroy = 1;
			}

			current_admin.ldap_stat.ldap_numbercalls++;
			/* FALLTHRU */
		case ALLOCATE:
			/*
			 * Allocate a buffer of the calculated (or default) size
			 * and proceed with populating it with data.
			 */
			buf = (dataunion *) alloca(configSize);

			/*
			 * Set a return code and, if a data source is specified,
			 * copy data from the source to the buffer.
			 */
			buf->data.ldap_ret.ldap_errno = ldapErrno;
			buf->data.ldap_ret.ldap_return_code = ldapErrno;
			buf->data.ldap_ret.ldap_bufferbytesused = configSize;

			if (dataSource.begin != NULL) {
				(void) memcpy(buf->data.ldap_ret.ldap_u.config,
				    dataSource.begin,
				    dataSource.size);
				if (dataSource.destroy) {
					free(dataSource.begin);
				}
			}

	}
	(void) door_return((char *)&buf->data,
	    buf->data.ldap_ret.ldap_bufferbytesused,
	    NULL,
	    0);
#undef	GETSIZE
#undef	ALLOCATE
}
Пример #18
0
 size_t get_default_data_size(intptr_t DYND_UNUSED(ndim), const intptr_t *DYND_UNUSED(shape)) const {
     return get_data_size();
 }
Пример #19
0
int
netsnmp_watcher_helper_handler(netsnmp_mib_handler *handler,
                               netsnmp_handler_registration *reginfo,
                               netsnmp_agent_request_info *reqinfo,
                               netsnmp_request_info *requests)
{
    netsnmp_watcher_info  *winfo = (netsnmp_watcher_info *) handler->myvoid;
    netsnmp_watcher_cache *old_data;

    DEBUGMSGTL(("helper:watcher", "Got request:  %d\n", reqinfo->mode));
    DEBUGMSGTL(( "helper:watcher", "  oid:"));
    DEBUGMSGOID(("helper:watcher", requests->requestvb->name,
                                   requests->requestvb->name_length));
    DEBUGMSG((   "helper:watcher", "\n"));

    switch (reqinfo->mode) {
        /*
         * data requests 
         */
    case MODE_GET:
        snmp_set_var_typed_value(requests->requestvb,
                                 winfo->type,
                                 winfo->data,
                                 get_data_size(winfo));
        break;

        /*
         * SET requests.  Should only get here if registered RWRITE 
         */
    case MODE_SET_RESERVE1:
        if (requests->requestvb->type != winfo->type) {
            netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGTYPE);
            handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
        } else if (((winfo->flags & WATCHER_MAX_SIZE) &&
                     requests->requestvb->val_len > winfo->max_size) ||
            ((winfo->flags & WATCHER_FIXED_SIZE) &&
                requests->requestvb->val_len != get_data_size(winfo))) {
            netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGLENGTH);
            handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
        } else if ((winfo->flags & WATCHER_SIZE_STRLEN) &&
            (memchr(requests->requestvb->val.string, '\0',
                requests->requestvb->val_len) != NULL)) {
            netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_WRONGVALUE);
            handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
        }
        break;

    case MODE_SET_RESERVE2:
        /*
         * store old info for undo later 
         */
        old_data =
            netsnmp_watcher_cache_create(winfo->data, get_data_size(winfo));
        if (old_data == NULL) {
            netsnmp_set_request_error(reqinfo, requests,
                                      SNMP_ERR_RESOURCEUNAVAILABLE);
            handler->flags |= MIB_HANDLER_AUTO_NEXT_OVERRIDE_ONCE;
        } else
            netsnmp_request_add_list_data(requests,
                                          netsnmp_create_data_list
                                          ("watcher", old_data, &free_wrapper));
        break;

    case MODE_SET_FREE:
        /*
         * nothing to do 
         */
        break;

    case MODE_SET_ACTION:
        /*
         * update current 
         */
        set_data(winfo, (void *)requests->requestvb->val.string,
                                requests->requestvb->val_len);
        break;

    case MODE_SET_UNDO:
        old_data = (netsnmp_watcher_cache*)netsnmp_request_get_list_data(requests, "watcher");
        set_data(winfo, old_data->data, old_data->size);
        break;

    case MODE_SET_COMMIT:
        break;

    }

    /* next handler called automatically - 'AUTO_NEXT' */
    return SNMP_ERR_NOERROR;
}