diff options
Diffstat (limited to 'src/opk.c')
-rw-r--r-- | src/opk.c | 151 |
1 files changed, 0 insertions, 151 deletions
diff --git a/src/opk.c b/src/opk.c deleted file mode 100644 index 457f7fa..0000000 --- a/src/opk.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (C) 2023 Patrick McDermott - * - * This file is part of opkg-opk. - * - * opkg-opk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * opkg-opk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with opkg-opk. If not, see <https://www.gnu.org/licenses/>. - */ - -#include <stdlib.h> -#include <string.h> -#include "defs.h" -#include "specials.h" -#include "opk.h" -#include "opk/opk.h" - -struct opkg_opk_opk * -opkg_opk_opk_init(void) -{ - struct opkg_opk_opk *opk; - - opk = malloc(sizeof(*opk)); - if (opk == NULL) { - return NULL; - } - - opk->print_control_head = NULL; - opk->print_control_tail = NULL; - opk->print_data_head = NULL; - opk->print_data_tail = NULL; - opk->list_control = 0; - opk->list_data = 0; - opk->control_dir = NULL; - opk->specials = NULL; - opk->previously_printed = 0; - - return opk; -} - -static int -_opkg_opk_opk_add_seek_name(struct _opkg_opk_opk_seek_name **head, - struct _opkg_opk_opk_seek_name **tail, const char *name) -{ - struct _opkg_opk_opk_seek_name *new; - - new = malloc(sizeof(*new)); - if (new == NULL) { - return OPKG_OPK_ERROR; - } - if (name[0] == '.' && name[1] == '/') { - new->name = name + 2; - } else if (name[0] == '/') { - new->name = name + 1; - } else { - new->name = name; - } - - new->prev = *tail; - new->next = NULL; - - if (*head == NULL) { - *head = new; - } else { - (*tail)->next = new; - } - *tail = new; - - return OPKG_OPK_OK; -} - -int -opkg_opk_opk_print_control(struct opkg_opk_opk *opk, const char *name) -{ - return _opkg_opk_opk_add_seek_name(&opk->print_control_head, - &opk->print_control_tail, name); -} - -int -opkg_opk_opk_print_data(struct opkg_opk_opk *opk, const char *name) -{ - return _opkg_opk_opk_add_seek_name(&opk->print_data_head, - &opk->print_data_tail, name); -} - -int -opkg_opk_opk_list_control(struct opkg_opk_opk *opk) -{ - opk->list_control = 1; - return OPKG_OPK_OK; -} - -int -opkg_opk_opk_list_data(struct opkg_opk_opk *opk) -{ - opk->list_data = 1; - return OPKG_OPK_OK; -} - -int -opkg_opk_opk_control_dir(struct opkg_opk_opk *opk, const char *dir) -{ - opk->control_dir = dir; - opk->control_dir_len = strlen(dir); - return OPKG_OPK_OK; -} - -int -opkg_opk_opk_data_dir(struct opkg_opk_opk *opk, const char *dir) -{ - opk->data_dir = dir; - opk->data_dir_len = strlen(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) -{ - struct _opkg_opk_opk_seek_name *name; - - while (opk->print_control_head != NULL) { - name = opk->print_control_head; - opk->print_control_head = opk->print_control_head->next; - free(name); - } - while (opk->print_data_head != NULL) { - name = opk->print_data_head; - opk->print_data_head = opk->print_data_head->next; - free(name); - } - opkg_opk_specials_free(opk->specials); - free(opk); -} |