File: warnings.h

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (119 lines) | stat: -rw-r--r-- 3,472 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/************************************************************************
 * Copyright (C) 2006-2008 Philipp Marek.
 *
 * This program is free software;  you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3 as
 * published by the Free Software Foundation.
 ************************************************************************/

#ifndef __WARNINGS_H__
#define __WARNINGS_H__


#include "options.h"


/** \file
 * Declarations and public enumerations for the warning subsystem.
 * */


/** List of possible actions for warning messages. */
typedef enum {
	/** Warn only once. This has to be 0 to be the default! */
	WA__WARN_ONCE=0,
	/** Warn every time */
	WA__WARN_ALWAYS,
	/** Print an error, stop execution, and exit with an error code. */
	WA__STOP,
	/** Ignore this warning. */
	WA__IGNORE,
	/** Just count this warning. If we got an \ref WA__WARN_ONCE warning it's 
	 * set to this value; this way it is still incremented and printed 
	 * in a summary. Ignored warnings are completely ignored. */
	WA__COUNT,
	/** The maximum index. Keep this at the end! */
	_WA__LAST_INDEX
} warning_action_e;


/** Definitions for warnings. */
struct wa__warnings
{
	/** Short name for command line processing */
	char text[24];
	/** Action to take. When ONCE is reached, it gets changed to IGNORE. */
	warning_action_e action;
	/** How often this warning occured. Always incremented; 
	 * may be >1 for WARN_ONCE. */
	unsigned count;
	/** Whether the user set some value other than the default. */
	enum opt__prio_e prio;
};


/** List of defined warnings. */
typedef enum {
	/** Invalid mtime property. */
	WRN__META_MTIME_INVALID,
	/** Invalid user property. */
	WRN__META_USER_INVALID,
	/** Invalid group property. */
	WRN__META_GROUP_INVALID,
	/** Invalid unix-mode property. */
	WRN__META_UMASK_INVALID,

	/** No URL defined for entry. */
	WRN__NO_URLLIST,

	/** \c LC_CTYPE and/or \c LC_ALL are invalid. */
	WRN__CHARSET_INVALID,

	/** A normal user gets a \c EPERM on \c chmod(), if he is not owner.
	 * Could happen if file data is the same, but meta-data has changed. */
	WRN__CHMOD_EPERM,
	/** Other error codes of \c chmod() - not needed, as they should always
	 * lead to a stop? */
	WRN__CHMOD_OTHER,
	/** Normal users may not call \c chown(); they get an \c EPERM. */
	WRN__CHOWN_EPERM,
	/** Other error codes of \c chown() - not needed, as they should always
	 * lead to a stop? */
	WRN__CHOWN_OTHER,

	/** A property should be set with an reserved name. */
	WRN__PROP_NAME_RESERVED,

	/** Mixed revision working copies not allowed. */
	WRN__MIXED_REV_WC,

	/** Diff returned an exit status of 2 (means error).
	 * But as that is returned for diffing binary files, too,
	 * the exit status is normally ignored. */
	WRN__DIFF_EXIT_STATUS,

	/** Absolute ignore pattern doesn't match wc base. */
	WRN__IGNPAT_WCBASE,

	/** Test warning - for debugging and automated testing. */
	WRN__TEST_WARNING,
	/** Maximum index - keep this at the end! */
	_WRN__LAST_INDEX
} warning_e;


/** Possibly print a warning. */
int wa__warn(warning_e index, int status, char *format, ...)
	__attribute__ ((format (printf, 3, 4) ));
/** Set the action of one or warnings. */
int wa__set_warn_option(char *stg, enum opt__prio_e prio);

/** Print the warning summary as debug messages.  */
int wa__summary(void);

/** Splits a string on whitespace, and sets warning options. */
int wa__split_process(char *warn, int prio);


#endif