1 /* conffile.c - the opkg package management system
5 Copyright (C) 2001 University of Southern California
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
21 #include "opkg_message.h"
23 #include "file_util.h"
24 #include "sprintf_alloc.h"
25 #include "opkg_conf.h"
27 int conffile_init(conffile_t * conffile, const char *file_name,
30 return nv_pair_init(conffile, file_name, md5sum);
33 void conffile_deinit(conffile_t * conffile)
35 nv_pair_deinit(conffile);
38 int conffile_has_been_modified(conffile_t * conffile)
41 char *filename = conffile->name;
45 if (conffile->value == NULL) {
46 opkg_msg(NOTICE, "Conffile %s has no md5sum.\n",
51 root_filename = root_filename_alloc(filename);
53 if (conffile->value && strlen(conffile->value) > 33) {
54 chksum = file_sha256sum_alloc(root_filename);
56 chksum = file_md5sum_alloc(root_filename);
59 if (chksum && (ret = strcmp(chksum, conffile->value))) {
60 opkg_msg(INFO, "Conffile %s:\n\told chk=%s\n\tnew chk=%s\n",
61 conffile->name, chksum, conffile->value);