|
1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
|
24 * Use is subject to license terms. |
|
25 */ |
|
26 |
|
27 |
|
28 #ifndef _FSEXAM_ERROR_H |
|
29 #define _FSEXAM_ERROR_H |
|
30 |
|
31 /* |
|
32 * If change any ERR_*, exec 'make clean' before 'make' |
|
33 */ |
|
34 typedef enum { |
|
35 /* INFO */ |
|
36 ERR_OK = 0, |
|
37 ERR_NAME_UTF8_ALREADY, |
|
38 ERR_CONTENT_UTF8_ALREADY, |
|
39 ERR_NAME_SAME, |
|
40 /* ERROR */ |
|
41 ERR_ERROR, /* 1 */ |
|
42 ERR_FILE_NONEXIST, |
|
43 ERR_NO_MEMORY, |
|
44 ERR_ENCODING_INDEX_INVALID, |
|
45 ERR_CANNOT_OPEN, |
|
46 ERR_CANNOT_RENAME, |
|
47 ERR_CANNOT_WRITE, |
|
48 ERR_NO_PROPER_ENCODING, |
|
49 ERR_NOT_REG_FILE, |
|
50 ERR_SYMLINK_TARGET_NOEXIST, |
|
51 ERR_CANNOT_CONVERT, |
|
52 ERR_CANNOT_READ, |
|
53 ERR_NO_RIGHTS, |
|
54 ERR_CANNOT_RM_SYMLINK, |
|
55 ERR_LOST_SYMLINK_FILE, |
|
56 ERR_DRYRUN_FILE_INVALID, |
|
57 ERR_GET_CWD, |
|
58 ERR_CHDIR, |
|
59 /* WARNING */ |
|
60 ERR_WARNING, |
|
61 ERR_HIST_NO_ITEM, |
|
62 ERR_TREE_IS_EMPTY, |
|
63 ERR_NAME_EXIST, |
|
64 ERR_IGNORE_HIDDEN_FILE, |
|
65 ERR_IGNORE_REMOTE_FILE, |
|
66 ERR_EMPTY_FILE, |
|
67 ERR_NO_PARAMS, |
|
68 ERR_FILTER, |
|
69 ERR_FILE_TYPE_NOT_SUPPORT, |
|
70 ERR_BUFFER_OVERFLOW, |
|
71 ERR_CANCEL_CONVERSION, |
|
72 /* Won't write log */ |
|
73 ERR_WONNOT_LOG, |
|
74 ERR_CANNOT_WRITE_DRYRUN, |
|
75 ERR_CANNOT_OPEN_DRYRUN, |
|
76 ERR_CANNOT_CONVERT_TO_URI, |
|
77 /* Misc error */ |
|
78 ERR_MISC, |
|
79 } ERROR_NO; |
|
80 |
|
81 extern ERROR_NO fsexam_errno; |
|
82 |
|
83 const char *fsexam_error_get_msg (void); |
|
84 |
|
85 void _fsexam_perror (char *errnofile, int line, char *filename); |
|
86 |
|
87 #define fsexam_perror(filename) \ |
|
88 do { \ |
|
89 _fsexam_perror (__FILE__, __LINE__, filename); \ |
|
90 }while (0) |
|
91 |
|
92 /* |
|
93 * How to make one elegant error handling machanism? |
|
94 * |
|
95 * - system error: errno need remember |
|
96 * - custermized error: fsexam_errno |
|
97 * - error context: such as |
|
98 * - filename, may be more than one file |
|
99 * - Sometime there is error occured, but we still have |
|
100 * get some result, such as get_abs_path, we have get |
|
101 * the abs path, but can't rechange to old_cwd |
|
102 * |
|
103 * - buffer overflow: do we need check and report? |
|
104 * - strlcpy, strlcat |
|
105 * - fgets |
|
106 * |
|
107 * - Who need to check the input is NULL or not? |
|
108 * - caller? |
|
109 * - callee? |
|
110 */ |
|
111 |
|
112 #endif //_FSEXAM_ERROR_H |