4 * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
5 * Copyright (c) 2005 by Judd Vinet <jvinet@zeroflux.org>
6 * Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
7 * Copyright (c) 2005 by Christian Hamar <krics@linuxforum.hu>
8 * Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #include "alpm_list.h"
35 /* split a backup string "file\thash" into the relevant components */
36 int _alpm_split_backup(const char *string
, alpm_backup_t
**backup
)
40 STRDUP(str
, string
, return -1);
43 ptr
= str
? strchr(str
, '\t') : NULL
;
45 (*backup
)->name
= str
;
46 (*backup
)->hash
= NULL
;
51 /* now str points to the filename and ptr points to the hash */
52 STRDUP((*backup
)->name
, str
, return -1);
53 STRDUP((*backup
)->hash
, ptr
, return -1);
58 /* Look for a filename in a alpm_pkg_t.backup list. If we find it,
59 * then we return the full backup entry.
61 alpm_backup_t
*_alpm_needbackup(const char *file
, alpm_pkg_t
*pkg
)
63 const alpm_list_t
*lp
;
65 if(file
== NULL
|| pkg
== NULL
) {
69 for(lp
= alpm_pkg_get_backup(pkg
); lp
; lp
= lp
->next
) {
70 alpm_backup_t
*backup
= lp
->data
;
72 if(strcmp(file
, backup
->name
) == 0) {
80 void _alpm_backup_free(alpm_backup_t
*backup
)
87 alpm_backup_t
*_alpm_backup_dup(const alpm_backup_t
*backup
)
89 alpm_backup_t
*newbackup
;
90 CALLOC(newbackup
, 1, sizeof(alpm_backup_t
), return NULL
);
92 STRDUP(newbackup
->name
, backup
->name
, return NULL
);
93 STRDUP(newbackup
->hash
, backup
->hash
, return NULL
);
98 /* vim: set ts=2 sw=2 noet: */