1/*
2 * Copyright (c) 2008 Apple Computer, Inc.  All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License").  You may not use this file except in compliance with the
9 * License.  Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22#ifndef PREFERENCES_H
23#define PREFERENCES_H
24
25#include <stdbool.h>
26#include <unistd.h>
27
28enum {
29    STATMODE_ACCUM = 1,
30    STATMODE_DELTA,
31    STATMODE_EVENT,
32    STATMODE_NON_EVENT
33};
34
35void top_prefs_init(void);
36
37/*
38 * One of:
39 * a accumulative mode
40 * d delta mode
41 * e event mode
42 * n non-event mode
43 */
44bool top_prefs_set_mode(const char *mode);
45int top_prefs_get_mode(void);
46const char *top_prefs_get_mode_string(void);
47
48void top_prefs_set_sleep(int seconds);
49int top_prefs_get_sleep(void);
50
51/* Take a symbolic string such as "cpu" */
52bool top_prefs_set_sort(const char *sort);
53/* Return one of the TOP_SORT enum values from above. */
54int top_prefs_get_sort(void);
55
56bool top_prefs_set_secondary_sort(const char *sort);
57int top_prefs_get_secondary_sort(void);
58
59const char *top_prefs_get_sort_string(void);
60const char *top_prefs_get_secondary_sort_string(void);
61
62/* This is used to sorting in ascending order (if flag is true). */
63void top_prefs_set_ascending(bool flag);
64
65bool top_prefs_get_ascending(void);
66
67void top_prefs_set_frameworks(bool flag);
68bool top_prefs_get_frameworks(void);
69
70void top_prefs_set_frameworks_interval(int interval);
71int top_prefs_get_frameworks_interval(void);
72
73void top_prefs_set_user(const char *user);
74
75char *top_prefs_get_user(void);
76
77void top_prefs_set_user_uid(uid_t uid);
78uid_t top_prefs_get_user_uid(void);
79
80/* Returns true if the comma separated names list is invalid. */
81bool top_prefs_set_stats(const char *names);
82bool top_prefs_get_stats(int *total, int **array);
83
84int top_prefs_get_samples(void);
85void top_prefs_set_samples(int s);
86
87int top_prefs_get_nprocs(void);
88void top_prefs_set_nprocs(int n);
89
90void top_prefs_set_pid(pid_t pid);
91bool top_prefs_get_pid(pid_t *pidptr);
92
93/* Returns true if the signal string is invalid. */
94bool top_prefs_set_signal_string(char *s);
95int top_prefs_get_signal(const char **sptr);
96
97void top_prefs_set_logging_mode(bool mode);
98bool top_prefs_get_logging_mode(void);
99
100void top_prefs_set_ncols(int limit);
101/* Returns true if the ncols has been set. */
102bool top_prefs_get_ncols(int *limit);
103
104void top_prefs_set_swap(bool show);
105bool top_prefs_get_swap(void);
106
107void top_prefs_set_secondary_ascending(bool flag);
108bool top_prefs_get_secondary_ascending(void);
109
110/* memory map reporting */
111void top_prefs_set_mmr(bool mmr);
112bool top_prefs_get_mmr(void);
113
114#endif /*PREFERENCES_H*/
115