Use uppercase M for printing maintainer field, to be consistent.
[project/opkg-lede.git] / libopkg / conffile.c
1 /* conffile.c - the opkg package management system
2
3 Carl D. Worth
4
5 Copyright (C) 2001 University of Southern California
6
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.
11
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.
16 */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #include "opkg_message.h"
22 #include "conffile.h"
23 #include "file_util.h"
24 #include "sprintf_alloc.h"
25 #include "opkg_conf.h"
26
27 int conffile_init(conffile_t *conffile, const char *file_name, const char *md5sum)
28 {
29 return nv_pair_init(conffile, file_name, md5sum);
30 }
31
32 void conffile_deinit(conffile_t *conffile)
33 {
34 nv_pair_deinit(conffile);
35 }
36
37 int conffile_has_been_modified(conffile_t *conffile)
38 {
39 char *md5sum;
40 char *filename = conffile->name;
41 char *root_filename;
42 int ret = 1;
43
44 if (conffile->value == NULL) {
45 opkg_msg(NOTICE, "Conffile %s has no md5sum.\n", conffile->name);
46 return 1;
47 }
48
49 root_filename = root_filename_alloc(filename);
50
51 md5sum = file_md5sum_alloc(root_filename);
52
53 if (md5sum && (ret = strcmp(md5sum, conffile->value))) {
54 opkg_msg(INFO, "Conffile %s:\n\told md5=%s\n\tnew md5=%s\n",
55 conffile->name, md5sum, conffile->value);
56 }
57
58 free(root_filename);
59 if (md5sum)
60 free(md5sum);
61
62 return ret;
63 }