/*
* 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;
fixed it for you: /*
* 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 666 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;
i can't believe you copyright code like that, and to anonymous, lolu
Name:
Anonymous2008-12-24 15:32
This won't work on most non-x86 architectures where accesses must typically be aligned. You can do an 8-bit read at any address, ad 16-bit read at any even address, a 32-bit read at any address that's a multiple of 4. Even on x86, ignoring these alignments may cause performance penalties.
Of course, many other architectures use big endian anyway, so the code's of limited use.
Name:
Anonymous2008-12-24 15:39
>>14,1
If the copyright belongs to Anonymous, we are all free to copy, modify, sell, and relicense it as we please. Only those who are not Anonymous are bound to the harsh terms below.