#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <zlib.h>
#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_zip.h"
Go to the source code of this file.
|
| static void | expect_true (const char *what, int ok) |
| | count a failed check
|
| static int | file_is (const char *path, const unsigned char *data, size_t len) |
| | is a file these bytes
|
| int | main (int argc, char **argv) |
| | run the checks
|
| static int | process_args (int argc, char **argv) |
| | read -V
|
| static void | put16 (unsigned char *p, unsigned v) |
| | put a little endian 16 bit value
|
| static void | put32 (unsigned char *p, unsigned long v) |
| | put a little endian 32 bit value
|
| static int | write_zip (const char *path, const MEMBER *m, int count) |
| | write an archive of two members, the way every zip tool lays it out: local headers and data, the central directory, its end record
|
◆ MEMBER
one stored member
one member to write
- Examples
- ex_pth.c, and ex_zip.c.
Definition at line 130 of file ex_pth.c.
| Data Fields |
|
const unsigned char * |
data |
its bytes |
|
size_t |
len |
how many |
|
unsigned |
method |
0 stored, 8 deflated |
|
const char * |
name |
its name |
◆ expect_true()
| void expect_true |
( |
const char * | what, |
|
|
int | ok ) |
|
static |
◆ file_is()
| int file_is |
( |
const char * | path, |
|
|
const unsigned char * | data, |
|
|
size_t | len ) |
|
static |
is a file these bytes
- Parameters
-
| path | the file |
| data | the bytes |
| len | how many |
- Returns
- non-zero when it is
- Examples
- ex_zip.c.
Definition at line 193 of file ex_zip.c.
Referenced by main().
◆ main()
| int main |
( |
int | argc, |
|
|
char ** | argv ) |
run the checks
- Parameters
-
| argc | argument count |
| argv | arguments |
- Returns
- 0 on success
Definition at line 214 of file ex_zip.c.
References MEMBER::data, expect_true(), failures, file_is(), MEMBER::len, LOG_ERR, log_level, MEMBER::method, N_ZIP_MEMBER::method, n_zip_extract(), n_zip_find(), n_zip_find_ending(), n_zip_read(), MEMBER::name, process_args(), set_log_level(), N_ZIP_MEMBER::size, and write_zip().
◆ process_args()
| int process_args |
( |
int | argc, |
|
|
char ** | argv ) |
|
static |
read -V
- Parameters
-
| argc | argument count |
| argv | arguments |
- Returns
- 0, or -1 on a bad argument
Definition at line 62 of file ex_zip.c.
References log_level.
◆ put16()
| void put16 |
( |
unsigned char * | p, |
|
|
unsigned | v ) |
|
static |
put a little endian 16 bit value
- Parameters
-
Definition at line 78 of file ex_zip.c.
◆ put32()
| void put32 |
( |
unsigned char * | p, |
|
|
unsigned long | v ) |
|
static |
put a little endian 32 bit value
- Parameters
-
Definition at line 86 of file ex_zip.c.
References put16().
◆ write_zip()
| int write_zip |
( |
const char * | path, |
|
|
const MEMBER * | m, |
|
|
int | count ) |
|
static |
write an archive of two members, the way every zip tool lays it out: local headers and data, the central directory, its end record
- Parameters
-
| path | where |
| m | the members |
| count | how many |
- Returns
- 0, or -1
Definition at line 109 of file ex_zip.c.
References put16(), and put32().
◆ failures
failed checks
Definition at line 44 of file ex_zip.c.
◆ log_level
log level from -V
Definition at line 42 of file ex_zip.c.