blob: 2fd314849495ccf428a4d44ab4d71038d9b2ab64 [file] [log] [blame]
Dieter Baron5149dfb2003-10-05 16:05:25 +00001/*
Dieter Baron1f3803c2005-06-09 19:57:10 +00002 $NiH: zip_error.c,v 1.6 2005/01/11 18:30:30 dillo Exp $
Dieter Baron5149dfb2003-10-05 16:05:25 +00003
4 zip_error.c -- struct zip_error helper functions
Dieter Baron1f3803c2005-06-09 19:57:10 +00005 Copyright (C) 1999, 2003, 2004, 2005 Dieter Baron and Thomas Klausner
Dieter Baron5149dfb2003-10-05 16:05:25 +00006
7 This file is part of libzip, a library to manipulate ZIP archives.
8 The authors can be contacted at <nih@giga.or.at>
9
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions
12 are met:
13 1. Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15 2. Redistributions in binary form must reproduce the above copyright
16 notice, this list of conditions and the following disclaimer in
17 the documentation and/or other materials provided with the
18 distribution.
19 3. The names of the authors may not be used to endorse or promote
20 products derived from this software without specific prior
21 written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
24 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
27 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34*/
35
36
37
38#include <stdlib.h>
39
40#include "zip.h"
41#include "zipint.h"
42
43
44
45void
Dieter Baronadaf98c2003-10-06 16:37:42 +000046_zip_error_copy(struct zip_error *dst, struct zip_error *src)
47{
48 dst->zip_err = src->zip_err;
49 dst->sys_err = src->sys_err;
50}
51
52
53
54void
Dieter Baron5149dfb2003-10-05 16:05:25 +000055_zip_error_fini(struct zip_error *err)
56{
57 free(err->str);
58 err->str = NULL;
59}
60
61
62
Dieter Barone3f91ef2003-10-06 02:50:14 +000063void
64_zip_error_get(struct zip_error *err, int *zep, int *sep)
65{
66 if (zep)
67 *zep = err->zip_err;
Dieter Barona87f0e82005-01-11 18:30:30 +000068 if (sep) {
69 if (zip_error_get_sys_type(err->zip_err) != ZIP_ET_NONE)
70 *sep = err->sys_err;
71 else
72 *sep = 0;
73 }
Dieter Barone3f91ef2003-10-06 02:50:14 +000074}
Dieter Baron5149dfb2003-10-05 16:05:25 +000075
Dieter Barone3f91ef2003-10-06 02:50:14 +000076
77
78void
79_zip_error_init(struct zip_error *err)
Dieter Baron5149dfb2003-10-05 16:05:25 +000080{
81 err->zip_err = 0;
82 err->sys_err = 0;
83 err->str = NULL;
84}
Dieter Barone3f91ef2003-10-06 02:50:14 +000085
86
87
88void
89_zip_error_set(struct zip_error *err, int ze, int se)
90{
Dieter Baronb2ed74d2004-04-14 14:01:31 +000091 if (err) {
92 err->zip_err = ze;
93 err->sys_err = se;
94 }
Dieter Barone3f91ef2003-10-06 02:50:14 +000095}