1
0
Fork 0
mirror of https://github.com/pygos/pkg-utils.git synced 2024-11-22 04:49:46 +01:00

Move input file processor to main code

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-01-31 17:56:18 +01:00
parent 134458b85a
commit 6fc871b3ff
4 changed files with 29 additions and 17 deletions

View file

@ -6,11 +6,12 @@ AM_CFLAGS = $(WARN_CFLAGS)
# application core # application core
GLOBALHDR = include/pkgformat.h include/util.h include/pkgreader.h GLOBALHDR = include/pkgformat.h include/util.h include/pkgreader.h
GLOBALHDR += include/compressor.h include/command.h include/pkgwriter.h GLOBALHDR += include/compressor.h include/command.h include/pkgwriter.h
GLOBALHDR += include/image_entry.h include/pkgio.h GLOBALHDR += include/image_entry.h include/pkgio.h include/input_file.h
MAIN = main/pkg.c main/util.c main/compressor.c main/command.c main/pkgreader.c MAIN = main/pkg.c main/util.c main/compressor.c main/command.c main/pkgreader.c
MAIN += main/pkgwriter.c main/image_entry.c main/image_entry_sort.c MAIN += main/pkgwriter.c main/image_entry.c main/image_entry_sort.c
MAIN += main/mkdir_p.c main/pkgio_rd_image_entry.c main/pkg_unpack.c MAIN += main/mkdir_p.c main/pkgio_rd_image_entry.c main/pkg_unpack.c
MAIN += main/input_file.c
pkg_SOURCES = $(GLOBALHDR) $(MAIN) pkg_SOURCES = $(GLOBALHDR) $(MAIN)
pkg_CFLAGS = $(AM_CFLAGS) pkg_CFLAGS = $(AM_CFLAGS)
@ -26,8 +27,7 @@ EXTRA_DIST = autogen.sh
pkg_SOURCES += main/cmd/pack/filelist.c main/cmd/pack/filelist_read.c pkg_SOURCES += main/cmd/pack/filelist.c main/cmd/pack/filelist_read.c
pkg_SOURCES += main/cmd/pack/write_toc.c main/cmd/pack/write_files.c pkg_SOURCES += main/cmd/pack/write_toc.c main/cmd/pack/write_files.c
pkg_SOURCES += main/cmd/pack/pack.h main/cmd/pack/pack.c pkg_SOURCES += main/cmd/pack/pack.h main/cmd/pack/pack.c
pkg_SOURCES += main/cmd/pack/input_file.c main/cmd/pack/desc.c pkg_SOURCES += main/cmd/pack/desc.c main/cmd/pack/write_hdr.c
pkg_SOURCES += main/cmd/pack/write_hdr.c
# dump command # dump command
pkg_SOURCES += main/cmd/dump/dump.c main/cmd/dump/dump.h main/cmd/dump/dump_toc.c pkg_SOURCES += main/cmd/dump/dump.c main/cmd/dump/dump.h main/cmd/dump/dump_toc.c

19
include/input_file.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef INPUT_FILE_H
#define INPUT_FILE_H
#include <stdio.h>
typedef struct {
FILE *f;
char *line;
const char *filename;
size_t linenum;
} input_file_t;
int prefetch_line(input_file_t *f);
void cleanup_file(input_file_t *f);
int open_file(input_file_t *f, const char *filename);
#endif /* INPUT_FILE_H */

View file

@ -15,19 +15,13 @@
#include <fcntl.h> #include <fcntl.h>
#include "image_entry.h" #include "image_entry.h"
#include "input_file.h"
#include "compressor.h" #include "compressor.h"
#include "pkgformat.h" #include "pkgformat.h"
#include "pkgwriter.h" #include "pkgwriter.h"
#include "command.h" #include "command.h"
#include "util.h" #include "util.h"
typedef struct {
FILE *f;
char *line;
const char *filename;
size_t linenum;
} input_file_t;
typedef struct dependency_t { typedef struct dependency_t {
struct dependency_t *next; struct dependency_t *next;
int type; int type;
@ -51,12 +45,6 @@ int write_toc(pkg_writer_t *wr, image_entry_t *list, compressor_t *cmp);
int write_files(pkg_writer_t *wr, image_entry_t *list, compressor_t *cmp); int write_files(pkg_writer_t *wr, image_entry_t *list, compressor_t *cmp);
int prefetch_line(input_file_t *f);
void cleanup_file(input_file_t *f);
int open_file(input_file_t *f, const char *filename);
int desc_read(const char *path, pkg_desc_t *desc); int desc_read(const char *path, pkg_desc_t *desc);
void desc_free(pkg_desc_t *desc); void desc_free(pkg_desc_t *desc);

View file

@ -1,4 +1,9 @@
#include "pack.h" #include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "input_file.h"
int prefetch_line(input_file_t *f) int prefetch_line(input_file_t *f)
{ {