16296d357SDmitri Tikhonov/* huff-encode -- Huffman-encode string */ 26296d357SDmitri Tikhonov 36296d357SDmitri Tikhonov#include <stdio.h> 46296d357SDmitri Tikhonov#include <stdlib.h> 56296d357SDmitri Tikhonov#include <string.h> 66296d357SDmitri Tikhonov 76296d357SDmitri Tikhonovint 86296d357SDmitri Tikhonovlshpack_enc_huff_encode (const unsigned char *src, 96296d357SDmitri Tikhonov const unsigned char *const src_end, unsigned char *const dst, int dst_len); 106296d357SDmitri Tikhonov 116296d357SDmitri Tikhonovint 126296d357SDmitri Tikhonovmain (int argc, char **argv) 136296d357SDmitri Tikhonov{ 146296d357SDmitri Tikhonov unsigned char buf[0x1000]; 156296d357SDmitri Tikhonov size_t len; 166296d357SDmitri Tikhonov int sz; 176296d357SDmitri Tikhonov 186296d357SDmitri Tikhonov if (argc != 2) 196296d357SDmitri Tikhonov { 206296d357SDmitri Tikhonov fprintf(stderr, "Usage: %s string > output\n", argv[0]); 216296d357SDmitri Tikhonov exit(EXIT_FAILURE); 226296d357SDmitri Tikhonov } 236296d357SDmitri Tikhonov 246296d357SDmitri Tikhonov len = strlen(argv[1]); 256296d357SDmitri Tikhonov sz = lshpack_enc_huff_encode((unsigned char *) argv[1], 266296d357SDmitri Tikhonov (unsigned char *) argv[1] + len, buf, sizeof(buf)); 276296d357SDmitri Tikhonov fwrite(buf, 1, sz, stdout); 286296d357SDmitri Tikhonov 296296d357SDmitri Tikhonov exit(EXIT_SUCCESS); 306296d357SDmitri Tikhonov} 31