lib/dgr.c
/** Given a label, a buffer to store data, and the size of that buffer,
 * get data from DGR, store it in buffer and return the actual size of
 * the data we copied into the buffer.
 *
 * @param name The label or name to apply to the piece of data to be retrieved from DGR.
 *
 * @param buffer A buffer for the retrieved data should be stored in.
 *
 * @param bufferSize The size of the buffer.
 *
 *
 * @return Returns the size of the data if success, and a negative
 * number upon error. Returns -1 if DGR didn't know about the
 * name. Returns -2 the buffer you provided was too small. Returns -3
 * if DGR is not enabled.
 */
Given a label, a buffer to store data, and the size of that buffer,
get data from DGR, store it in buffer and return the actual size of
the data we copied into the buffer.

@param name The label or name to apply to the piece of data to be retrieved from DGR.

@param buffer A buffer for the retrieved data should be stored in.

@param bufferSize The size of the buffer.

@return Returns the size of the data if success, and a negative
number upon error. Returns -1 if DGR didn't know about the
name. Returns -2 the buffer you provided was too small. Returns -3
if DGR is not enabled.
Given a label a buffer to store data and the size of that buffer get data from DGR store it in buffer and return the actual size of the data we copied into the buffer . @param name The label or name to apply to the piece of data to be retrieved from DGR . @param buffer A buffer for the retrieved data should be stored in . @param bufferSize The size of the buffer . @return Returns the size of the data if success and a negative number upon error . Returns - 1 if DGR didn ' t know about the name . Returns - 2 the buffer you provided was too small . Returns - 3 if DGR is not enabled .
static int dgr_get(const char *name, void* buffer, int bufferSize)
{
	if(dgr_disabled)
		return -3;
	int index = dgr_findIndex(name);
	if(index == -1)
		return -1;
	dgr_record *rec = &(dgr_list[index]);
	if(bufferSize >= rec->size)
	{
		memcpy(buffer, rec->buffer, rec->size);
		return rec->size;
	}
	else 
		return -2;
}
static int dgr_get ( const char * name , void * buffer , int bufferSize ) { if ( dgr_disabled ) return -3 ; int index = dgr_findIndex ( name ) ; if ( index == -1 ) return -1 ; dgr_record * rec = & ( dgr_list [ index ] ) ; if ( bufferSize >= rec -> size ) { memcpy ( buffer , rec -> buffer , rec -> size ) ; return rec -> size ; } else return -2 ; }
Given a label, a buffer to store data, and the size of that buffer,
 get data from DGR, store it in buffer and return the actual size of
 the data we copied into the buffer.
Given a label a buffer to store data and the size of that buffer get data from DGR store it in buffer and return the actual size of the data we copied into the buffer .
/* If we found the record... */ /* Copy the data if there is enough room */ /* 'buffer' wasn't large enough to store data. */