view smspdu/smspdu-pack.c @ 663:136298c89fdd default tip

Enabling of "Developer mode" to allow symlinks without elevation.
author Oleksandr Gavenko <gavenkoa@gmail.com>
date Sun, 15 Nov 2020 15:24:16 +0200
parents c0ac856d2e4b
children
line wrap: on
line source

#include <stdlib.h>
#include <stdio.h>

int main()
{
    int ch;
    int buf = 0;
    int off = 0;
    while ((ch = getchar()) != EOF) {
        /* printf("ch: %c\n", ch); */
        if (off == 0) {
            buf = ch & 0x7f;
            off = 7;
        } else {
            int remain = 8 - off;
            int hi = ch & ((1<<remain) - 1);
            buf |= hi << off;
            printf("%02x", buf);
            buf = (ch & 0x7f) >> remain;
            off = 7 - remain;
        }
    }
    if (off > 0) {
        printf("%02x", buf);
    }
    return EXIT_SUCCESS;
}