/*
* Copyright 2008 Anonymous
*
* This snippet is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*/
/* The parse function allows the extraciton of various length word data from
* a little endian buffer
*
* @note This function doesn't care about the buffer length, as it should be
* correctly specified into the fmt field.
*
* @param buffer The buffer containing the data;
* @param fmt The extraction format to use
* @param offset A internal use offset that must be initialized to zero
* @param ret A pointer to the memory area that will contain the extracted
* data
* @return true if there's still something to extract, false otherwise
*/
bool parse(const uint8_t *buffer, const char *fmt,
uint32_t *offset, uint32_t *ret)
{
/* Two separated words: 0 for the format; 1 for the buffer */
uint16_t *offs;
uint32_t shifts;
const char *f;