1 /* Copyright (c) 2006-2015 Jonas Fonseca <jonas.fonseca@gmail.com>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
18 #include "tig/types.h"
24 #define STATUS_CODE_INFO(_) \
25 _(CUSTOM_MESSAGE, NULL), \
26 _(NO_OPTION_VALUE, "No option value"), \
27 _(OUT_OF_MEMORY, "Out of memory"), \
28 _(FILE_DOES_NOT_EXIST, "File does not exist"), \
29 _(UNMATCHED_QUOTATION, "Unmatched quotation"), \
33 #define STATUS_CODE_ENUM(name, msg) ERROR_ ## name
34 STATUS_CODE_INFO(STATUS_CODE_ENUM
)
37 const char *get_status_message(enum status_code code
);
38 enum status_code
error(const char *fmt
, ...) PRINTF_LIKE(1, 2);
39 enum status_code
success(const char *fmt
, ...) PRINTF_LIKE(1, 2);
41 typedef void (*die_fn
)(void);
42 extern die_fn die_callback
;
43 void TIG_NORETURN
die(const char *err
, ...) PRINTF_LIKE(1, 2);
44 void warn(const char *msg
, ...) PRINTF_LIKE(1, 2);
47 count_digits(unsigned long i
)
54 for (digits
= 0; i
; digits
++)
60 apply_step(double step
, int value
)
65 return value
? value
: 1;
69 * Git data formatters.
82 extern const struct ident unknown_ident
;
84 int timecmp(const struct time
*t1
, const struct time
*t2
);
85 int ident_compare(const struct ident
*i1
, const struct ident
*i2
);
87 const char *mkdate(const struct time
*time
, enum date date
);
88 const char *mkfilesize(unsigned long size
, enum file_size format
);
89 const char *mkauthor(const struct ident
*ident
, int cols
, enum author author
);
90 const char *mkmode(mode_t mode
);
91 const char *mkstatus(const char status
, enum status_label label
);
93 #define author_trim(cols) (cols == 0 || cols > 10)
99 void *chunk_allocator(void *mem
, size_t type_size
, size_t chunk_size
, size_t size
, size_t increase
);
101 #define DEFINE_ALLOCATOR(name, type, chunk_size) \
103 name(type **mem, size_t size, size_t increase) \
111 tmp = chunk_allocator(*mem, sizeof(type), chunk_size, size, increase); \
118 /* vim: set ts=8 sw=8 noexpandtab: */