/* Index in units array (see common.c) */
#define NO_UNIT -1
-#define UNIT_SECTOR 0
-#define UNIT_BYTE 1
-#define UNIT_KILOBYTE 2
+
+enum {
+ UNIT_SECTOR = 0,
+ UNIT_BYTE = 1,
+ UNIT_KILOBYTE = 2
+};
#define NR_UNITS 8
#define PERCENT_LIMIT_LOW 25.0
#define PERCENT_LIMIT_XLOW 10.0
-#define XHIGH 1
-#define XLOW 2
-#define XLOW0 3
+enum {
+ XHIGH = 1,
+ XLOW = 2,
+ XLOW0 = 3
+};
#define MAX_SGR_LEN 16
-#define IS_INT 0
-#define IS_STR 1
-#define IS_RESTART 2
-#define IS_DEBUG IS_RESTART
-#define IS_COMMENT 3
-#define IS_ZERO 4
+enum {
+ IS_INT = 0,
+ IS_STR = 1,
+ IS_RESTART = 2,
+ IS_COMMENT = 3,
+ IS_ZERO = 4,
+ IS_DEBUG = IS_RESTART
+};
/*
***************************************************************************
#define USE_ALL_DIR(m) (((m) & I_D_ALL_DIR) == I_D_ALL_DIR)
#define DISPLAY_COMPACT(m) (((m) & I_D_COMPACT) == I_D_COMPACT)
-#define T_PART 0
-#define T_DEV 1
-#define T_PART_DEV 2
-#define T_GROUP 3
+enum {
+ T_PART = 0,
+ T_DEV = 1,
+ T_PART_DEV = 2,
+ T_GROUP = 3
+};
#define UKWN_MAJ_NR 0
* @action Open or close action.
***************************************************************************
*/
-void json_markup_network(int tab, int action)
+void json_markup_network(int tab, enum json_action action)
{
static int markup_state = CLOSE_JSON_MARKUP;
* @action Open or close action.
***************************************************************************
*/
-void json_markup_power_management(int tab, int action)
+void json_markup_power_management(int tab, enum json_action action)
{
static int markup_state = CLOSE_JSON_MARKUP;
* @action Open or close action.
***************************************************************************
*/
-void json_markup_psi(int tab, int action)
+void json_markup_psi(int tab, enum json_action action)
{
static int markup_state = CLOSE_JSON_MARKUP;
* IN:
* @p_timestamp Timestamp for previous stat sample.
* @a Activity structure.
- * @pos Header to display, 0 being the first header (headers
+ * @pos Header to display, FIRST being the first header (headers
* are delimited by the '|' character).
* @iwidth First column width (generally this is the item name).
* A negative value means that the corresponding field
#define NR_F_COUNT 13
/* Activities */
-#define A_CPU 1
-#define A_PCSW 2
-#define A_IRQ 3
-#define A_SWAP 4
-#define A_PAGE 5
-#define A_IO 6
-#define A_MEMORY 7
-#define A_KTABLES 8
-#define A_QUEUE 9
-#define A_SERIAL 10
-#define A_DISK 11
-#define A_NET_DEV 12
-#define A_NET_EDEV 13
-#define A_NET_NFS 14
-#define A_NET_NFSD 15
-#define A_NET_SOCK 16
-#define A_NET_IP 17
-#define A_NET_EIP 18
-#define A_NET_ICMP 19
-#define A_NET_EICMP 20
-#define A_NET_TCP 21
-#define A_NET_ETCP 22
-#define A_NET_UDP 23
-#define A_NET_SOCK6 24
-#define A_NET_IP6 25
-#define A_NET_EIP6 26
-#define A_NET_ICMP6 27
-#define A_NET_EICMP6 28
-#define A_NET_UDP6 29
-#define A_PWR_CPU 30
-#define A_PWR_FAN 31
-#define A_PWR_TEMP 32
-#define A_PWR_IN 33
-#define A_HUGE 34
-#define A_PWR_FREQ 35
-#define A_PWR_USB 36
-#define A_FS 37
-#define A_NET_FC 38
-#define A_NET_SOFT 39
-#define A_PSI_CPU 40
-#define A_PSI_IO 41
-#define A_PSI_MEM 42
-
+enum {
+ A_CPU = 1,
+ A_PCSW = 2,
+ A_IRQ = 3,
+ A_SWAP = 4,
+ A_PAGE = 5,
+ A_IO = 6,
+ A_MEMORY = 7,
+ A_KTABLES = 8,
+ A_QUEUE = 9,
+ A_SERIAL = 10,
+ A_DISK = 11,
+ A_NET_DEV = 12,
+ A_NET_EDEV = 13,
+ A_NET_NFS = 14,
+ A_NET_NFSD = 15,
+ A_NET_SOCK = 16,
+ A_NET_IP = 17,
+ A_NET_EIP = 18,
+ A_NET_ICMP = 19,
+ A_NET_EICMP = 20,
+ A_NET_TCP = 21,
+ A_NET_ETCP = 22,
+ A_NET_UDP = 23,
+ A_NET_SOCK6 = 24,
+ A_NET_IP6 = 25,
+ A_NET_EIP6 = 26,
+ A_NET_ICMP6 = 27,
+ A_NET_EICMP6 = 28,
+ A_NET_UDP6 = 29,
+ A_PWR_CPU = 30,
+ A_PWR_FAN = 31,
+ A_PWR_TEMP = 32,
+ A_PWR_IN = 33,
+ A_HUGE = 34,
+ A_PWR_FREQ = 35,
+ A_PWR_USB = 36,
+ A_FS = 37,
+ A_NET_FC = 38,
+ A_NET_SOFT = 39,
+ A_PSI_CPU = 40,
+ A_PSI_IO = 41,
+ A_PSI_MEM = 42
+};
/* Macro used to flag an activity that should be collected */
#define COLLECT_ACTIVITY(m) act[get_activity_position(act, m, EXIT_IF_NOT_FOUND)]->options |= AO_COLLECTED
#define EXIT_IF_NOT_FOUND 1
#define RESUME_IF_NOT_FOUND 0
-#define SOFT_SIZE 0
-#define HARD_SIZE 1
+enum size_mode {
+ SOFT_SIZE = 0,
+ HARD_SIZE = 1
+};
-#define FIRST 0
-#define SECOND 1
+enum {
+ FIRST = 0,
+ SECOND = 1
+};
-#define END_OF_DATA_UNEXPECTED 1
-#define INCONSISTENT_INPUT_DATA 2
+enum sa_err_codes {
+ END_OF_DATA_UNEXPECTED = 1,
+ INCONSISTENT_INPUT_DATA = 2
+};
-#define UEOF_STOP 0
-#define UEOF_CONT 1
+enum on_eof {
+ UEOF_STOP = 0,
+ UEOF_CONT = 1
+};
-#define CLOSE_XML_MARKUP 0
-#define OPEN_XML_MARKUP 1
+enum xml_action {
+ CLOSE_XML_MARKUP = 0,
+ OPEN_XML_MARKUP = 1
+};
-#define CLOSE_JSON_MARKUP 0
-#define OPEN_JSON_MARKUP 1
+enum json_action {
+ CLOSE_JSON_MARKUP = 0,
+ OPEN_JSON_MARKUP = 1
+};
-#define COUNT_ACTIVITIES 0
-#define COUNT_OUTPUTS 1
+enum count_mode {
+ COUNT_ACTIVITIES = 0,
+ COUNT_OUTPUTS = 1
+};
/* Type for all functions reading statistics */
#define __read_funct_t void
/*
***************************************************************************
- * Output formats for sadf
+ * Output formats for sadfsize_mode
***************************************************************************
*/
#define NR_FMT 9
/* Output formats */
-#define F_SAR_OUTPUT 0
-#define F_DB_OUTPUT 1
-#define F_HEADER_OUTPUT 2
-#define F_PPC_OUTPUT 3
-#define F_XML_OUTPUT 4
-#define F_JSON_OUTPUT 5
-#define F_CONV_OUTPUT 6
-#define F_SVG_OUTPUT 7
-#define F_RAW_OUTPUT 8
-#define F_PCP_OUTPUT 9
-
+enum {
+ F_SAR_OUTPUT = 0,
+ F_DB_OUTPUT = 1,
+ F_HEADER_OUTPUT = 2,
+ F_PPC_OUTPUT = 3,
+ F_XML_OUTPUT = 4,
+ F_JSON_OUTPUT = 5,
+ F_CONV_OUTPUT = 6,
+ F_SVG_OUTPUT = 7,
+ F_RAW_OUTPUT = 8,
+ F_PCP_OUTPUT = 9
+};
/* Structure for SVG specific parameters */
struct svg_parm {
#define MAX_EXTRA_SIZE 1024
/* Record type */
-/*
- * R_STATS means that this is a record of statistics.
- */
-#define R_STATS 1
-/*
- * R_RESTART means that this is a special record containing
- * a LINUX RESTART message.
- */
-#define R_RESTART 2
-/*
- * R_LAST_STATS warns sar that this is the last record to be written
- * to file before a file rotation, and that the next data to come will
- * be a header file.
- * Such a record is tagged R_STATS anyway before being written to file.
- */
-#define R_LAST_STATS 3
-/*
- * R_COMMENT means that this is a special record containing
- * a comment.
- */
-#define R_COMMENT 4
-/*
- * R_EXTRA* records means that extra structures are following current
- * record_header structure, but no statistics structures.
- */
-#define R_EXTRA_MIN 5
-#define R_EXTRA_MAX 15
+enum {
+ /*
+ * R_STATS means that this is a record of statistics.
+ */
+ R_STATS = 1,
+ /*
+ * R_RESTART means that this is a special record containing
+ * a LINUX RESTART message.
+ */
+ R_RESTART = 2,
+ /*
+ * R_LAST_STATS warns sar that this is the last record to be written
+ * to file before a file rotation, and that the next data to come will
+ * be a header file.
+ * Such a record is tagged R_STATS anyway before being written to file.
+ */
+ R_LAST_STATS = 3,
+ /*
+ * R_COMMENT means that this is a special record containing
+ * a comment.
+ */
+ R_COMMENT = 4,
+ /*
+ * R_EXTRA* records means that extra structures are following current
+ * record_header structure, but no statistics structures.
+ */
+ R_EXTRA_MIN = 5,
+ R_EXTRA_MAX = 15
+};
/* Maximum length of a comment */
#define MAX_COMMENT_LEN 64
/* Maximum number of views on a single row */
#define MAX_VIEWS_ON_A_ROW 6
-#define SVG_LINE_GRAPH 1
-#define SVG_BAR_GRAPH 2
+enum svg_graph_type {
+ SVG_LINE_GRAPH = 1,
+ SVG_BAR_GRAPH = 2
+};
/* Maximum number of horizontal lines for the background grid */
#define MAX_HLINES_NR 10
#define SVG_COL_HEADER_IDX 22
#define SVG_COL_ERROR_IDX 23
-#define SVG_DEFAULT_COL_PALETTE 0
-#define SVG_CUSTOM_COL_PALETTE 1
-#define SVG_BW_COL_PALETTE 2
+enum {
+ SVG_DEFAULT_COL_PALETTE = 0,
+ SVG_CUSTOM_COL_PALETTE = 1,
+ SVG_BW_COL_PALETTE = 2
+};
#define MAYBE 0x80
void enum_version_nr
(struct file_magic *);
int get_activity_nr
- (struct activity * [], unsigned int, int);
+ (struct activity * [], unsigned int, enum count_mode);
int get_activity_position
(struct activity * [], unsigned int, int);
void handle_invalid_sa_file
struct file_header *, struct activity * [], struct report_format *, int, int);
int read_file_stat_bunch
(struct activity * [], int, int, int, struct file_activity *, int, int,
- char *, struct file_magic *, int);
+ char *, struct file_magic *, enum on_eof);
__nr_t read_nr_value
(int, char *, struct file_magic *, int, int, int);
int read_record_hdr
void replace_nonprintable_char
(int, char *);
int sa_fread
- (int, void *, size_t, int, int);
+ (int, void *, size_t, enum size_mode, enum on_eof);
int sa_get_record_timestamp_struct
(uint64_t, struct record_header *, struct tm *);
int sa_open_read_magic
* Count number of activities with given option.
*
* IN:
- * @act Array of activities.
- * @option Option that activities should have to be counted
- * (eg. AO_COLLECTED...)
- * @count_outputs TRUE if each output should be counted for activities with
- * multiple outputs.
+ * @act Array of activities.
+ * @option Option that activities should have to be counted
+ * (eg. AO_COLLECTED...)
+ * @count Set to COUNT_OUTPUTS if each output should be counted for
+ * activities with multiple outputs.
*
* RETURNS:
* Number of selected activities
***************************************************************************
*/
-int get_activity_nr(struct activity *act[], unsigned int option, int count_outputs)
+int get_activity_nr(struct activity *act[], unsigned int option, enum count_mode count)
{
int i, n = 0;
unsigned int msk;
for (i = 0; i < NR_ACT; i++) {
if ((act[i]->options & option) == option) {
- if (HAS_MULTIPLE_OUTPUTS(act[i]->options) && count_outputs) {
+ if (HAS_MULTIPLE_OUTPUTS(act[i]->options) && (count == COUNT_OUTPUTS)) {
for (msk = 1; msk < 0x100; msk <<= 1) {
if ((act[i]->opt_flags & 0xff) & msk) {
n++;
* 0 otherwise.
***************************************************************************
*/
-int sa_fread(int ifd, void *buffer, size_t size, int mode, int oneof)
+int sa_fread(int ifd, void *buffer, size_t size, enum size_mode mode, enum on_eof oneof)
{
ssize_t n;
int read_file_stat_bunch(struct activity *act[], int curr, int ifd, int act_nr,
struct file_activity *file_actlst, int endian_mismatch,
int arch_64, char *dfile, struct file_magic *file_magic,
- int oneof)
+ enum on_eof oneof)
{
int i, j, p;
struct file_activity *fal = file_actlst;
*/
int read_next_sample(int ifd, int action, int curr, char *file, int *rtype, int tab,
struct file_magic *file_magic, struct file_activity *file_actlst,
- struct tm *rectime, int oneof)
+ struct tm *rectime, enum on_eof oneof)
{
int rc;
char rec_hdr_tmp[MAX_RECORD_HEADER_SIZE];
#define XML_DTD_VERSION "3.12"
/* Various constants */
-#define DO_SAVE 0
-#define DO_RESTORE 1
+enum {
+ DO_SAVE = 0,
+ DO_RESTORE = 1
+};
#define IGNORE_NOTHING 0
#define IGNORE_RESTART 1
* @itv Interval of time with preceding record.
* @record_hdr Record header for current sample (unused here).
* @file_hdr System activity file standard header.
- * @flags Flags for common options.
+ * @flags Flags for common options (unused here).
*
* RETURNS:
* Pointer on the "timestamp" string.
***************************************************************************
*/
__tm_funct_t print_ppc_timestamp(void *parm, int action, char *cur_date,
- char *cur_time, char * my_tz, unsigned long long itv,
+ char *cur_time, char *my_tz, unsigned long long itv,
struct record_header *record_hdr,
struct file_header *file_hdr, unsigned int flags)
{
* @error_code Code of error message to display.
***************************************************************************
*/
-void print_read_error(int error_code)
+void print_read_error(enum sa_err_codes error_code)
{
switch (error_code) {
* @asfactor Autoscale factors (one for each graph).
***************************************************************************
*/
-void gr_autoscaling(unsigned int asfactor[], int asf_nr, int group, int g_type, int pos,
- double gmax, double *spmax)
+void gr_autoscaling(unsigned int asfactor[], int asf_nr, int group, enum svg_graph_type g_type,
+ int pos, double gmax, double *spmax)
{
int j;
char val[32];
#ifndef _SVG_STATS_H
#define _SVG_STATS_H
-
/*
***************************************************************************
* Prototypes for functions used to display system statistics in SVG.
#define DISPLAY_ZERO_OMIT(m) (((m) & T_D_ZERO_OMIT) == T_D_ZERO_OMIT)
#define DISPLAY_UNIT(m) (((m) & T_D_UNIT) == T_D_UNIT)
-#define TAPE_STATS_VALID 1
-#define TAPE_STATS_INVALID 0
+enum {
+ TAPE_STATS_INVALID = 0,
+ TAPE_STATS_VALID = 1
+};
#define SYSFS_CLASS_TAPE_DIR PRE "/sys/class/scsi_tape"
#define TAPE_STAT_PATH PRE "/sys/class/scsi_tape/st%i/stats/"
* @action Open or close action.
***************************************************************************
*/
-void xml_markup_network(int tab, int action)
+void xml_markup_network(int tab, enum xml_action action)
{
static int markup_state = CLOSE_XML_MARKUP;
* @action Open or close action.
***************************************************************************
*/
-void xml_markup_power_management(int tab, int action)
+void xml_markup_power_management(int tab, enum xml_action action)
{
static int markup_state = CLOSE_XML_MARKUP;
* @action Open or close action.
***************************************************************************
*/
-void xml_markup_psi(int tab, int action)
+void xml_markup_psi(int tab, enum xml_action action)
{
static int markup_state = CLOSE_XML_MARKUP;