1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
*/
#ifndef H_CDF
#define H_CDF
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <getopt.h>
#include <ctype.h>
#include <string.h>
#include <stdint.h>
#include <assert.h>
typedef union {
int64_t i;
uint64_t u;
double d;
} Number;
typedef struct {
Number data;
uint64_t count;
} DistRecord;
static int parse_options(int argc, char*const* argv);
static void help();
static int process_data(FILE *file);
static DistRecord *expand_array(DistRecord *records, size_t *capacity);
static int read_data_int(DistRecord **records, size_t capacity, FILE *file);
static int read_data_uint(DistRecord **records, size_t capacity, FILE *file);
static int read_data_fp(DistRecord **records, size_t capacity, FILE *file);
static int print_data_fp(DistRecord *records, long double *freqs, size_t cnt);
static int print_data_int(DistRecord *records, long double *freqs, size_t cnt);
static int print_data_uint(DistRecord *records, long double *freqs, size_t cnt);
#endif
|