mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Use a platform-specific routine for long option usage
Related to https://github.com/htop-dev/htop/pull/564
This commit is contained in:
parent
d56d23d91a
commit
253ff23f9e
@ -23,9 +23,6 @@ in the source distribution for its full text.
|
||||
#include "generic/uname.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
extern const ProcessField Platform_defaultFields[];
|
||||
|
||||
extern double Platform_timebaseToNS;
|
||||
@ -80,6 +77,10 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
@ -21,9 +21,6 @@ in the source distribution for its full text.
|
||||
#include "generic/uname.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
extern const ProcessField Platform_defaultFields[];
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
@ -70,6 +67,10 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
@ -22,9 +22,6 @@ in the source distribution for its full text.
|
||||
#include "generic/uname.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
extern const ProcessField Platform_defaultFields[];
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
@ -75,6 +72,10 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
9
htop.c
9
htop.c
@ -48,7 +48,6 @@ static void printHelpFlag(const char* name) {
|
||||
"-d --delay=DELAY Set the delay between updates, in tenths of seconds\n"
|
||||
"-F --filter=FILTER Show only the commands matching the given filter\n"
|
||||
"-h --help Print this help screen\n"
|
||||
PLATFORM_LONG_OPTIONS_USAGE
|
||||
"-H --highlight-changes[=DELAY] Highlight new and old processes\n"
|
||||
"-M --no-mouse Disable the mouse\n"
|
||||
"-p --pid=PID[,PID,PID...] Show only the given PIDs\n"
|
||||
@ -56,12 +55,12 @@ static void printHelpFlag(const char* name) {
|
||||
"-t --tree Show the tree view (can be combined with -s)\n"
|
||||
"-u --user[=USERNAME] Show only processes for a given user (or $USER)\n"
|
||||
"-U --no-unicode Do not use unicode but plain ASCII\n"
|
||||
"-V --version Print version info\n"
|
||||
"\n"
|
||||
"-V --version Print version info\n", name);
|
||||
Platform_longOptionsUsage(name);
|
||||
printf("\n"
|
||||
"Long options may be passed with a single dash.\n\n"
|
||||
"Press F1 inside %s for online help.\n"
|
||||
"See 'man %s' for more information.\n",
|
||||
name, name, name);
|
||||
"See 'man %s' for more information.\n", name, name);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
|
@ -846,6 +846,20 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
|
||||
Platform_Battery_cacheTime = now;
|
||||
}
|
||||
|
||||
void Platform_longOptionsUsage(const char* name)
|
||||
{
|
||||
#ifdef HAVE_LIBCAP
|
||||
printf(
|
||||
" --drop-capabilities[=none|basic|strict] Drop Linux capabilities when running as root\n"
|
||||
" none - do not drop any capabilities\n"
|
||||
" basic (default) - drop all capabilities not needed by %s\n"
|
||||
" strict - drop all capabilities except those needed for\n"
|
||||
" core functionality\n", name);
|
||||
#else
|
||||
(void) name;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Platform_getLongOption(int opt, int argc, char** argv) {
|
||||
#ifndef HAVE_LIBCAP
|
||||
(void) argc;
|
||||
|
@ -27,19 +27,6 @@ in the source distribution for its full text.
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBCAP
|
||||
#define PLATFORM_LONG_OPTIONS \
|
||||
{"drop-capabilities", optional_argument, 0, 128},
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE \
|
||||
" --drop-capabilities[=none|basic|strict] Drop Linux capabilities when running as root\n" \
|
||||
" none - do not drop any capabilities\n" \
|
||||
" basic (default) - drop all capabilities not needed by htop\n" \
|
||||
" strict - drop all capabilities except those needed for core functionality\n"
|
||||
#else
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
#endif
|
||||
|
||||
|
||||
extern const ProcessField Platform_defaultFields[];
|
||||
|
||||
@ -95,6 +82,15 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBCAP
|
||||
#define PLATFORM_LONG_OPTIONS \
|
||||
{"drop-capabilities", optional_argument, 0, 128},
|
||||
#else
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#endif
|
||||
|
||||
void Platform_longOptionsUsage(const char* name);
|
||||
|
||||
bool Platform_getLongOption(int opt, int argc, char** argv);
|
||||
|
||||
#endif
|
||||
|
@ -23,9 +23,6 @@ in the source distribution for its full text.
|
||||
#include "generic/uname.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
extern const ProcessField Platform_defaultFields[];
|
||||
|
||||
/* see /usr/include/sys/signal.h */
|
||||
@ -73,6 +70,10 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
@ -26,9 +26,6 @@ in the source distribution for its full text.
|
||||
#include "generic/uname.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
#define kill(pid, signal) kill(pid / 1024, signal)
|
||||
|
||||
typedef struct var kvar_t;
|
||||
@ -92,6 +89,10 @@ static inline void Platform_getRelease(char** string) {
|
||||
*string = Generic_uname();
|
||||
}
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
@ -17,9 +17,6 @@ in the source distribution for its full text.
|
||||
#include "UnsupportedProcess.h"
|
||||
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
#define PLATFORM_LONG_OPTIONS_USAGE
|
||||
|
||||
extern const SignalItem Platform_signals[];
|
||||
|
||||
extern const unsigned int Platform_numberOfSignals;
|
||||
@ -64,6 +61,10 @@ void Platform_getHostname(char* buffer, size_t size);
|
||||
|
||||
void Platform_getRelease(char** string);
|
||||
|
||||
#define PLATFORM_LONG_OPTIONS
|
||||
|
||||
static inline void Platform_longOptionsUsage(ATTR_UNUSED const char* name) { }
|
||||
|
||||
static inline bool Platform_getLongOption(ATTR_UNUSED int opt, ATTR_UNUSED int argc, ATTR_UNUSED char** argv) {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user