All pastes #596275 Raw Edit

iaia

public text v1 · immutable
#596275 ·published 2007-06-29 21:10 UTC
rendered paste body
unsigned char 
*encode_field(unsigned int field)
{
        unsigned char buf[4];
        static unsigned char s[3] = {0};

        if (field > 99) {
                snprintf(buf, 4, "%d", field);
                s[0] = (field/10) + (field > 199 ? 60 : 54);
                s[1] = buf[2];
        } else {
                snprintf(s, 3, "%d", field);
        }

        return s;
}