diff options
author | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-05-17 12:20:19 (EDT) |
---|---|---|
committer | Patrick McDermott <patrick.mcdermott@libiquity.com> | 2023-05-17 14:20:32 (EDT) |
commit | 88fc60c9ed2407c7d5b929b109729b4a3e40259f (patch) | |
tree | 11a49b93adb2eda5f90453a1e136170d9b6ded63 | |
parent | 255d04438a6634605b73008351fe2bcf70995658 (diff) |
opk: Read specials file
-rw-r--r-- | src/opk.c | 12 | ||||
-rw-r--r-- | src/opk.h | 14 | ||||
-rw-r--r-- | src/opk/opk.h | 1 |
3 files changed, 27 insertions, 0 deletions
@@ -19,6 +19,7 @@ #include <stdlib.h> #include "defs.h" +#include "specials.h" #include "opk.h" #include "opk/opk.h" @@ -39,6 +40,7 @@ opkg_opk_opk_init(void) opk->list_control = 0; opk->list_data = 0; opk->control_dir = NULL; + opk->specials = NULL; opk->previously_printed = 0; return opk; @@ -117,6 +119,15 @@ opkg_opk_opk_data_dir(struct opkg_opk_opk *opk, const char *dir) return OPKG_OPK_OK; } +int +opkg_opk_opk_specials_read(struct opkg_opk_opk *opk, const char *file_name) +{ + if (opkg_opk_specials_read(file_name, &opk->specials) != OPKG_OPK_OK) { + return OPKG_OPK_ERROR; + } + return OPKG_OPK_OK; +} + void opkg_opk_opk_free(struct opkg_opk_opk *opk) { @@ -132,5 +143,6 @@ opkg_opk_opk_free(struct opkg_opk_opk *opk) opk->print_data_head = opk->print_data_head->next; free(name); } + opkg_opk_specials_free(opk->specials); free(opk); } @@ -104,6 +104,20 @@ int opkg_opk_opk_data_dir(struct opkg_opk_opk *opk, const char *dir); /* + * Reads types and device numbers of device special files from a list file for + * use when writing. + * Parameters: + * - opk: Package structure. + * - file_name: Device special files list file. + * Returns: + * - OPKG_OPK_OK if the list was successfully read. + * - OPKG_OPK_ERROR if list file is unreadable or malformed or on memory + * exhaustion. + */ +int +opkg_opk_opk_specials_read(struct opkg_opk_opk *opk, const char *file_name); + +/* * Performs the configured read actions. * Parameters: * - file_name: Package's file name. diff --git a/src/opk/opk.h b/src/opk/opk.h index 28a6b66..d66e0a7 100644 --- a/src/opk/opk.h +++ b/src/opk/opk.h @@ -41,6 +41,7 @@ struct opkg_opk_opk { const char *control_dir; const char *data_dir; FILE *file; + struct opkg_opk_specials *specials; char file_buffer[8192]; uint64_t mtime; const char *file_name; |