|
Revision 1350, 1.2 kB
(checked in by till, 1 year ago)
|
- bin2hex: convert binary input to hex
- ngtrie: trie-based string similarity computation using n-grams
|
- Property svn:executable set to
*
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
#include <stdlib.h> |
|---|
| 19 |
#include <stdio.h> |
|---|
| 20 |
#include <string.h> |
|---|
| 21 |
#include <errno.h> |
|---|
| 22 |
|
|---|
| 23 |
int main(int argc, char *argv[]) { |
|---|
| 24 |
u_char byte; |
|---|
| 25 |
int retval; |
|---|
| 26 |
FILE *file; |
|---|
| 27 |
|
|---|
| 28 |
if (argc < 2) { |
|---|
| 29 |
fprintf(stderr, "Error - No filename given.\n"); |
|---|
| 30 |
exit(1); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
if ((file = fopen(argv[1], "r")) == NULL) { |
|---|
| 35 |
fprintf(stderr, "Error - Unable to open file: %s.\n", strerror(errno)); |
|---|
| 36 |
exit(1); |
|---|
| 37 |
} |
|---|
| 38 |
|
|---|
| 39 |
errno = 0; |
|---|
| 40 |
while((retval = fscanf(file, "%c", &byte)) > 0) fprintf(stdout, "\\x%02x", byte); |
|---|
| 41 |
if ((retval = EOF) && errno) fprintf(stderr, "Error - Unable to read from file: %s.\n", strerror(errno)); |
|---|
| 42 |
|
|---|
| 43 |
fclose(file); |
|---|
| 44 |
return(0); |
|---|
| 45 |
} |
|---|