|
| 1 | +/** |
| 2 | + * hdr_histogram_log.c |
| 3 | + * Written by Michael Barker and released to the public domain, |
| 4 | + * as explained at http://creativecommons.org/publicdomain/zero/1.0/ |
| 5 | + */ |
| 6 | + |
| 7 | +#include <stdint.h> |
| 8 | +#include <stdio.h> |
| 9 | +#include <string.h> |
| 10 | + |
| 11 | +#include "hdr_histogram.h" |
| 12 | +#include "hdr_histogram_log.h" |
| 13 | +#include "hdr_tests.h" |
| 14 | + |
| 15 | +#define UNUSED(x) (void)(x) |
| 16 | + |
| 17 | +const char* hdr_strerror(int errnum) |
| 18 | +{ |
| 19 | + switch (errnum) |
| 20 | + { |
| 21 | + case HDR_COMPRESSION_COOKIE_MISMATCH: |
| 22 | + return "Compression cookie mismatch"; |
| 23 | + case HDR_ENCODING_COOKIE_MISMATCH: |
| 24 | + return "Encoding cookie mismatch"; |
| 25 | + case HDR_DEFLATE_INIT_FAIL: |
| 26 | + return "Deflate initialisation failed"; |
| 27 | + case HDR_DEFLATE_FAIL: |
| 28 | + return "Deflate failed"; |
| 29 | + case HDR_INFLATE_INIT_FAIL: |
| 30 | + return "Inflate initialisation failed"; |
| 31 | + case HDR_INFLATE_FAIL: |
| 32 | + return "Inflate failed"; |
| 33 | + case HDR_LOG_INVALID_VERSION: |
| 34 | + return "Log - invalid version in log header"; |
| 35 | + case HDR_TRAILING_ZEROS_INVALID: |
| 36 | + return "Invalid number of trailing zeros"; |
| 37 | + case HDR_VALUE_TRUNCATED: |
| 38 | + return "Truncated value found when decoding"; |
| 39 | + case HDR_ENCODED_INPUT_TOO_LONG: |
| 40 | + return "The encoded input exceeds the size of the histogram"; |
| 41 | + default: |
| 42 | + return strerror(errnum); |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +int hdr_encode_compressed( |
| 47 | + struct hdr_histogram* h, |
| 48 | + uint8_t** compressed_histogram, |
| 49 | + size_t* compressed_len) |
| 50 | +{ |
| 51 | + UNUSED(h); |
| 52 | + UNUSED(compressed_histogram); |
| 53 | + UNUSED(compressed_len); |
| 54 | + |
| 55 | + return -1; |
| 56 | +} |
| 57 | + |
| 58 | +int hdr_decode_compressed( |
| 59 | + uint8_t* buffer, size_t length, struct hdr_histogram** histogram) |
| 60 | +{ |
| 61 | + UNUSED(buffer); |
| 62 | + UNUSED(length); |
| 63 | + UNUSED(histogram); |
| 64 | + |
| 65 | + return -1; |
| 66 | +} |
| 67 | + |
| 68 | +int hdr_log_writer_init(struct hdr_log_writer* writer) |
| 69 | +{ |
| 70 | + UNUSED(writer); |
| 71 | + |
| 72 | + return -1; |
| 73 | +} |
| 74 | + |
| 75 | +int hdr_log_write_header( |
| 76 | + struct hdr_log_writer* writer, FILE* file, |
| 77 | + const char* user_prefix, hdr_timespec* timestamp) |
| 78 | +{ |
| 79 | + UNUSED(writer); |
| 80 | + UNUSED(file); |
| 81 | + UNUSED(user_prefix); |
| 82 | + UNUSED(timestamp); |
| 83 | + |
| 84 | + return -1; |
| 85 | +} |
| 86 | + |
| 87 | +int hdr_log_write( |
| 88 | + struct hdr_log_writer* writer, |
| 89 | + FILE* file, |
| 90 | + const hdr_timespec* start_timestamp, |
| 91 | + const hdr_timespec* end_timestamp, |
| 92 | + struct hdr_histogram* histogram) |
| 93 | +{ |
| 94 | + UNUSED(writer); |
| 95 | + UNUSED(file); |
| 96 | + UNUSED(start_timestamp); |
| 97 | + UNUSED(end_timestamp); |
| 98 | + UNUSED(histogram); |
| 99 | + |
| 100 | + return -1; |
| 101 | +} |
| 102 | + |
| 103 | +int hdr_log_write_entry( |
| 104 | + struct hdr_log_writer* writer, |
| 105 | + FILE* file, |
| 106 | + struct hdr_log_entry* entry, |
| 107 | + struct hdr_histogram* histogram) |
| 108 | +{ |
| 109 | + UNUSED(writer); |
| 110 | + UNUSED(file); |
| 111 | + UNUSED(entry); |
| 112 | + UNUSED(histogram); |
| 113 | + |
| 114 | + return -1; |
| 115 | +} |
| 116 | + |
| 117 | +int hdr_log_reader_init(struct hdr_log_reader* reader) |
| 118 | +{ |
| 119 | + UNUSED(reader); |
| 120 | + |
| 121 | + return -1; |
| 122 | +} |
| 123 | + |
| 124 | +int hdr_log_read_header(struct hdr_log_reader* reader, FILE* file) |
| 125 | +{ |
| 126 | + UNUSED(reader); |
| 127 | + UNUSED(file); |
| 128 | + |
| 129 | + return -1; |
| 130 | +} |
| 131 | + |
| 132 | +int hdr_log_read( |
| 133 | + struct hdr_log_reader* reader, FILE* file, struct hdr_histogram** histogram, |
| 134 | + hdr_timespec* timestamp, hdr_timespec* interval) |
| 135 | +{ |
| 136 | + UNUSED(reader); |
| 137 | + UNUSED(file); |
| 138 | + UNUSED(histogram); |
| 139 | + UNUSED(timestamp); |
| 140 | + UNUSED(interval); |
| 141 | + |
| 142 | + return -1; |
| 143 | +} |
| 144 | + |
| 145 | +int hdr_log_read_entry( |
| 146 | + struct hdr_log_reader* reader, FILE* file, struct hdr_log_entry *entry, struct hdr_histogram** histogram) |
| 147 | +{ |
| 148 | + UNUSED(reader); |
| 149 | + UNUSED(file); |
| 150 | + UNUSED(entry); |
| 151 | + UNUSED(histogram); |
| 152 | + |
| 153 | + return -1; |
| 154 | +} |
| 155 | + |
| 156 | +int hdr_log_encode(struct hdr_histogram* histogram, char** encoded_histogram) |
| 157 | +{ |
| 158 | + UNUSED(histogram); |
| 159 | + UNUSED(encoded_histogram); |
| 160 | + |
| 161 | + return -1; |
| 162 | +} |
| 163 | + |
| 164 | +int hdr_log_decode(struct hdr_histogram** histogram, char* base64_histogram, size_t base64_len) |
| 165 | +{ |
| 166 | + UNUSED(histogram); |
| 167 | + UNUSED(base64_histogram); |
| 168 | + UNUSED(base64_len); |
| 169 | + |
| 170 | + return -1; |
| 171 | +} |
0 commit comments