#include "../unarr.h"
#include "allocator.h"
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <inttypes.h>
Go to the source code of this file.
|
#define | warn(...) ar_log("!", __FILE__, __LINE__, __VA_ARGS__) |
|
#define | log(...) ar_log("-", __FILE__, __LINE__, __VA_ARGS__) |
|
|
size_t | ar_conv_rune_to_utf8 (wchar_t rune, char *out, size_t size) |
|
char * | ar_conv_dos_to_utf8 (const char *astr) |
|
time64_t | ar_conv_dosdate_to_filetime (uint32_t dosdate) |
|
uint32_t | ar_crc32 (uint32_t crc32, const unsigned char *data, size_t data_len) |
|
ar_stream * | ar_open_stream (void *data, ar_stream_close_fn close, ar_stream_read_fn read, ar_stream_seek_fn seek, ar_stream_tell_fn tell) |
|
void | ar_log (const char *prefix, const char *file, int line, const char *msg,...) |
|
ar_archive * | ar_open_archive (ar_stream *stream, size_t struct_size, ar_archive_close_fn close, ar_parse_entry_fn parse_entry, ar_entry_get_name_fn get_name, ar_entry_uncompress_fn uncompress, ar_get_global_comment_fn get_comment, off64_t first_entry_offset) |
|
#define log |
( |
|
...) | |
ar_log("-", __FILE__, __LINE__, __VA_ARGS__) |
#define warn |
( |
|
...) | |
ar_log("!", __FILE__, __LINE__, __VA_ARGS__) |
typedef void(* ar_archive_close_fn)(ar_archive *ar) |
typedef const char*(* ar_entry_get_name_fn)(ar_archive *ar) |
typedef bool(* ar_entry_uncompress_fn)(ar_archive *ar, void *buffer, size_t count) |
typedef size_t(* ar_get_global_comment_fn)(ar_archive *ar, void *buffer, size_t count) |
typedef void(* ar_stream_close_fn)(void *data) |
typedef size_t(* ar_stream_read_fn)(void *data, void *buffer, size_t count) |
typedef bool(* ar_stream_seek_fn)(void *data, off64_t offset, int origin) |
typedef off64_t(* ar_stream_tell_fn)(void *data) |
char* ar_conv_dos_to_utf8 |
( |
const char * |
astr) | |
|
Definition at line 53 of file conv.c.
60 for (in = astr; *in; in++) {
65 if (size == (
size_t)-1)
67 str = malloc(size + 1);
71 for (in = astr, out = str; *in; in++) {
time64_t ar_conv_dosdate_to_filetime |
( |
uint32_t |
dosdate) | |
|
Definition at line 79 of file conv.c.
84 tm.tm_sec = (dosdate & 0x1F) * 2;
85 tm.tm_min = (dosdate >> 5) & 0x3F;
86 tm.tm_hour = (dosdate >> 11) & 0x1F;
87 tm.tm_mday = (dosdate >> 16) & 0x1F;
88 tm.tm_mon = ((dosdate >> 21) & 0x0F) - 1;
89 tm.tm_year = ((dosdate >> 25) & 0x7F) + 80;
93 t2 = mktime(gmtime(&t1));
95 return (
time64_t)(2 * t1 - t2 + 11644473600) * 10000000;
size_t ar_conv_rune_to_utf8 |
( |
wchar_t |
rune, |
|
|
char * |
out, |
|
|
size_t |
size |
|
) |
| |
Definition at line 28 of file conv.c.
36 if (rune < 0x0800 && size >= 2) {
37 *out++ = 0xC0 | ((rune >> 6) & 0x1F);
38 *out++ = 0x80 | (rune & 0x3F);
42 if ((0xD800 <= rune && rune <= 0xDFFF) || rune >= 0x10000)
44 *out++ = 0xE0 | ((rune >> 12) & 0x0F);
45 *out++ = 0x80 | ((rune >> 6) & 0x3F);
46 *out++ = 0x80 | (rune & 0x3F);
uint32_t ar_crc32 |
( |
uint32_t |
crc32, |
|
|
const unsigned char * |
data, |
|
|
size_t |
data_len |
|
) |
| |
Definition at line 13 of file crc32.c.
19 for (i = 128; i; i >>= 1) {
20 h = (h >> 1) ^ ((h & 1) ? 0xEDB88320 : 0);
21 for (j = 0; j < 256; j += 2 * i) {
28 crc32 = crc32 ^ 0xFFFFFFFF;
29 while (data_len-- > 0) {
30 crc32 = (crc32 >> 8) ^
crc_table[(crc32 ^ *data++) & 0xFF];
32 return crc32 ^ 0xFFFFFFFF;
void ar_log |
( |
const char * |
prefix, |
|
|
const char * |
file, |
|
|
int |
line, |
|
|
const char * |
msg, |
|
|
|
... |
|
) |
| |
Definition at line 95 of file unarr.c.
100 fprintf(stderr,
"%s ",
prefix);
104 file =
strrchr(file,
'\\') + 1;
105 fprintf(stderr,
"%s:%d: ", file, line);
106 vfprintf(stderr, msg, args);
107 fprintf(stderr,
"\n");
Definition at line 6 of file unarr.c.
13 memset(ar, 0, struct_size);