2018-05-12 16:03:00 +00:00
|
|
|
/*
|
2009-08-05 22:46:51 +00:00
|
|
|
*
|
|
|
|
* Conky, a system monitor, based on torsmo
|
|
|
|
*
|
|
|
|
* Any original torsmo code is licensed under the BSD license
|
|
|
|
*
|
|
|
|
* All code written since the fork of torsmo is licensed under the GPL
|
|
|
|
*
|
|
|
|
* Please see COPYING for details
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
2018-05-12 16:03:00 +00:00
|
|
|
* Copyright (c) 2005-2018 Brenden Matthews, Philip Kovacs, et. al.
|
2009-08-05 22:46:51 +00:00
|
|
|
* (see AUTHORS)
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/* local headers */
|
|
|
|
#include "algebra.h"
|
2009-11-29 13:14:06 +00:00
|
|
|
#include "bsdapm.h"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "build.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "colours.h"
|
2009-10-17 14:14:25 +00:00
|
|
|
#include "combine.h"
|
2018-05-13 18:27:58 +00:00
|
|
|
#include "core.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "diskio.h"
|
2009-11-12 22:50:17 +00:00
|
|
|
#include "entropy.h"
|
2009-10-15 19:51:21 +00:00
|
|
|
#include "exec.h"
|
2009-11-16 19:58:26 +00:00
|
|
|
#include "i8k.h"
|
2018-08-06 22:09:20 +00:00
|
|
|
#include "misc.h"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "text_object.h"
|
2010-10-30 15:44:33 +00:00
|
|
|
#ifdef BUILD_IMLIB2
|
2009-11-28 21:45:01 +00:00
|
|
|
#include "imlib2.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_IMLIB2 */
|
2009-11-11 09:55:25 +00:00
|
|
|
#include "proc.h"
|
2010-04-18 15:52:41 +00:00
|
|
|
#ifdef BUILD_MYSQL
|
|
|
|
#include "mysql.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_MYSQL */
|
2010-04-27 14:42:21 +00:00
|
|
|
#ifdef BUILD_ICAL
|
|
|
|
#include "ical.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_ICAL */
|
2010-04-30 17:32:42 +00:00
|
|
|
#ifdef BUILD_IRC
|
|
|
|
#include "irc.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_IRC */
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "fonts.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "fs.h"
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_IBM
|
2009-12-17 21:11:42 +00:00
|
|
|
#include "ibm.h"
|
|
|
|
#include "smapi.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_IBM */
|
2010-01-20 17:17:30 +00:00
|
|
|
#ifdef BUILD_ICONV
|
2009-10-03 18:01:33 +00:00
|
|
|
#include "iconv_tools.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_ICONV */
|
2009-12-28 20:05:40 +00:00
|
|
|
#include "llua.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "logging.h"
|
|
|
|
#include "mail.h"
|
|
|
|
#include "mboxscan.h"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "mixer.h"
|
2010-04-30 17:33:21 +00:00
|
|
|
#include "nc.h"
|
2009-10-17 14:43:12 +00:00
|
|
|
#include "net_stat.h"
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_NVIDIA
|
2009-10-03 14:14:23 +00:00
|
|
|
#include "nvidia.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_NVIDIA */
|
2018-08-06 22:09:20 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include "cpu.h"
|
2010-04-17 00:31:37 +00:00
|
|
|
#include "read_tcpip.h"
|
2009-10-06 23:04:32 +00:00
|
|
|
#include "scroll.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "specials.h"
|
2018-05-12 16:03:00 +00:00
|
|
|
#include "tailhead.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "temphelper.h"
|
2009-09-03 21:53:20 +00:00
|
|
|
#include "template.h"
|
2009-10-03 15:46:59 +00:00
|
|
|
#include "timeinfo.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#include "top.h"
|
2009-11-29 15:40:23 +00:00
|
|
|
#include "user.h"
|
2009-11-25 23:51:19 +00:00
|
|
|
#include "users.h"
|
2010-12-31 15:43:49 +00:00
|
|
|
#ifdef BUILD_CURL
|
|
|
|
#include "ccurl_thread.h"
|
|
|
|
#endif /* BUILD_CURL */
|
2011-01-06 10:14:24 +00:00
|
|
|
#ifdef BUILD_WEATHER_METAR
|
|
|
|
#include "weather.h"
|
|
|
|
#endif /* BUILD_WEATHER_METAR */
|
2011-02-15 23:33:22 +00:00
|
|
|
#ifdef BUILD_RSS
|
|
|
|
#include "rss.h"
|
|
|
|
#endif /* BUILD_RSS */
|
2011-03-25 14:06:26 +00:00
|
|
|
#ifdef BUILD_AUDACIOUS
|
|
|
|
#include "audacious.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_AUDACIOUS */
|
2011-05-10 20:40:53 +00:00
|
|
|
#ifdef BUILD_CMUS
|
|
|
|
#include "cmus.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_CMUS */
|
2016-05-06 11:25:30 +00:00
|
|
|
#ifdef BUILD_JOURNAL
|
|
|
|
#include "journal.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_JOURNAL */
|
2016-06-24 14:17:20 +00:00
|
|
|
#ifdef BUILD_PULSEAUDIO
|
|
|
|
#include "pulseaudio.h"
|
2018-08-20 12:32:42 +00:00
|
|
|
#endif /* BUILD_PULSEAUDIO */
|
2009-08-07 07:24:24 +00:00
|
|
|
|
|
|
|
/* check for OS and include appropriate headers */
|
|
|
|
#if defined(__linux__)
|
|
|
|
#include "linux.h"
|
|
|
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
|
|
|
#include "freebsd.h"
|
2012-06-28 16:56:01 +00:00
|
|
|
#elif defined(__DragonFly__)
|
|
|
|
#include "dragonfly.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#elif defined(__OpenBSD__)
|
|
|
|
#include "openbsd.h"
|
Basic macOS support (#480)
* Initial patches for Darwin support
* cmake files ready for building on Sierra. Dont know about other OSX versions
* Added darwin.h which will contain darwin specific headers
* Patches for enablin asprintf support (needs _POSIX_C_SOURCE >= __DARWIN_C_FULL so remove -D_POSIX_C_SOURCE=200809L). What is more, -D_LARGEFILE64_SOURCE is used by default so not needed on macOS
* Stubs for get_entropy_avail and get_entropy_poolsize
* More progress to getting to build
* More patches
* Now builds, remains fixing linking errors. Also implemented some functions
* Now links
* Now conky runs without sigabrt()'ing... An exception in semaphore.hh caused it to crash immediately upon initialisation
* README changes
* This was based on an old attempt I did with porting conky where I hadn't cloned the repo and thus it showed 3166 commits behind
* Patched a bit the semaphore.hh and now conky runs at 0.7% CPU usage and not in 100% or 200% as it did before! Yeah
* This update fixes swap-related miscalculations, though:
On macOS there can be used MANY swapfiles ( NOT swap partitions,,, the installation disk is the partition for storing swap memory data )
Thus conky code must be updated for Darwin to support multi-swapfile usage stats.
For now, we default to showing stats for swapfile0
* Fixed a bit the comments so they make sense
* Realised that the sysctl code can give us stats for the whole swap storage so removed the swapmode( int swapfd, unsigned long * retvail, unsigned long * retfree )
* I think the code is in good condition now
* semaphore.hh: Implemented ~semaphore() and added throwing exception
when sem initialisation fails just like in sem() for linux…
darwin.cc: partially implemented update_cpu_usage() and
update_total_processes()
* Implements update_total_processes()
( Now it finds the correct number of tasks )
the changes in cmake file don’t change the functionality… It is only
comments.
In upcoming updates lua support may be enabled and the comments are
related to lua support.
* get_cpu_count() now conforms to newer sysctl code as suggested by Apple ( we use hw.logicalcpumax instead of hw.ncpus ) --> The new implementation of get_cpu_count() finds the the max value of logical cores the mac could use on a boot.
update_total_processes() was patched to allow initialising only ONCE when conky runs the machHost and processorSet ( this could probably be implemented in a better way I guess though... )
* patch
* experimental support for get_top_info() and update_cpu_usage() :)
* going to patch stuff
* adds getting rss memory in get_top_info()
* fixes
* Couple things made more beautiful but too many things to fix ...
* Remove unneeded code from darwin_soundcard.h and keep only needed to
compile ( This way we are compatible to GPLv3, i think )
Include GPLv3 header in darwin.cc, darwin.h and darwin_soundcard.h
Add more beautiful and explanatory comments to ease the work of other
contributors… ( Mostly on things that don’t work! )
* Merged the macOS update_cpu_usage() implementation with the linux implementation but still it doesn't work as expected, plus, there are more memory related problems that will be fixed in newer release!
NOTE: It will be really good to see how functions are implemented on linux.cc for more complete implementation
* Now using a more linux-influenced implementation and dropping the old... ( only keeps mach stuff )
Needs some more work though to print accurate percentage! :)
* Add conky installer (.pkg) project
* Now gets thread count aswell! For now, we get this from update_total_processes... Also, removed the installer project because I need to learn more the software
* Properly get thread count!
- Patched core.cc to enable getting threads count on macOS!
- Cleanup in darwin.cc
* sort out some things in the code:
- running_threads_count is not the same as thread_count on macOS! There is actually a difference!
Correct a bit the code!
* Enable the if_mounted command and start implementing the check_mount function in darwin.cc
* Tighten things up
* This patch makes conky build easily and without patching on any supported macOS version! The new flag introduced is a temporary solution for allowing conky to compile on other OS without tweaking the cmake files. If you want to compile it with i18l support you will have to run the command: brew link gettext after you install gettext
* Update README to provide more complete info on building on macOS
* Fix
* patch check_mounted + SIP status
This commit:
- patches check_mounted function to match the implementation found in FreeBSD.cc! Now conky expects typing something like this:
conky -t '${if_mounted /Volumes/MacOS} ${endif}'
Please note that the correct way is "/Volumes/MacOS", not "/Volumes/MacOS/" ! You shouldnt put the backslash at the end... It will not work!
- Adds a new command called sip_status which you can use to make conky show System Integrity Protection related information such as if filesystem protection is enabled, if user approved kexts protection is enabled and more...
you can type conky -t '$sip_status' to see what it does...
( I will most likely update some things later regarding sip_status and check_mounted )
* Further implement sip_status
sip_status now has different functionality!
If you give no arguments it shows whether SIP is enabled or disabled ( generally )
If you give argument ( takes only ONE ) you can specify which specific thing of SIP you want to show status for...
You need to pass 0, 1, ..., 9 to $sip_status as argument to print status for apple-internal, untrusted-kexts, and more...
Below you can see the list:
ARG: RESULT:
nothing --> print enabled / disabled
0 --> allow_apple_internal
1 --> allow_untrusted_kexts
2 --> allow_task_for_pid
3 --> allow_unrestricted_fs
4 --> allow_kernel_debugger
5 --> allow_unrestricted_dtrace
6 --> allow_unrestricted_nvram
7 --> allow_device_configuration
8 --> allow_any_recovery_os
9 --> allow_user_approved_kexts
* sip_status progress & if_up enabled
This commit adds the 'a' argument for $sip_status which checks if the SIP configuration is ok or it is likely to break in the future.
Also, enabled the $if_up command, but there are some problems with it...
* sip_status patches
- Updated code based on newest version of csrstat utility (v.1.8)
The 1.8 version fixes a problem in finding status of ALLOW_DEVICE_CONFIGURATION flag.
- Fixed a bug where we mistakenly printed 'disabled' even when SIP was enabled.
* Disable ncurses checks in a way that will allow compiling for other OSes! ( it was a really quick patch before )
* More changes in cmake file to make code prettier and more exact
* More cmake files cuteness
* work for supporting versions prior Sierra
This patch brings more compatibility with versions prior to Sierra.
The project as is nearly links on a 10.9.5 OSX installation.
- on versions prior Sierra clock_gettime() is not implemented thus we need to provide our own implementation for conky to work. ( Currently we have minimal support, more studying needs to be done )
NOTE: In order to compile on versions as old as Mavericks you will need newer compilers because command line tools for 10.9.5 dont support some C++11 features... For this I donwloaded the commandline tools for Xcode 8.1 ( or 8 dont remember well ) and installed only the CommandLine Tools section with Pacifist!
( The OSX installer sees the OS as too old, so you need pacifist! )
* Oops
* $if_mounted ready
This patch removes the unneded print_mounted() function!
Also cleanup code.
* $if_up works
I think $if_up command works therefore remove the APPLE specific code in core.cc ( there wasnt anything different anyway ) and use the FreeBSD code.
Minor conky output changes in darwin.cc
* fix compatibility with Mavericks and before...
This update allows conky to be compiled on Mavericks and before by checking at compilation time what our build target is.
If it is Mavericks or lower, then cant use the csr_get_active_config func because it is not available.
On higher versions than Mavericks it works as before...
NOTE: For compiling on Mavericks or lower you will have to write 10.9 in CMAKE_OSX_DEPLOYMENT_TARGET when you run ccmake
* Added link for youtube video showing conky running on macOS
* Improvements
Minor improvements related to style
Removed unneeded free() calls
* Simplify Xcode configuration process! :)
* Removed update_cpu_usage() implementation
It was quite buggy so I removed it...
* Cleanup the source code
1. Bogus TODO comments have been deleted!
2. Started using DEBUG_MODE based printf
3. Explain some things better/cleanup
* Last small cleanup
The TODO in get_from_load_info() was unneeded. Removed!
Also, DEBUG_MODE is enabled for now...
* update authors file
* Improve README
Make it more clean and easier to understand.
* Update README.md
small tweak
* Work for conforming with "Development" rules
1. Add to variables.xml documentation about the $sip_status variable.
2. Add sip_status variable to conkyrc.vim and nanorc to allow highlighting
3. the friends in darwin.cc is ambiguous,,, some are more than friends.
* First patch set that implements get_top_info()
:)
* Calculate cpu usage of all processes more efficiently. (Now results match Activity Monitor's results a lot!!!)
More info about the get_top_info() implementation will come once I finish it! (soon)
* Cleanup patch!
o Move a couple things to better places
o Rename get_sample() to get_cpu_sample() to allow to be used by different functions such as get_cpu_usage() ( this is a scene from the future... )
o Improve the way we get cpu usage for each process by passing the already created proc_taskinfo struct to the appropriate function instead of creating another one
inside it!
* Correctly enable $running_processes variable
In our implementation update_top() doesn't calculate the count of running processes! We assign this functionality to the update_running_processes() function.
* Removed unneeded flag
This is not needed because we do not use update_top() for getting the number of running processes!
* Update README.md
* Update README.md
This adds support for TravisCL.
Though this will compile the project only on Linux it is a good sign to know if our port still can compile on Linux or we have broken things. It seems like it can't but I suspect the problem existed before my patches. I will investigate.
* First patch towards implementing #15
This patch a reworked get_top_info(). We now use the function get_top_info_for_kinfo_proc() to set the contents of each |process| struct.
Also, we calculate the total cpu usage and total process usage concurrently using GCD.
Aside from these we bring the function helper_get_proc_list() which makes the code simpler and cleaner.
* First fix for the algorithm that calculates % CPU usage of a process
The previous patch made the algorithm buggy. It required more reentrant-safe functions.
Make calc_cpu_total_r() which is a more reentrant-safe reimplementation of the calc_cpu_total() function.
This is not the last commit, more are coming in the future.
* Previous commit wasn't pushed...
* Problems committing
* Make the code cleaner but break the algorithm again #15
The algorithm doesn't work... It is a work in progress!
But this time we have merged the cpu_info and cpusample into one struct called cpusample
( I copied some variables from the linux implementation but they will probably be removed )
* Rework the code a bit / CPU usage % algorithm still doesn't work
Now get_from_load_info() is renamed to helper_update_threads_processes() and is called by both update_threads() and update_total_processes()
This makes the code nicer and removes the enum with the flags
* cleanup
remove unneeded functions, remove unneeded variables
* bugfix
* bugfix
* remove the whole get_top_info() code!
I will rework a lot this code so we can get rid of it.
* Work for #15
Now we use the ultimate solution for calculating % usage of CPU of a process!
Check the #15 Issue for information about this patch!
* Quick memory leak fix & some patches for the get_top_info algorithm
* quick patch for semaphore class
* Update the comments
* For consistency
* temp
* Revert "Merge branch 'master' into update_cpu_usage"
This reverts commit 7267a515c40d54b85107e51016703e6c10f3183e, reversing
changes made to 2190ff0b51463c12c61b3357cf846b8e705ebeb4.
* Revert "Revert "Merge branch 'master' into update_cpu_usage""
This reverts commit 692bd27a3adb2fe7027d65932467a140e42cc7bc.
* Partially implement the overall % CPU usage
* bug fix: I meant procs and threads!
* make the code better part1
* cleanup
* Stabilise the values of get_cpu_sample(). Affects get_top_info() and update_cpu_usage() ( fixes #13 and #15 )
For some reason the code that used host_statistics() function didn't produced bad values quite often. Replaced the function with host_processor_info() and changed the algorithm
and now the values are correct!
This affects the get_top_info() and update_cpu_usage() functions which wouldn't work correctly until now.
* Finish the optimised version of get_top_info()
Fixes #15
* Quick fix for #16
Probably I will come up with a different location for get_cpu_count() because I want to conform to linux implementation.
Also, the memory leak I am mentioning in get_cpu_count() may not actually exist, as I suspected in the back of my head.
* Strictness
* Cleanup ConkyPlatformChecks.cmake
Cleanup the quick patch code for Lua.
* Add warning to README
If you are using old version of cmake, update it. It will probably have problems when trying to locate lua.
* More cleanup
* Fix identation
This simplifies the diff.
Also, note that by merging the new code for checking for NCURSES we acheive better compatibility and easy build process
* Remove mixer related patches and files
With the newest patches from upstream, cmake checks if the header soundcard.h exists on the system.
If it doesn't exist (in the case of macOS for example) all mixer-related variables are disabled.
* Changes for using as submodule for ConkyX
* Fixes
* Implement get_freq
This implements #11
Though it doesn't support getting the **current** cpu frequency.
I haven't found a way to do it on macOS but i guess it can be done using a kernel extension. I may come back to this again in the future
* First work for correcting mem stats #6
Incorporate the update_pages_stolen() function and all of its dependencies.
I will see if I can patch the code in order to avoid license problems
* Work for #6
Now we follow the way apple's top works and not Activity Monitor.
For this reason we find different values. But correct based on top.
* cleanup for #6
* bug fix 1
* cleanup
* hmm sorry
* More cleanup
- Move the libtop_tsamp_t object to darwin.cc.
- Remove unneeded member variables.
* A bit documentation
* Implement secondary memory stats #6
Implement memwithbuffers, memeasyfree and memfree (which isn't secondary)
* Quit update_meminfo if libtop_tsamp_update_vm_stats() failed
* Update README.md
Revert to original conky readme
Move all macOS related information to the Wiki: https://github.com/Conky-for-macOS/conky-for-macOS/wiki
* Alot junk slipped in too!
* Merge net_stats branch
For now, I have only tested up / down bytes count on en0, and it works.
This is for #14
* Corrections
- Fix License headers in darwin* files
- Remove ConkyX entry from .gitignore which slipped into from the "forConkyX" branch which was used for another project ... ConkyX.
- Cleanup top.h (I will request the changes in a pull request finally)
* Fix identation and cleanup
* identation-fixes part1
* Try to fix problem compiling on linux
Improve checks for headers in ConkyPlatformChecks.cmake to amend the problem;
I mistakenly thought that statfs64 wasn't available in sys/statfs.h in macOS thus I tried to add platform specific code. Though, I add the checks in the wrong place and also messed up linux-specific code by replacing checks_include sys/statfs with check_symbol_exists statfs64
* attemp to completely fix linux problem!
2018-05-07 11:27:32 +00:00
|
|
|
#elif defined(__APPLE__) && defined(__MACH__)
|
|
|
|
#include "darwin.h"
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-08-07 16:09:34 +00:00
|
|
|
#define STRNDUP_ARG strndup(arg ? arg : "", text_buffer_size.get(*state))
|
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/* strip a leading /dev/ if any, following symlinks first
|
|
|
|
*
|
|
|
|
* BEWARE: this function returns a pointer to static content
|
|
|
|
* which gets overwritten in consecutive calls. I.e.:
|
|
|
|
* this function is NOT reentrant.
|
|
|
|
*/
|
2018-05-12 16:03:00 +00:00
|
|
|
const char *dev_name(const char *path) {
|
|
|
|
static char buf[PATH_MAX];
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-13 18:27:58 +00:00
|
|
|
if (path == nullptr) { return nullptr; }
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-13 18:27:58 +00:00
|
|
|
#define DEV_NAME(x) \
|
|
|
|
((x) != nullptr && strlen(x) > 5 && strncmp(x, "/dev/", 5) == 0 ? (x) + 5 \
|
|
|
|
: (x))
|
|
|
|
if (realpath(path, buf) == nullptr) { return DEV_NAME(path); }
|
2018-05-12 16:03:00 +00:00
|
|
|
return DEV_NAME(buf);
|
2009-08-07 07:24:24 +00:00
|
|
|
#undef DEV_NAME
|
|
|
|
}
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
static struct text_object *new_text_object_internal() {
|
|
|
|
auto *obj = static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
memset(obj, 0, sizeof(struct text_object));
|
|
|
|
return obj;
|
2009-08-05 22:46:51 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
static struct text_object *create_plain_text(const char *s) {
|
|
|
|
struct text_object *obj;
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-13 18:27:58 +00:00
|
|
|
if (s == nullptr || *s == '\0') { return nullptr; }
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
obj = new_text_object_internal();
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
obj_be_plain_text(obj, s);
|
|
|
|
return obj;
|
2009-08-07 07:24:24 +00:00
|
|
|
}
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2010-04-19 12:54:03 +00:00
|
|
|
#ifdef BUILD_CURL
|
2018-05-12 16:03:00 +00:00
|
|
|
void stock_parse_arg(struct text_object *obj, const char *arg) {
|
|
|
|
char stock[8];
|
|
|
|
char data[16];
|
2010-04-19 12:45:05 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
obj->data.s = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
if (sscanf(arg, "%7s %15s", stock, data) != 2) {
|
|
|
|
NORM_ERR("wrong number of arguments for $stock");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!strcasecmp("ask", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "a", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("adv", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "a2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("asksize", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "a5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("bid", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "b", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("askrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "b2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("bidrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "b3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("bookvalue", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "b4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("bidsize", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "b6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("change", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "c1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("commission", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "c3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("changert", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "c6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ahcrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "c8", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ds", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "d", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ltd", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "d1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("tradedate", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "d2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("es", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "e", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ei", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "e1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("epsecy", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "e7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("epseny", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "e8", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("epsenq", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "e9", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("floatshares", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "f6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dayslow", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dayshigh", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "h", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("52weeklow", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("52weekhigh", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "k", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hgp", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ag", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hg", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hgprt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hgrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "g6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("moreinfo", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "i", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("obrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "i5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("mc", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("mcrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ebitda", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("c52wlow", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pc52wlow", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "j6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("cprt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "k2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("lts", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "k3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("c52whigh", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "k4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pc52whigh", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "k5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ltp", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "l1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hl", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "l2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ll", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "l3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dr", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("drrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("50ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m3", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("200ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("c200ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pc200ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("c50ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pc50ma", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "m8", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("name", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "n", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("notes", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "n4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("open", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "o", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pc", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "p", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pricepaid", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "p1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("cip", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "p2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ps", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "p5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pb", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "p6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("edv", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "q", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("per", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dpd", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("perrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r2", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pegr", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r5", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pepsecy", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("pepseny", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "r7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("symbol", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "s", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("sharesowned", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "s1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("shortratio", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "s7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("ltt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "t1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("tradelinks", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "t6", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("tt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "t7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("1ytp", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "t8", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("volume", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "v", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hv", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "v1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("hvrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "v7", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("52weekrange", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "w", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dvc", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "w1", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dvcrt", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "w4", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("se", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "x", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else if (!strcasecmp("dy", data))
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(data, "y", 3);
|
2018-05-12 16:03:00 +00:00
|
|
|
else {
|
|
|
|
NORM_ERR(
|
|
|
|
"\"%s\" is not supported by $stock. Supported: 1ytp, 200ma, 50ma, "
|
|
|
|
"52weeklow, 52weekhigh, 52weekrange, adv, ag, ahcrt, ask, askrt, "
|
|
|
|
"asksize, bid, bidrt, bidsize, bookvalue, c200ma, c50ma, c52whigh, "
|
|
|
|
"c52wlow, change, changert, cip, commission, cprt, dayshigh, dayslow, "
|
|
|
|
"dpd, dr, drrt, ds, dvc, dvcrt, dy, ebitda, edv, ei, epsecy, epsenq, "
|
|
|
|
"epseny, es, floatshares, hg, hgp, hgprt, hl, hv, hvrt, ll, ltd, ltp, "
|
|
|
|
"lts, ltt, mc, mcrt, moreinfo, name, notes, obrt, open, pb, pc, "
|
|
|
|
"pc200ma, pc50ma, pc52whigh, pc52wlow, pegr, pepsecy, pepseny, per, "
|
|
|
|
"perrt, pricepaid, ps, se, sharesowned, shortratio, symbol, tradedate, "
|
|
|
|
"tradelinks, tt, volume",
|
|
|
|
data);
|
|
|
|
return;
|
|
|
|
}
|
2010-04-19 12:45:05 +00:00
|
|
|
#define MAX_FINYAH_URL_LENGTH 64
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.s = (char *)malloc(MAX_FINYAH_URL_LENGTH);
|
|
|
|
snprintf(obj->data.s, MAX_FINYAH_URL_LENGTH,
|
|
|
|
"http://download.finance.yahoo.com/d/quotes.csv?s=%s&f=%s", stock,
|
|
|
|
data);
|
2010-04-19 12:45:05 +00:00
|
|
|
}
|
2010-04-19 12:54:03 +00:00
|
|
|
#endif /* BUILD_CURL */
|
2010-04-19 12:45:05 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
legacy_cb_handle *create_cb_handle(int (*fn)()) {
|
2018-05-12 23:26:31 +00:00
|
|
|
if (fn != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
return new legacy_cb_handle(conky::register_cb<legacy_cb>(1, fn));
|
2018-05-12 23:26:31 +00:00
|
|
|
}
|
|
|
|
{ return nullptr; }
|
2010-12-31 12:39:54 +00:00
|
|
|
}
|
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/* construct_text_object() creates a new text_object */
|
2018-05-12 16:03:00 +00:00
|
|
|
struct text_object *construct_text_object(char *s, const char *arg, long line,
|
|
|
|
void **ifblock_opaque,
|
|
|
|
void *free_at_crash) {
|
|
|
|
// struct text_object *obj = new_text_object();
|
|
|
|
struct text_object *obj = new_text_object_internal();
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->line = line;
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2009-09-09 23:35:57 +00:00
|
|
|
/* helper defines for internal use only */
|
2018-05-12 16:03:00 +00:00
|
|
|
#define __OBJ_HEAD(a, n) \
|
|
|
|
if (!strcmp(s, #a)) { \
|
|
|
|
obj->cb_handle = create_cb_handle(n);
|
2009-09-09 23:35:57 +00:00
|
|
|
#define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj)
|
2018-05-12 16:03:00 +00:00
|
|
|
#define __OBJ_ARG(...) \
|
|
|
|
if (!arg) { \
|
|
|
|
free(s); \
|
|
|
|
CRIT_ERR(obj, free_at_crash, __VA_ARGS__); \
|
|
|
|
}
|
2009-09-09 23:35:57 +00:00
|
|
|
|
|
|
|
/* defines to be used below */
|
|
|
|
#define OBJ(a, n) __OBJ_HEAD(a, n) {
|
|
|
|
#define OBJ_ARG(a, n, ...) __OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) {
|
2018-05-12 16:03:00 +00:00
|
|
|
#define OBJ_IF(a, n) \
|
|
|
|
__OBJ_HEAD(a, n) __OBJ_IF; \
|
|
|
|
{
|
|
|
|
#define OBJ_IF_ARG(a, n, ...) \
|
|
|
|
__OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) __OBJ_IF; \
|
|
|
|
{
|
|
|
|
#define END \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
else
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
if (s[0] == '#') {
|
|
|
|
obj->data.l = get_x11_color(s);
|
|
|
|
obj->callbacks.print = &new_fg;
|
|
|
|
} else
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2009-12-13 01:34:29 +00:00
|
|
|
#ifndef __OpenBSD__
|
2018-05-12 23:26:31 +00:00
|
|
|
OBJ(acpitemp, nullptr)
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.i = open_acpi_temperature(arg);
|
|
|
|
obj->callbacks.print = &print_acpitemp;
|
|
|
|
obj->callbacks.free = &free_acpitemp;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(acpiacadapter, nullptr) if (arg != nullptr) {
|
2010-01-24 14:34:03 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 23:26:31 +00:00
|
|
|
if (strpbrk(arg, "/.") != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
/*
|
|
|
|
* a bit of paranoia. screen out funky paths
|
|
|
|
* i hope no device will have a '.' in its name
|
|
|
|
*/
|
|
|
|
NORM_ERR("acpiacadapter: arg must not contain '/' or '.'");
|
|
|
|
} else
|
|
|
|
obj->data.opaque = strdup(arg);
|
2010-01-24 14:34:03 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
NORM_ERR("acpiacadapter: arg is only used on linux");
|
2010-01-24 14:34:03 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_acpiacadapter;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* !__OpenBSD__ */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(freq, nullptr) get_cpu_count();
|
2018-08-06 22:09:20 +00:00
|
|
|
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
|
|
|
|
strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
2018-08-08 15:56:31 +00:00
|
|
|
(unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.i = 1;
|
|
|
|
/* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
|
|
|
|
"Displaying the clock for CPU 1."); */
|
|
|
|
} else {
|
|
|
|
obj->data.i = atoi(&arg[0]);
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_freq;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(freq_g, nullptr) get_cpu_count();
|
2018-08-06 22:09:20 +00:00
|
|
|
if ((arg == nullptr) || (isdigit((unsigned char)arg[0]) == 0) ||
|
|
|
|
strlen(arg) >= 3 || atoi(&arg[0]) == 0 ||
|
2018-08-08 15:56:31 +00:00
|
|
|
(unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.i = 1;
|
|
|
|
/* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
|
|
|
|
"CPUs! Displaying the clock for CPU 1."); */
|
|
|
|
} else {
|
|
|
|
obj->data.i = atoi(&arg[0]);
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_freq_g;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(read_tcp, nullptr,
|
|
|
|
"read_tcp: Needs \"(host) port\" as argument(s)")
|
2018-05-12 16:03:00 +00:00
|
|
|
parse_read_tcpip_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_read_tcp;
|
|
|
|
obj->callbacks.free = &free_read_tcpip;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(read_udp, nullptr,
|
|
|
|
"read_udp: Needs \"(host) port\" as argument(s)")
|
2018-05-12 16:03:00 +00:00
|
|
|
parse_read_tcpip_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_read_udp;
|
|
|
|
obj->callbacks.free = &free_read_tcpip;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(tcp_ping, nullptr,
|
|
|
|
"tcp_ping: Needs \"host (port)\" as argument(s)")
|
2018-05-12 16:03:00 +00:00
|
|
|
parse_tcp_ping_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_tcp_ping;
|
|
|
|
obj->callbacks.free = &free_tcp_ping;
|
2009-08-07 07:24:24 +00:00
|
|
|
#if defined(__linux__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(voltage_mv, 0) get_cpu_count();
|
2018-08-06 22:09:20 +00:00
|
|
|
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 ||
|
2018-08-08 15:56:31 +00:00
|
|
|
atoi(&arg[0]) == 0 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.i = 1;
|
|
|
|
/* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
|
|
|
|
"CPUs! Displaying voltage for CPU 1."); */
|
|
|
|
} else {
|
|
|
|
obj->data.i = atoi(&arg[0]);
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_voltage_mv;
|
|
|
|
END OBJ(voltage_v, 0) get_cpu_count();
|
2018-08-06 22:09:20 +00:00
|
|
|
if (!arg || !isdigit((unsigned char)arg[0]) || strlen(arg) >= 3 ||
|
2018-08-08 15:56:31 +00:00
|
|
|
atoi(&arg[0]) == 0 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.i = 1;
|
|
|
|
/* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
|
|
|
|
"CPUs! Displaying voltage for CPU 1."); */
|
|
|
|
} else {
|
|
|
|
obj->data.i = atoi(&arg[0]);
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_voltage_v;
|
2018-08-20 12:36:55 +00:00
|
|
|
|
2018-08-07 15:54:01 +00:00
|
|
|
#endif /* __linux__ */
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2010-01-11 00:13:42 +00:00
|
|
|
#ifdef BUILD_WLAN
|
2018-08-07 15:54:01 +00:00
|
|
|
END OBJ(wireless_essid, &update_net_stats) obj->data.opaque =
|
|
|
|
get_net_stat(arg, obj, free_at_crash);
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_essid;
|
|
|
|
END OBJ(wireless_channel, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_channel;
|
|
|
|
END OBJ(wireless_freq, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_frequency;
|
|
|
|
END OBJ(wireless_mode, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_mode;
|
|
|
|
END OBJ(wireless_bitrate, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_bitrate;
|
|
|
|
END OBJ(wireless_ap, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_ap;
|
|
|
|
END OBJ(wireless_link_qual, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_link_qual;
|
|
|
|
END OBJ(wireless_link_qual_max, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_link_qual_max;
|
|
|
|
END OBJ(wireless_link_qual_perc, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_wireless_link_qual_perc;
|
|
|
|
END OBJ(wireless_link_bar, &update_net_stats)
|
|
|
|
parse_net_stat_bar_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.barval = &wireless_link_barval;
|
2010-01-11 00:13:42 +00:00
|
|
|
#endif /* BUILD_WLAN */
|
2018-08-20 12:36:55 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
#ifndef __OpenBSD__
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(acpifan, nullptr) obj->callbacks.print = &print_acpifan;
|
|
|
|
END OBJ(battery, nullptr) char bat[64];
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
sscanf(arg, "%63s", bat);
|
|
|
|
} else {
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(bat, "BAT0", 5);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_battery;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(battery_short, nullptr) char bat[64];
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
sscanf(arg, "%63s", bat);
|
|
|
|
} else {
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(bat, "BAT0", 5);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_battery_short;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-08-19 18:04:28 +00:00
|
|
|
|
|
|
|
END OBJ(battery_status, 0) obj->data.s = strndup(arg ? arg : "BAT0", text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_battery_status;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(battery_time, nullptr) char bat[64];
|
2009-08-05 22:46:51 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
sscanf(arg, "%63s", bat);
|
|
|
|
} else {
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(bat, "BAT0", 5);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_battery_time;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(battery_percent, nullptr) char bat[64];
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
sscanf(arg, "%63s", bat);
|
|
|
|
} else {
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(bat, "BAT0", 5);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.percentage = &battery_percentage;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(battery_bar, nullptr) char bat[64];
|
2010-05-23 09:25:19 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
arg = scan_bar(obj, arg, 100);
|
2018-05-12 23:26:31 +00:00
|
|
|
if ((arg != nullptr) && strlen(arg) > 0) {
|
2018-05-12 16:03:00 +00:00
|
|
|
sscanf(arg, "%63s", bat);
|
|
|
|
} else {
|
2018-05-13 18:27:58 +00:00
|
|
|
strncpy(bat, "BAT0", 5);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
obj->data.s = strndup(bat, text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.barval = &get_battery_perct_bar;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* !__OpenBSD__ */
|
|
|
|
|
|
|
|
#if defined(__linux__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(disk_protect, 0, "disk_protect needs an argument") obj->data.s =
|
|
|
|
strndup(dev_name(arg), text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_disk_protect_queue;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(i8k_version, &update_i8k) obj->callbacks.print = &print_i8k_version;
|
|
|
|
END OBJ(i8k_bios, &update_i8k) obj->callbacks.print = &print_i8k_bios;
|
|
|
|
END OBJ(i8k_serial, &update_i8k) obj->callbacks.print = &print_i8k_serial;
|
|
|
|
END OBJ(i8k_cpu_temp, &update_i8k) obj->callbacks.print = &print_i8k_cpu_temp;
|
|
|
|
END OBJ(i8k_left_fan_status, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_left_fan_status;
|
|
|
|
END OBJ(i8k_right_fan_status, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_right_fan_status;
|
|
|
|
END OBJ(i8k_left_fan_rpm, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_left_fan_rpm;
|
|
|
|
END OBJ(i8k_right_fan_rpm, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_right_fan_rpm;
|
|
|
|
END OBJ(i8k_ac_status, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_ac_status;
|
|
|
|
END OBJ(i8k_buttons_status, &update_i8k) obj->callbacks.print =
|
|
|
|
&print_i8k_buttons_status;
|
2010-01-07 02:38:12 +00:00
|
|
|
#if defined(BUILD_IBM)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(ibm_fan, 0) obj->callbacks.print = &get_ibm_acpi_fan;
|
|
|
|
END OBJ_ARG(ibm_temps, &get_ibm_acpi_temps, "ibm_temps: needs an argument")
|
|
|
|
parse_ibm_temps_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_ibm_temps;
|
|
|
|
END OBJ(ibm_volume, 0) obj->callbacks.print = &get_ibm_acpi_volume;
|
|
|
|
END OBJ(ibm_brightness, 0) obj->callbacks.print = &get_ibm_acpi_brightness;
|
|
|
|
END OBJ(ibm_thinklight, 0) obj->callbacks.print = &get_ibm_acpi_thinklight;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
/* information from sony_laptop kernel module
|
|
|
|
* /sys/devices/platform/sony-laptop */
|
|
|
|
END OBJ(sony_fanspeed, 0) obj->callbacks.print = &get_sony_fanspeed;
|
|
|
|
END OBJ_ARG(ioscheduler, 0, "get_ioscheduler needs an argument (e.g. hda)")
|
|
|
|
obj->data.s = strndup(dev_name(arg), text_buffer_size.get(*state));
|
|
|
|
obj->callbacks.print = &print_ioscheduler;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(laptop_mode, 0) obj->callbacks.print = &print_laptop_mode;
|
|
|
|
END OBJ_ARG(
|
|
|
|
pb_battery, 0,
|
|
|
|
"pb_battery: needs one argument: status, percent or time") if (strcmp(arg,
|
|
|
|
"st"
|
|
|
|
"at"
|
|
|
|
"u"
|
|
|
|
"s") ==
|
|
|
|
EQUAL) {
|
|
|
|
obj->data.i = PB_BATT_STATUS;
|
|
|
|
}
|
|
|
|
else if (strcmp(arg, "percent") == EQUAL) {
|
|
|
|
obj->data.i = PB_BATT_PERCENT;
|
|
|
|
}
|
|
|
|
else if (strcmp(arg, "time") == EQUAL) {
|
|
|
|
obj->data.i = PB_BATT_TIME;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NORM_ERR("pb_battery: illegal argument '%s', defaulting to status", arg);
|
|
|
|
obj->data.i = PB_BATT_STATUS;
|
|
|
|
}
|
|
|
|
obj->callbacks.print = get_powerbook_batt_info;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* __linux__ */
|
2018-05-12 16:03:00 +00:00
|
|
|
#if (defined(__FreeBSD__) || defined(__linux__) || defined(__DragonFly__) || \
|
|
|
|
(defined(__APPLE__) && defined(__MACH__)))
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF_ARG(if_up, nullptr, "if_up needs an argument")
|
|
|
|
parse_if_up_arg(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &interface_up;
|
|
|
|
obj->callbacks.free = &free_if_up;
|
2009-08-05 22:46:51 +00:00
|
|
|
#endif
|
2009-08-07 07:24:24 +00:00
|
|
|
#if defined(__OpenBSD__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(obsd_sensors_temp, 0, "obsd_sensors_temp: needs an argument")
|
|
|
|
parse_obsd_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_obsd_sensors_temp;
|
|
|
|
END OBJ_ARG(obsd_sensors_fan, 0,
|
|
|
|
"obsd_sensors_fan: needs 2 arguments (device and sensor number)")
|
|
|
|
parse_obsd_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_obsd_sensors_fan;
|
|
|
|
END OBJ_ARG(obsd_sensors_volt, 0,
|
|
|
|
"obsd_sensors_volt: needs 2 arguments (device and sensor number)")
|
|
|
|
parse_obsd_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_obsd_sensors_volt;
|
|
|
|
END OBJ(obsd_vendor, 0) obj->callbacks.print = &get_obsd_vendor;
|
|
|
|
END OBJ(obsd_product, 0) obj->callbacks.print = &get_obsd_product;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* __OpenBSD__ */
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(buffers, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_buffers;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(cached, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_cached;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
#define SCAN_CPU(__arg, __var) \
|
|
|
|
{ \
|
|
|
|
int __offset = 0; \
|
|
|
|
if ((__arg) && sscanf(__arg, " cpu%d %n", &(__var), &__offset) > 0) \
|
|
|
|
(__arg) += __offset; \
|
|
|
|
else \
|
|
|
|
(__var) = 0; \
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
END OBJ(cpu, &update_cpu_usage) get_cpu_count();
|
|
|
|
SCAN_CPU(arg, obj->data.i);
|
|
|
|
obj->callbacks.percentage = &cpu_percentage;
|
2018-08-07 15:54:01 +00:00
|
|
|
obj->callbacks.free = &free_cpu;
|
2018-05-12 16:03:00 +00:00
|
|
|
DBGP2("Adding $cpu for CPU %d", obj->data.i);
|
2010-11-13 22:59:31 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(cpugauge, &update_cpu_usage) get_cpu_count();
|
|
|
|
SCAN_CPU(arg, obj->data.i);
|
|
|
|
scan_gauge(obj, arg, 1);
|
|
|
|
obj->callbacks.gaugeval = &cpu_barval;
|
2018-08-07 15:54:01 +00:00
|
|
|
obj->callbacks.free = &free_cpu;
|
2018-05-12 16:03:00 +00:00
|
|
|
DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
|
2010-11-13 22:59:31 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(cpubar, &update_cpu_usage) get_cpu_count();
|
|
|
|
SCAN_CPU(arg, obj->data.i);
|
|
|
|
scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &cpu_barval;
|
2018-08-07 15:54:01 +00:00
|
|
|
obj->callbacks.free = &free_cpu;
|
2018-05-12 16:03:00 +00:00
|
|
|
DBGP2("Adding $cpubar for CPU %d", obj->data.i);
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(cpugraph, &update_cpu_usage) get_cpu_count();
|
2018-05-12 23:26:31 +00:00
|
|
|
char *buf = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
SCAN_CPU(arg, obj->data.i);
|
|
|
|
buf = scan_graph(obj, arg, 1);
|
|
|
|
DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
|
|
|
|
free_and_zero(buf);
|
|
|
|
obj->callbacks.graphval = &cpu_barval;
|
2018-08-07 15:54:01 +00:00
|
|
|
obj->callbacks.free = &free_cpu;
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(loadgraph, &update_load_average) scan_loadgraph_arg(obj, arg);
|
|
|
|
obj->callbacks.graphval = &loadgraphval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(diskio, &update_diskio) parse_diskio_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_diskio;
|
|
|
|
END OBJ(diskio_read, &update_diskio) parse_diskio_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_diskio_read;
|
|
|
|
END OBJ(diskio_write, &update_diskio) parse_diskio_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_diskio_write;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(diskiograph, &update_diskio) parse_diskiograph_arg(obj, arg);
|
|
|
|
obj->callbacks.graphval = &diskiographval;
|
|
|
|
END OBJ(diskiograph_read, &update_diskio) parse_diskiograph_arg(obj, arg);
|
|
|
|
obj->callbacks.graphval = &diskiographval_read;
|
|
|
|
END OBJ(diskiograph_write, &update_diskio) parse_diskiograph_arg(obj, arg);
|
|
|
|
obj->callbacks.graphval = &diskiographval_write;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color, nullptr)
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
if (out_to_x.get(*state)) {
|
2018-05-12 23:26:31 +00:00
|
|
|
obj->data.l =
|
|
|
|
arg != nullptr ? get_x11_color(arg) : default_color.get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
}
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
|
|
|
#ifdef BUILD_NCURSES
|
2018-05-12 16:03:00 +00:00
|
|
|
if (out_to_ncurses.get(*state)) {
|
|
|
|
obj->data.l = COLOR_WHITE;
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
if (strcasecmp(arg, "red") == 0) {
|
|
|
|
obj->data.l = COLOR_RED;
|
|
|
|
} else if (strcasecmp(arg, "green") == 0) {
|
|
|
|
obj->data.l = COLOR_GREEN;
|
|
|
|
} else if (strcasecmp(arg, "yellow") == 0) {
|
|
|
|
obj->data.l = COLOR_YELLOW;
|
|
|
|
} else if (strcasecmp(arg, "blue") == 0) {
|
|
|
|
obj->data.l = COLOR_BLUE;
|
|
|
|
} else if (strcasecmp(arg, "magenta") == 0) {
|
|
|
|
obj->data.l = COLOR_MAGENTA;
|
|
|
|
} else if (strcasecmp(arg, "cyan") == 0) {
|
|
|
|
obj->data.l = COLOR_CYAN;
|
|
|
|
} else if (strcasecmp(arg, "black") == 0) {
|
|
|
|
obj->data.l = COLOR_BLACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
init_pair(obj->data.l, obj->data.l, COLOR_BLACK);
|
|
|
|
}
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_NCURSES */
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_fg;
|
2010-03-11 10:28:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color0, nullptr) obj->data.l = color[0].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color1, nullptr) obj->data.l = color[1].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color2, nullptr) obj->data.l = color[2].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color3, nullptr) obj->data.l = color[3].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color4, nullptr) obj->data.l = color[4].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color5, nullptr) obj->data.l = color[5].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color6, nullptr) obj->data.l = color[6].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color7, nullptr) obj->data.l = color[7].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color8, nullptr) obj->data.l = color[8].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(color9, nullptr) obj->data.l = color[9].get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
set_current_text_color(obj->data.l);
|
|
|
|
obj->callbacks.print = &new_fg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(font, nullptr) scan_font(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_font;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(conky_version, nullptr) obj_be_plain_text(obj, VERSION);
|
|
|
|
END OBJ(conky_build_date, nullptr) obj_be_plain_text(obj, BUILD_DATE);
|
|
|
|
END OBJ(conky_build_arch, nullptr) obj_be_plain_text(obj, BUILD_ARCH);
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(downspeed, &update_net_stats)
|
2018-08-06 22:09:20 +00:00
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_downspeed;
|
|
|
|
END OBJ(downspeedf, &update_net_stats)
|
2018-08-06 22:09:20 +00:00
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_downspeedf;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(downspeedgraph, &update_net_stats)
|
|
|
|
parse_net_stat_graph_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.graphval = &downspeedgraphval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(else, nullptr) obj_be_ifblock_else(ifblock_opaque, obj);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &gen_false_iftest;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(endif, nullptr) obj_be_ifblock_endif(ifblock_opaque, obj);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &gen_print_nothing;
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(eval, nullptr) obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_evaluate;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2010-01-07 02:38:12 +00:00
|
|
|
#if defined(BUILD_IMLIB2) && defined(BUILD_X11)
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(image, nullptr) obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_image_callback;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_IMLIB2 */
|
2010-04-18 15:52:41 +00:00
|
|
|
#ifdef BUILD_MYSQL
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(mysql, 0, "mysql needs a query") obj->data.s = strdup(arg);
|
|
|
|
obj->callbacks.print = &print_mysql;
|
2010-04-18 15:52:41 +00:00
|
|
|
#endif /* BUILD_MYSQL */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(no_update, nullptr, "no_update needs arguments")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_no_update(obj, arg);
|
|
|
|
obj->callbacks.print = &print_no_update;
|
|
|
|
obj->callbacks.free = &free_no_update;
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(cat, 0) obj->data.s = STRNDUP_ARG;
|
2018-05-19 14:27:10 +00:00
|
|
|
obj->callbacks.print = &print_cat;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-08-02 15:15:16 +00:00
|
|
|
|
|
|
|
#ifdef BUILD_X11
|
2018-08-06 22:09:20 +00:00
|
|
|
END OBJ(num_led, 0) obj->callbacks.print = &print_num_led;
|
|
|
|
END OBJ(caps_led, 0) obj->callbacks.print = &print_caps_led;
|
|
|
|
END OBJ(scroll_led, 0) obj->callbacks.print = &print_scroll_led;
|
2018-08-31 12:36:46 +00:00
|
|
|
END OBJ(keyboard_layout, 0) obj->callbacks.print = &print_keyboard_layout;
|
2018-08-06 22:09:20 +00:00
|
|
|
END OBJ(mouse_speed, 0) obj->callbacks.print = &print_mouse_speed;
|
2018-08-02 15:15:16 +00:00
|
|
|
#endif /* BUILD_X11 */
|
|
|
|
|
2018-08-31 12:36:46 +00:00
|
|
|
END OBJ(password, 0) obj->data.s = strndup(arg ? arg : "20", text_buffer_size.get(*state));
|
2018-08-04 20:26:40 +00:00
|
|
|
obj->callbacks.print = &print_password;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
|
2018-08-04 21:11:21 +00:00
|
|
|
#ifdef __x86_64__
|
2018-08-06 22:09:20 +00:00
|
|
|
END OBJ(freq2, 0) obj->callbacks.print = &print_freq2;
|
2018-08-04 20:26:40 +00:00
|
|
|
#endif /* __x86_64__ */
|
|
|
|
|
2018-08-20 12:36:55 +00:00
|
|
|
END OBJ(start_case, 0) obj->data.s = STRNDUP_ARG;
|
2018-08-04 19:01:28 +00:00
|
|
|
obj->callbacks.print = &print_cap;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(catp, 0) obj->data.s = STRNDUP_ARG;
|
2018-05-19 14:27:10 +00:00
|
|
|
obj->callbacks.print = &print_catp;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(exec, nullptr, "exec needs arguments: <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXEC);
|
|
|
|
obj->parse = false;
|
|
|
|
obj->thread = false;
|
|
|
|
register_exec(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_exec;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execi, nullptr, "execi needs arguments: <interval> <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXECI);
|
|
|
|
obj->parse = false;
|
|
|
|
obj->thread = false;
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execp, nullptr, "execp needs arguments: <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXEC);
|
|
|
|
obj->parse = true;
|
|
|
|
obj->thread = false;
|
|
|
|
register_exec(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_exec;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execpi, nullptr, "execpi needs arguments: <interval> <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXECI);
|
|
|
|
obj->parse = true;
|
|
|
|
obj->thread = false;
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execbar, nullptr,
|
|
|
|
"execbar needs arguments: [height],[width] <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXEC | EF_BAR);
|
|
|
|
register_exec(obj);
|
|
|
|
obj->callbacks.barval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_exec;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execibar, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"execibar needs arguments: <interval> [height],[width] <command>")
|
|
|
|
scan_exec_arg(obj, arg, EF_EXECI | EF_BAR);
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.barval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2016-01-09 17:19:48 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execgauge, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"execgauge needs arguments: [height],[width] <command>")
|
|
|
|
scan_exec_arg(obj, arg, EF_EXEC | EF_GAUGE);
|
|
|
|
register_exec(obj);
|
|
|
|
obj->callbacks.gaugeval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_exec;
|
|
|
|
END OBJ_ARG(
|
2018-05-12 23:26:31 +00:00
|
|
|
execigauge, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"execigauge needs arguments: <interval> [height],[width] <command>")
|
|
|
|
scan_exec_arg(obj, arg, EF_EXECI | EF_GAUGE);
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.gaugeval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execgraph, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"execgraph needs arguments: <command> [height],[width] [color1] "
|
|
|
|
"[color2] [scale] [-t|-l]")
|
|
|
|
scan_exec_arg(obj, arg, EF_EXEC | EF_GRAPH);
|
|
|
|
register_exec(obj);
|
|
|
|
obj->callbacks.graphval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_exec;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(execigraph, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"execigraph needs arguments: <interval> <command> "
|
|
|
|
"[height],[width] [color1] [color2] [scale] [-t|-l]")
|
|
|
|
scan_exec_arg(obj, arg, EF_EXECI | EF_GRAPH);
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.graphval = &execbarval;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2010-11-13 22:59:31 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(texeci, nullptr, "texeci needs arguments: <interval> <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXECI);
|
|
|
|
obj->parse = false;
|
|
|
|
obj->thread = true;
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_execi;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(texecpi, nullptr, "texecpi needs arguments: <interval> <command>")
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_exec_arg(obj, arg, EF_EXECI);
|
|
|
|
obj->parse = true;
|
|
|
|
obj->thread = true;
|
|
|
|
register_execi(obj);
|
|
|
|
obj->callbacks.print = &print_exec;
|
|
|
|
obj->callbacks.free = &free_execi;
|
|
|
|
END OBJ(fs_bar, &update_fs_stats) init_fs_bar(obj, arg);
|
|
|
|
obj->callbacks.barval = &fs_barval;
|
|
|
|
END OBJ(fs_bar_free, &update_fs_stats) init_fs_bar(obj, arg);
|
|
|
|
obj->callbacks.barval = &fs_free_barval;
|
|
|
|
END OBJ(fs_free, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.print = &print_fs_free;
|
|
|
|
END OBJ(fs_used_perc, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.percentage = &fs_used_percentage;
|
|
|
|
END OBJ(fs_free_perc, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.percentage = &fs_free_percentage;
|
|
|
|
END OBJ(fs_size, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.print = &print_fs_size;
|
|
|
|
END OBJ(fs_type, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.print = &print_fs_type;
|
|
|
|
END OBJ(fs_used, &update_fs_stats) init_fs(obj, arg);
|
|
|
|
obj->callbacks.print = &print_fs_used;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(hr, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_hr;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(nameserver, &update_dns_data) parse_nameserver_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_nameserver;
|
|
|
|
obj->callbacks.free = &free_dns_data;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(offset, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_offset;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(voffset, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_voffset;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(goto, nullptr, "goto needs arguments") obj->data.l = atoi(arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_goto;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(tab, nullptr) scan_tab(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_tab;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2009-08-07 07:24:24 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(i2c, 0, "i2c needs arguments") parse_i2c_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_sysfs_sensor;
|
|
|
|
obj->callbacks.free = &free_sysfs_sensor;
|
|
|
|
END OBJ_ARG(platform, 0, "platform needs arguments")
|
|
|
|
parse_platform_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_sysfs_sensor;
|
|
|
|
obj->callbacks.free = &free_sysfs_sensor;
|
|
|
|
END OBJ_ARG(hwmon, 0, "hwmon needs argumanets") parse_hwmon_sensor(obj, arg);
|
|
|
|
obj->callbacks.print = &print_sysfs_sensor;
|
|
|
|
obj->callbacks.free = &free_sysfs_sensor;
|
2009-11-18 15:15:37 +00:00
|
|
|
#endif /* __linux__ */
|
2018-05-12 16:03:00 +00:00
|
|
|
END
|
|
|
|
/* we have four different types of top (top, top_mem, top_time and
|
|
|
|
* top_io). To avoid having almost-same code four times, we have this
|
|
|
|
* special handler. */
|
|
|
|
/* XXX: maybe fiddle them apart later, as print_top() does
|
|
|
|
* nothing else than just that, using an ugly switch(). */
|
|
|
|
if (strncmp(s, "top", 3) == EQUAL) {
|
2018-05-12 23:26:31 +00:00
|
|
|
if (parse_top_args(s, arg, obj) != 0) {
|
2010-11-23 17:50:40 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 16:03:00 +00:00
|
|
|
determine_longstat_file();
|
2010-11-23 17:50:40 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->cb_handle = create_cb_handle(update_top);
|
|
|
|
} else {
|
|
|
|
free(obj);
|
2018-05-12 23:26:31 +00:00
|
|
|
return nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else OBJ(addr, &update_net_stats) parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_addr;
|
|
|
|
END
|
2016-10-04 07:47:57 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 16:03:00 +00:00
|
|
|
OBJ(addrs, &update_net_stats) parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_addrs;
|
2011-02-09 17:49:52 +00:00
|
|
|
#ifdef BUILD_IPV6
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(v6addrs, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_v6addrs;
|
2011-02-09 17:49:52 +00:00
|
|
|
#endif /* BUILD_IPV6 */
|
2018-05-12 16:03:00 +00:00
|
|
|
END
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* __linux__ */
|
2018-05-12 23:26:31 +00:00
|
|
|
OBJ_ARG(tail, nullptr, "tail needs arguments")
|
2018-05-12 16:03:00 +00:00
|
|
|
init_tailhead("tail", arg, obj, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_tail;
|
|
|
|
obj->callbacks.free = &free_tailhead;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(head, nullptr, "head needs arguments")
|
2018-05-12 16:03:00 +00:00
|
|
|
init_tailhead("head", arg, obj, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_head;
|
|
|
|
obj->callbacks.free = &free_tailhead;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(lines, nullptr, "lines needs an argument") obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_lines;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(words, nullptr, "words needs a argument") obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_words;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(loadavg, &update_load_average) scan_loadavg_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_loadavg;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF_ARG(if_empty, nullptr, "if_empty needs an argument") obj->sub =
|
|
|
|
static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_variable_text_internal(obj->sub, arg);
|
|
|
|
obj->callbacks.iftest = &if_empty_iftest;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF_ARG(if_match, nullptr, "if_match needs arguments") obj->sub =
|
|
|
|
static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_variable_text_internal(obj->sub, arg);
|
|
|
|
obj->callbacks.iftest = &check_if_match;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF_ARG(if_existing, nullptr, "if_existing needs an argument or two")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &if_existing_iftest;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2012-06-28 16:56:01 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument") obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &check_mount;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
|
|
|
|
top_running = 1;
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &if_running_iftest;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
Basic macOS support (#480)
* Initial patches for Darwin support
* cmake files ready for building on Sierra. Dont know about other OSX versions
* Added darwin.h which will contain darwin specific headers
* Patches for enablin asprintf support (needs _POSIX_C_SOURCE >= __DARWIN_C_FULL so remove -D_POSIX_C_SOURCE=200809L). What is more, -D_LARGEFILE64_SOURCE is used by default so not needed on macOS
* Stubs for get_entropy_avail and get_entropy_poolsize
* More progress to getting to build
* More patches
* Now builds, remains fixing linking errors. Also implemented some functions
* Now links
* Now conky runs without sigabrt()'ing... An exception in semaphore.hh caused it to crash immediately upon initialisation
* README changes
* This was based on an old attempt I did with porting conky where I hadn't cloned the repo and thus it showed 3166 commits behind
* Patched a bit the semaphore.hh and now conky runs at 0.7% CPU usage and not in 100% or 200% as it did before! Yeah
* This update fixes swap-related miscalculations, though:
On macOS there can be used MANY swapfiles ( NOT swap partitions,,, the installation disk is the partition for storing swap memory data )
Thus conky code must be updated for Darwin to support multi-swapfile usage stats.
For now, we default to showing stats for swapfile0
* Fixed a bit the comments so they make sense
* Realised that the sysctl code can give us stats for the whole swap storage so removed the swapmode( int swapfd, unsigned long * retvail, unsigned long * retfree )
* I think the code is in good condition now
* semaphore.hh: Implemented ~semaphore() and added throwing exception
when sem initialisation fails just like in sem() for linux…
darwin.cc: partially implemented update_cpu_usage() and
update_total_processes()
* Implements update_total_processes()
( Now it finds the correct number of tasks )
the changes in cmake file don’t change the functionality… It is only
comments.
In upcoming updates lua support may be enabled and the comments are
related to lua support.
* get_cpu_count() now conforms to newer sysctl code as suggested by Apple ( we use hw.logicalcpumax instead of hw.ncpus ) --> The new implementation of get_cpu_count() finds the the max value of logical cores the mac could use on a boot.
update_total_processes() was patched to allow initialising only ONCE when conky runs the machHost and processorSet ( this could probably be implemented in a better way I guess though... )
* patch
* experimental support for get_top_info() and update_cpu_usage() :)
* going to patch stuff
* adds getting rss memory in get_top_info()
* fixes
* Couple things made more beautiful but too many things to fix ...
* Remove unneeded code from darwin_soundcard.h and keep only needed to
compile ( This way we are compatible to GPLv3, i think )
Include GPLv3 header in darwin.cc, darwin.h and darwin_soundcard.h
Add more beautiful and explanatory comments to ease the work of other
contributors… ( Mostly on things that don’t work! )
* Merged the macOS update_cpu_usage() implementation with the linux implementation but still it doesn't work as expected, plus, there are more memory related problems that will be fixed in newer release!
NOTE: It will be really good to see how functions are implemented on linux.cc for more complete implementation
* Now using a more linux-influenced implementation and dropping the old... ( only keeps mach stuff )
Needs some more work though to print accurate percentage! :)
* Add conky installer (.pkg) project
* Now gets thread count aswell! For now, we get this from update_total_processes... Also, removed the installer project because I need to learn more the software
* Properly get thread count!
- Patched core.cc to enable getting threads count on macOS!
- Cleanup in darwin.cc
* sort out some things in the code:
- running_threads_count is not the same as thread_count on macOS! There is actually a difference!
Correct a bit the code!
* Enable the if_mounted command and start implementing the check_mount function in darwin.cc
* Tighten things up
* This patch makes conky build easily and without patching on any supported macOS version! The new flag introduced is a temporary solution for allowing conky to compile on other OS without tweaking the cmake files. If you want to compile it with i18l support you will have to run the command: brew link gettext after you install gettext
* Update README to provide more complete info on building on macOS
* Fix
* patch check_mounted + SIP status
This commit:
- patches check_mounted function to match the implementation found in FreeBSD.cc! Now conky expects typing something like this:
conky -t '${if_mounted /Volumes/MacOS} ${endif}'
Please note that the correct way is "/Volumes/MacOS", not "/Volumes/MacOS/" ! You shouldnt put the backslash at the end... It will not work!
- Adds a new command called sip_status which you can use to make conky show System Integrity Protection related information such as if filesystem protection is enabled, if user approved kexts protection is enabled and more...
you can type conky -t '$sip_status' to see what it does...
( I will most likely update some things later regarding sip_status and check_mounted )
* Further implement sip_status
sip_status now has different functionality!
If you give no arguments it shows whether SIP is enabled or disabled ( generally )
If you give argument ( takes only ONE ) you can specify which specific thing of SIP you want to show status for...
You need to pass 0, 1, ..., 9 to $sip_status as argument to print status for apple-internal, untrusted-kexts, and more...
Below you can see the list:
ARG: RESULT:
nothing --> print enabled / disabled
0 --> allow_apple_internal
1 --> allow_untrusted_kexts
2 --> allow_task_for_pid
3 --> allow_unrestricted_fs
4 --> allow_kernel_debugger
5 --> allow_unrestricted_dtrace
6 --> allow_unrestricted_nvram
7 --> allow_device_configuration
8 --> allow_any_recovery_os
9 --> allow_user_approved_kexts
* sip_status progress & if_up enabled
This commit adds the 'a' argument for $sip_status which checks if the SIP configuration is ok or it is likely to break in the future.
Also, enabled the $if_up command, but there are some problems with it...
* sip_status patches
- Updated code based on newest version of csrstat utility (v.1.8)
The 1.8 version fixes a problem in finding status of ALLOW_DEVICE_CONFIGURATION flag.
- Fixed a bug where we mistakenly printed 'disabled' even when SIP was enabled.
* Disable ncurses checks in a way that will allow compiling for other OSes! ( it was a really quick patch before )
* More changes in cmake file to make code prettier and more exact
* More cmake files cuteness
* work for supporting versions prior Sierra
This patch brings more compatibility with versions prior to Sierra.
The project as is nearly links on a 10.9.5 OSX installation.
- on versions prior Sierra clock_gettime() is not implemented thus we need to provide our own implementation for conky to work. ( Currently we have minimal support, more studying needs to be done )
NOTE: In order to compile on versions as old as Mavericks you will need newer compilers because command line tools for 10.9.5 dont support some C++11 features... For this I donwloaded the commandline tools for Xcode 8.1 ( or 8 dont remember well ) and installed only the CommandLine Tools section with Pacifist!
( The OSX installer sees the OS as too old, so you need pacifist! )
* Oops
* $if_mounted ready
This patch removes the unneded print_mounted() function!
Also cleanup code.
* $if_up works
I think $if_up command works therefore remove the APPLE specific code in core.cc ( there wasnt anything different anyway ) and use the FreeBSD code.
Minor conky output changes in darwin.cc
* fix compatibility with Mavericks and before...
This update allows conky to be compiled on Mavericks and before by checking at compilation time what our build target is.
If it is Mavericks or lower, then cant use the csr_get_active_config func because it is not available.
On higher versions than Mavericks it works as before...
NOTE: For compiling on Mavericks or lower you will have to write 10.9 in CMAKE_OSX_DEPLOYMENT_TARGET when you run ccmake
* Added link for youtube video showing conky running on macOS
* Improvements
Minor improvements related to style
Removed unneeded free() calls
* Simplify Xcode configuration process! :)
* Removed update_cpu_usage() implementation
It was quite buggy so I removed it...
* Cleanup the source code
1. Bogus TODO comments have been deleted!
2. Started using DEBUG_MODE based printf
3. Explain some things better/cleanup
* Last small cleanup
The TODO in get_from_load_info() was unneeded. Removed!
Also, DEBUG_MODE is enabled for now...
* update authors file
* Improve README
Make it more clean and easier to understand.
* Update README.md
small tweak
* Work for conforming with "Development" rules
1. Add to variables.xml documentation about the $sip_status variable.
2. Add sip_status variable to conkyrc.vim and nanorc to allow highlighting
3. the friends in darwin.cc is ambiguous,,, some are more than friends.
* First patch set that implements get_top_info()
:)
* Calculate cpu usage of all processes more efficiently. (Now results match Activity Monitor's results a lot!!!)
More info about the get_top_info() implementation will come once I finish it! (soon)
* Cleanup patch!
o Move a couple things to better places
o Rename get_sample() to get_cpu_sample() to allow to be used by different functions such as get_cpu_usage() ( this is a scene from the future... )
o Improve the way we get cpu usage for each process by passing the already created proc_taskinfo struct to the appropriate function instead of creating another one
inside it!
* Correctly enable $running_processes variable
In our implementation update_top() doesn't calculate the count of running processes! We assign this functionality to the update_running_processes() function.
* Removed unneeded flag
This is not needed because we do not use update_top() for getting the number of running processes!
* Update README.md
* Update README.md
This adds support for TravisCL.
Though this will compile the project only on Linux it is a good sign to know if our port still can compile on Linux or we have broken things. It seems like it can't but I suspect the problem existed before my patches. I will investigate.
* First patch towards implementing #15
This patch a reworked get_top_info(). We now use the function get_top_info_for_kinfo_proc() to set the contents of each |process| struct.
Also, we calculate the total cpu usage and total process usage concurrently using GCD.
Aside from these we bring the function helper_get_proc_list() which makes the code simpler and cleaner.
* First fix for the algorithm that calculates % CPU usage of a process
The previous patch made the algorithm buggy. It required more reentrant-safe functions.
Make calc_cpu_total_r() which is a more reentrant-safe reimplementation of the calc_cpu_total() function.
This is not the last commit, more are coming in the future.
* Previous commit wasn't pushed...
* Problems committing
* Make the code cleaner but break the algorithm again #15
The algorithm doesn't work... It is a work in progress!
But this time we have merged the cpu_info and cpusample into one struct called cpusample
( I copied some variables from the linux implementation but they will probably be removed )
* Rework the code a bit / CPU usage % algorithm still doesn't work
Now get_from_load_info() is renamed to helper_update_threads_processes() and is called by both update_threads() and update_total_processes()
This makes the code nicer and removes the enum with the flags
* cleanup
remove unneeded functions, remove unneeded variables
* bugfix
* bugfix
* remove the whole get_top_info() code!
I will rework a lot this code so we can get rid of it.
* Work for #15
Now we use the ultimate solution for calculating % usage of CPU of a process!
Check the #15 Issue for information about this patch!
* Quick memory leak fix & some patches for the get_top_info algorithm
* quick patch for semaphore class
* Update the comments
* For consistency
* temp
* Revert "Merge branch 'master' into update_cpu_usage"
This reverts commit 7267a515c40d54b85107e51016703e6c10f3183e, reversing
changes made to 2190ff0b51463c12c61b3357cf846b8e705ebeb4.
* Revert "Revert "Merge branch 'master' into update_cpu_usage""
This reverts commit 692bd27a3adb2fe7027d65932467a140e42cc7bc.
* Partially implement the overall % CPU usage
* bug fix: I meant procs and threads!
* make the code better part1
* cleanup
* Stabilise the values of get_cpu_sample(). Affects get_top_info() and update_cpu_usage() ( fixes #13 and #15 )
For some reason the code that used host_statistics() function didn't produced bad values quite often. Replaced the function with host_processor_info() and changed the algorithm
and now the values are correct!
This affects the get_top_info() and update_cpu_usage() functions which wouldn't work correctly until now.
* Finish the optimised version of get_top_info()
Fixes #15
* Quick fix for #16
Probably I will come up with a different location for get_cpu_count() because I want to conform to linux implementation.
Also, the memory leak I am mentioning in get_cpu_count() may not actually exist, as I suspected in the back of my head.
* Strictness
* Cleanup ConkyPlatformChecks.cmake
Cleanup the quick patch code for Lua.
* Add warning to README
If you are using old version of cmake, update it. It will probably have problems when trying to locate lua.
* More cleanup
* Fix identation
This simplifies the diff.
Also, note that by merging the new code for checking for NCURSES we acheive better compatibility and easy build process
* Remove mixer related patches and files
With the newest patches from upstream, cmake checks if the header soundcard.h exists on the system.
If it doesn't exist (in the case of macOS for example) all mixer-related variables are disabled.
* Changes for using as submodule for ConkyX
* Fixes
* Implement get_freq
This implements #11
Though it doesn't support getting the **current** cpu frequency.
I haven't found a way to do it on macOS but i guess it can be done using a kernel extension. I may come back to this again in the future
* First work for correcting mem stats #6
Incorporate the update_pages_stolen() function and all of its dependencies.
I will see if I can patch the code in order to avoid license problems
* Work for #6
Now we follow the way apple's top works and not Activity Monitor.
For this reason we find different values. But correct based on top.
* cleanup for #6
* bug fix 1
* cleanup
* hmm sorry
* More cleanup
- Move the libtop_tsamp_t object to darwin.cc.
- Remove unneeded member variables.
* A bit documentation
* Implement secondary memory stats #6
Implement memwithbuffers, memeasyfree and memfree (which isn't secondary)
* Quit update_meminfo if libtop_tsamp_update_vm_stats() failed
* Update README.md
Revert to original conky readme
Move all macOS related information to the Wiki: https://github.com/Conky-for-macOS/conky-for-macOS/wiki
* Alot junk slipped in too!
* Merge net_stats branch
For now, I have only tested up / down bytes count on en0, and it works.
This is for #14
* Corrections
- Fix License headers in darwin* files
- Remove ConkyX entry from .gitignore which slipped into from the "forConkyX" branch which was used for another project ... ConkyX.
- Cleanup top.h (I will request the changes in a pull request finally)
* Fix identation and cleanup
* identation-fixes part1
* Try to fix problem compiling on linux
Improve checks for headers in ConkyPlatformChecks.cmake to amend the problem;
I mistakenly thought that statfs64 wasn't available in sys/statfs.h in macOS thus I tried to add platform specific code. Though, I add the checks in the wrong place and also messed up linux-specific code by replacing checks_include sys/statfs with check_symbol_exists statfs64
* attemp to completely fix linux problem!
2018-05-07 11:27:32 +00:00
|
|
|
#elif defined(__APPLE__) && defined(__MACH__)
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF_ARG(if_mounted, nullptr, "if_mounted needs an argument")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &check_mount;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
|
|
|
|
/* System Integrity Protection */
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(sip_status, &get_sip_status) obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_sip_status;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2009-08-07 07:24:24 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_IF_ARG(
|
|
|
|
if_running, 0,
|
|
|
|
"if_running needs an argument") char buf[text_buffer_size.get(*state)];
|
2009-08-07 07:21:56 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
snprintf(buf, text_buffer_size.get(*state), "pidof %s >/dev/null", arg);
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
/* XXX: maybe use a different callback here */
|
|
|
|
obj->callbacks.iftest = &if_running_iftest;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(kernel, nullptr) obj->callbacks.print = &print_kernel;
|
|
|
|
END OBJ(machine, nullptr) obj->callbacks.print = &print_machine;
|
2012-06-28 16:56:01 +00:00
|
|
|
#if defined(__DragonFly__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(version, 0) obj->callbacks.print = &print_version;
|
2012-06-28 16:56:01 +00:00
|
|
|
#endif
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(new_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_new_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(seen_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_seen_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(unseen_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_unseen_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(flagged_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_flagged_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(unflagged_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_unflagged_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(forwarded_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_forwarded_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(unforwarded_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_unforwarded_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(replied_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_replied_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(unreplied_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_unreplied_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(draft_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_draft_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(trashed_mails, nullptr) parse_local_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_trashed_mails;
|
|
|
|
obj->callbacks.free = &free_local_mails;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mboxscan, nullptr) parse_mboxscan_arg(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mboxscan;
|
|
|
|
obj->callbacks.free = &free_mboxscan;
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(mem, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_mem;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(memwithbuffers, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_memwithbuffers;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(memeasyfree, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_memeasyfree;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(memfree, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_memfree;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(memmax, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_memmax;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(memperc, &update_meminfo) obj->callbacks.percentage = &mem_percentage;
|
2011-01-04 13:48:33 +00:00
|
|
|
#ifdef __linux__
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(memdirty, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_memdirty;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
#endif /* __linux__ */
|
2010-11-13 22:59:31 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(memgauge, &update_meminfo) scan_gauge(obj, arg, 1);
|
|
|
|
obj->callbacks.gaugeval = &mem_barval;
|
2018-08-07 16:09:34 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(membar, &update_meminfo) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &mem_barval;
|
|
|
|
END OBJ(memwithbuffersbar, &update_meminfo) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &mem_with_buffers_barval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(memgraph, &update_meminfo) char *buf = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
buf = scan_graph(obj, arg, 1);
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
free_and_zero(buf);
|
|
|
|
obj->callbacks.graphval = &mem_barval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11*/
|
2018-01-19 16:36:40 +00:00
|
|
|
#ifdef HAVE_SOME_SOUNDCARD_H
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(mixer, 0) parse_mixer_arg(obj, arg);
|
|
|
|
obj->callbacks.percentage = &mixer_percentage;
|
|
|
|
END OBJ(mixerl, 0) parse_mixer_arg(obj, arg);
|
|
|
|
obj->callbacks.percentage = &mixerl_percentage;
|
|
|
|
END OBJ(mixerr, 0) parse_mixer_arg(obj, arg);
|
|
|
|
obj->callbacks.percentage = &mixerr_percentage;
|
|
|
|
END OBJ(mixerbar, 0) scan_mixer_bar(obj, arg);
|
|
|
|
obj->callbacks.barval = &mixer_barval;
|
|
|
|
END OBJ(mixerlbar, 0) scan_mixer_bar(obj, arg);
|
|
|
|
obj->callbacks.barval = &mixerl_barval;
|
|
|
|
END OBJ(mixerrbar, 0) scan_mixer_bar(obj, arg);
|
|
|
|
obj->callbacks.barval = &mixerr_barval;
|
|
|
|
END OBJ_IF(if_mixer_mute, 0) parse_mixer_arg(obj, arg);
|
|
|
|
obj->callbacks.iftest = &check_mixer_muted;
|
2018-08-07 16:09:34 +00:00
|
|
|
#endif /* HAVE_SOME_SOUNDCARD_H */
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(monitor, nullptr) obj->callbacks.print = &print_monitor;
|
|
|
|
END OBJ(monitor_number, nullptr) obj->callbacks.print = &print_monitor_number;
|
|
|
|
END OBJ(desktop, nullptr) obj->callbacks.print = &print_desktop;
|
|
|
|
END OBJ(desktop_number, nullptr) obj->callbacks.print = &print_desktop_number;
|
|
|
|
END OBJ(desktop_name, nullptr) obj->callbacks.print = &print_desktop_name;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(format_time, nullptr, "format_time needs a pid as argument")
|
|
|
|
obj->sub = static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_variable_text_internal(obj->sub, arg);
|
|
|
|
obj->callbacks.print = &print_format_time;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(nodename, nullptr) obj->callbacks.print = &print_nodename;
|
|
|
|
END OBJ(nodename_short, nullptr) obj->callbacks.print = &print_nodename_short;
|
|
|
|
END OBJ_ARG(cmdline_to_pid, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"cmdline_to_pid needs a command line as argument")
|
|
|
|
scan_cmdline_to_pid_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_cmdline_to_pid;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_chroot, nullptr, "pid_chroot needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_chroot;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_cmdline, nullptr, "pid_cmdline needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_cmdline;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_cwd, nullptr, "pid_cwd needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_cwd;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_environ, nullptr, "pid_environ needs arguments")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_environ;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_environ_list, nullptr,
|
|
|
|
"pid_environ_list needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_environ_list;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_exe, nullptr, "pid_exe needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_exe;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_nice, nullptr, "pid_nice needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_nice;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_openfiles, nullptr, "pid_openfiles needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_openfiles;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_parent, nullptr, "pid_parent needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_parent;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_priority, nullptr, "pid_priority needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_priority;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_state, nullptr, "pid_state needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_state;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_state_short, nullptr,
|
|
|
|
"pid_state_short needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_state_short;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_stderr, nullptr, "pid_stderr needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_stderr;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_stdin, nullptr, "pid_stdin needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_stdin;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_stdout, nullptr, "pid_stdout needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_stdout;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_threads, nullptr, "pid_threads needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_threads;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_thread_list, nullptr,
|
|
|
|
"pid_thread_list needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_thread_list;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_time_kernelmode, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"pid_time_kernelmode needs a pid as argument")
|
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_time_kernelmode;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_time_usermode, nullptr,
|
|
|
|
"pid_time_usermode needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_time_usermode;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_time, nullptr, "pid_time needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_time;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_uid, nullptr, "pid_uid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_uid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_euid, nullptr, "pid_euid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_euid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_suid, nullptr, "pid_suid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_suid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_fsuid, nullptr, "pid_fsuid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_fsuid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_gid, nullptr, "pid_gid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_gid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_egid, nullptr, "pid_egid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_egid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_sgid, nullptr, "pid_sgid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_sgid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_fsgid, nullptr, "pid_fsgid needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_fsgid;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(gid_name, nullptr, "gid_name needs a gid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_gid_name;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(uid_name, nullptr, "uid_name needs a uid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_uid_name;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_read, nullptr, "pid_read needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_read;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmpeak, nullptr, "pid_vmpeak needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmpeak;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmsize, nullptr, "pid_vmsize needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmsize;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmlck, nullptr, "pid_vmlck needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmlck;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmhwm, nullptr, "pid_vmhwm needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmhwm;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmrss, nullptr, "pid_vmrss needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmrss;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmdata, nullptr, "pid_vmdata needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmdata;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmstk, nullptr, "pid_vmstk needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmstk;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmexe, nullptr, "pid_vmexe needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmexe;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmlib, nullptr, "pid_vmlib needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmlib;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_vmpte, nullptr, "pid_vmpte needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_vmpte;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(pid_write, nullptr, "pid_write needs a pid as argument")
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_object_args_to_sub(obj, arg);
|
|
|
|
obj->callbacks.print = &print_pid_write;
|
2012-06-28 16:56:01 +00:00
|
|
|
#ifdef __DragonFly__
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(processes, &update_top)
|
2012-06-28 16:56:01 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(processes, &update_total_processes)
|
2012-06-28 16:56:01 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_processes;
|
2009-11-14 03:19:51 +00:00
|
|
|
#ifdef __linux__
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(distribution, 0) obj->callbacks.print = &print_distribution;
|
|
|
|
END OBJ(running_processes, &update_top) top_running = 1;
|
|
|
|
obj->callbacks.print = &print_running_processes;
|
|
|
|
END OBJ(threads, &update_threads) obj->callbacks.print = &print_threads;
|
|
|
|
END OBJ(running_threads, &update_stat) obj->callbacks.print =
|
|
|
|
&print_running_threads;
|
2012-06-28 16:56:01 +00:00
|
|
|
#else
|
|
|
|
#if defined(__DragonFly__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(running_processes, &update_top) obj->callbacks.print =
|
|
|
|
&print_running_processes;
|
Basic macOS support (#480)
* Initial patches for Darwin support
* cmake files ready for building on Sierra. Dont know about other OSX versions
* Added darwin.h which will contain darwin specific headers
* Patches for enablin asprintf support (needs _POSIX_C_SOURCE >= __DARWIN_C_FULL so remove -D_POSIX_C_SOURCE=200809L). What is more, -D_LARGEFILE64_SOURCE is used by default so not needed on macOS
* Stubs for get_entropy_avail and get_entropy_poolsize
* More progress to getting to build
* More patches
* Now builds, remains fixing linking errors. Also implemented some functions
* Now links
* Now conky runs without sigabrt()'ing... An exception in semaphore.hh caused it to crash immediately upon initialisation
* README changes
* This was based on an old attempt I did with porting conky where I hadn't cloned the repo and thus it showed 3166 commits behind
* Patched a bit the semaphore.hh and now conky runs at 0.7% CPU usage and not in 100% or 200% as it did before! Yeah
* This update fixes swap-related miscalculations, though:
On macOS there can be used MANY swapfiles ( NOT swap partitions,,, the installation disk is the partition for storing swap memory data )
Thus conky code must be updated for Darwin to support multi-swapfile usage stats.
For now, we default to showing stats for swapfile0
* Fixed a bit the comments so they make sense
* Realised that the sysctl code can give us stats for the whole swap storage so removed the swapmode( int swapfd, unsigned long * retvail, unsigned long * retfree )
* I think the code is in good condition now
* semaphore.hh: Implemented ~semaphore() and added throwing exception
when sem initialisation fails just like in sem() for linux…
darwin.cc: partially implemented update_cpu_usage() and
update_total_processes()
* Implements update_total_processes()
( Now it finds the correct number of tasks )
the changes in cmake file don’t change the functionality… It is only
comments.
In upcoming updates lua support may be enabled and the comments are
related to lua support.
* get_cpu_count() now conforms to newer sysctl code as suggested by Apple ( we use hw.logicalcpumax instead of hw.ncpus ) --> The new implementation of get_cpu_count() finds the the max value of logical cores the mac could use on a boot.
update_total_processes() was patched to allow initialising only ONCE when conky runs the machHost and processorSet ( this could probably be implemented in a better way I guess though... )
* patch
* experimental support for get_top_info() and update_cpu_usage() :)
* going to patch stuff
* adds getting rss memory in get_top_info()
* fixes
* Couple things made more beautiful but too many things to fix ...
* Remove unneeded code from darwin_soundcard.h and keep only needed to
compile ( This way we are compatible to GPLv3, i think )
Include GPLv3 header in darwin.cc, darwin.h and darwin_soundcard.h
Add more beautiful and explanatory comments to ease the work of other
contributors… ( Mostly on things that don’t work! )
* Merged the macOS update_cpu_usage() implementation with the linux implementation but still it doesn't work as expected, plus, there are more memory related problems that will be fixed in newer release!
NOTE: It will be really good to see how functions are implemented on linux.cc for more complete implementation
* Now using a more linux-influenced implementation and dropping the old... ( only keeps mach stuff )
Needs some more work though to print accurate percentage! :)
* Add conky installer (.pkg) project
* Now gets thread count aswell! For now, we get this from update_total_processes... Also, removed the installer project because I need to learn more the software
* Properly get thread count!
- Patched core.cc to enable getting threads count on macOS!
- Cleanup in darwin.cc
* sort out some things in the code:
- running_threads_count is not the same as thread_count on macOS! There is actually a difference!
Correct a bit the code!
* Enable the if_mounted command and start implementing the check_mount function in darwin.cc
* Tighten things up
* This patch makes conky build easily and without patching on any supported macOS version! The new flag introduced is a temporary solution for allowing conky to compile on other OS without tweaking the cmake files. If you want to compile it with i18l support you will have to run the command: brew link gettext after you install gettext
* Update README to provide more complete info on building on macOS
* Fix
* patch check_mounted + SIP status
This commit:
- patches check_mounted function to match the implementation found in FreeBSD.cc! Now conky expects typing something like this:
conky -t '${if_mounted /Volumes/MacOS} ${endif}'
Please note that the correct way is "/Volumes/MacOS", not "/Volumes/MacOS/" ! You shouldnt put the backslash at the end... It will not work!
- Adds a new command called sip_status which you can use to make conky show System Integrity Protection related information such as if filesystem protection is enabled, if user approved kexts protection is enabled and more...
you can type conky -t '$sip_status' to see what it does...
( I will most likely update some things later regarding sip_status and check_mounted )
* Further implement sip_status
sip_status now has different functionality!
If you give no arguments it shows whether SIP is enabled or disabled ( generally )
If you give argument ( takes only ONE ) you can specify which specific thing of SIP you want to show status for...
You need to pass 0, 1, ..., 9 to $sip_status as argument to print status for apple-internal, untrusted-kexts, and more...
Below you can see the list:
ARG: RESULT:
nothing --> print enabled / disabled
0 --> allow_apple_internal
1 --> allow_untrusted_kexts
2 --> allow_task_for_pid
3 --> allow_unrestricted_fs
4 --> allow_kernel_debugger
5 --> allow_unrestricted_dtrace
6 --> allow_unrestricted_nvram
7 --> allow_device_configuration
8 --> allow_any_recovery_os
9 --> allow_user_approved_kexts
* sip_status progress & if_up enabled
This commit adds the 'a' argument for $sip_status which checks if the SIP configuration is ok or it is likely to break in the future.
Also, enabled the $if_up command, but there are some problems with it...
* sip_status patches
- Updated code based on newest version of csrstat utility (v.1.8)
The 1.8 version fixes a problem in finding status of ALLOW_DEVICE_CONFIGURATION flag.
- Fixed a bug where we mistakenly printed 'disabled' even when SIP was enabled.
* Disable ncurses checks in a way that will allow compiling for other OSes! ( it was a really quick patch before )
* More changes in cmake file to make code prettier and more exact
* More cmake files cuteness
* work for supporting versions prior Sierra
This patch brings more compatibility with versions prior to Sierra.
The project as is nearly links on a 10.9.5 OSX installation.
- on versions prior Sierra clock_gettime() is not implemented thus we need to provide our own implementation for conky to work. ( Currently we have minimal support, more studying needs to be done )
NOTE: In order to compile on versions as old as Mavericks you will need newer compilers because command line tools for 10.9.5 dont support some C++11 features... For this I donwloaded the commandline tools for Xcode 8.1 ( or 8 dont remember well ) and installed only the CommandLine Tools section with Pacifist!
( The OSX installer sees the OS as too old, so you need pacifist! )
* Oops
* $if_mounted ready
This patch removes the unneded print_mounted() function!
Also cleanup code.
* $if_up works
I think $if_up command works therefore remove the APPLE specific code in core.cc ( there wasnt anything different anyway ) and use the FreeBSD code.
Minor conky output changes in darwin.cc
* fix compatibility with Mavericks and before...
This update allows conky to be compiled on Mavericks and before by checking at compilation time what our build target is.
If it is Mavericks or lower, then cant use the csr_get_active_config func because it is not available.
On higher versions than Mavericks it works as before...
NOTE: For compiling on Mavericks or lower you will have to write 10.9 in CMAKE_OSX_DEPLOYMENT_TARGET when you run ccmake
* Added link for youtube video showing conky running on macOS
* Improvements
Minor improvements related to style
Removed unneeded free() calls
* Simplify Xcode configuration process! :)
* Removed update_cpu_usage() implementation
It was quite buggy so I removed it...
* Cleanup the source code
1. Bogus TODO comments have been deleted!
2. Started using DEBUG_MODE based printf
3. Explain some things better/cleanup
* Last small cleanup
The TODO in get_from_load_info() was unneeded. Removed!
Also, DEBUG_MODE is enabled for now...
* update authors file
* Improve README
Make it more clean and easier to understand.
* Update README.md
small tweak
* Work for conforming with "Development" rules
1. Add to variables.xml documentation about the $sip_status variable.
2. Add sip_status variable to conkyrc.vim and nanorc to allow highlighting
3. the friends in darwin.cc is ambiguous,,, some are more than friends.
* First patch set that implements get_top_info()
:)
* Calculate cpu usage of all processes more efficiently. (Now results match Activity Monitor's results a lot!!!)
More info about the get_top_info() implementation will come once I finish it! (soon)
* Cleanup patch!
o Move a couple things to better places
o Rename get_sample() to get_cpu_sample() to allow to be used by different functions such as get_cpu_usage() ( this is a scene from the future... )
o Improve the way we get cpu usage for each process by passing the already created proc_taskinfo struct to the appropriate function instead of creating another one
inside it!
* Correctly enable $running_processes variable
In our implementation update_top() doesn't calculate the count of running processes! We assign this functionality to the update_running_processes() function.
* Removed unneeded flag
This is not needed because we do not use update_top() for getting the number of running processes!
* Update README.md
* Update README.md
This adds support for TravisCL.
Though this will compile the project only on Linux it is a good sign to know if our port still can compile on Linux or we have broken things. It seems like it can't but I suspect the problem existed before my patches. I will investigate.
* First patch towards implementing #15
This patch a reworked get_top_info(). We now use the function get_top_info_for_kinfo_proc() to set the contents of each |process| struct.
Also, we calculate the total cpu usage and total process usage concurrently using GCD.
Aside from these we bring the function helper_get_proc_list() which makes the code simpler and cleaner.
* First fix for the algorithm that calculates % CPU usage of a process
The previous patch made the algorithm buggy. It required more reentrant-safe functions.
Make calc_cpu_total_r() which is a more reentrant-safe reimplementation of the calc_cpu_total() function.
This is not the last commit, more are coming in the future.
* Previous commit wasn't pushed...
* Problems committing
* Make the code cleaner but break the algorithm again #15
The algorithm doesn't work... It is a work in progress!
But this time we have merged the cpu_info and cpusample into one struct called cpusample
( I copied some variables from the linux implementation but they will probably be removed )
* Rework the code a bit / CPU usage % algorithm still doesn't work
Now get_from_load_info() is renamed to helper_update_threads_processes() and is called by both update_threads() and update_total_processes()
This makes the code nicer and removes the enum with the flags
* cleanup
remove unneeded functions, remove unneeded variables
* bugfix
* bugfix
* remove the whole get_top_info() code!
I will rework a lot this code so we can get rid of it.
* Work for #15
Now we use the ultimate solution for calculating % usage of CPU of a process!
Check the #15 Issue for information about this patch!
* Quick memory leak fix & some patches for the get_top_info algorithm
* quick patch for semaphore class
* Update the comments
* For consistency
* temp
* Revert "Merge branch 'master' into update_cpu_usage"
This reverts commit 7267a515c40d54b85107e51016703e6c10f3183e, reversing
changes made to 2190ff0b51463c12c61b3357cf846b8e705ebeb4.
* Revert "Revert "Merge branch 'master' into update_cpu_usage""
This reverts commit 692bd27a3adb2fe7027d65932467a140e42cc7bc.
* Partially implement the overall % CPU usage
* bug fix: I meant procs and threads!
* make the code better part1
* cleanup
* Stabilise the values of get_cpu_sample(). Affects get_top_info() and update_cpu_usage() ( fixes #13 and #15 )
For some reason the code that used host_statistics() function didn't produced bad values quite often. Replaced the function with host_processor_info() and changed the algorithm
and now the values are correct!
This affects the get_top_info() and update_cpu_usage() functions which wouldn't work correctly until now.
* Finish the optimised version of get_top_info()
Fixes #15
* Quick fix for #16
Probably I will come up with a different location for get_cpu_count() because I want to conform to linux implementation.
Also, the memory leak I am mentioning in get_cpu_count() may not actually exist, as I suspected in the back of my head.
* Strictness
* Cleanup ConkyPlatformChecks.cmake
Cleanup the quick patch code for Lua.
* Add warning to README
If you are using old version of cmake, update it. It will probably have problems when trying to locate lua.
* More cleanup
* Fix identation
This simplifies the diff.
Also, note that by merging the new code for checking for NCURSES we acheive better compatibility and easy build process
* Remove mixer related patches and files
With the newest patches from upstream, cmake checks if the header soundcard.h exists on the system.
If it doesn't exist (in the case of macOS for example) all mixer-related variables are disabled.
* Changes for using as submodule for ConkyX
* Fixes
* Implement get_freq
This implements #11
Though it doesn't support getting the **current** cpu frequency.
I haven't found a way to do it on macOS but i guess it can be done using a kernel extension. I may come back to this again in the future
* First work for correcting mem stats #6
Incorporate the update_pages_stolen() function and all of its dependencies.
I will see if I can patch the code in order to avoid license problems
* Work for #6
Now we follow the way apple's top works and not Activity Monitor.
For this reason we find different values. But correct based on top.
* cleanup for #6
* bug fix 1
* cleanup
* hmm sorry
* More cleanup
- Move the libtop_tsamp_t object to darwin.cc.
- Remove unneeded member variables.
* A bit documentation
* Implement secondary memory stats #6
Implement memwithbuffers, memeasyfree and memfree (which isn't secondary)
* Quit update_meminfo if libtop_tsamp_update_vm_stats() failed
* Update README.md
Revert to original conky readme
Move all macOS related information to the Wiki: https://github.com/Conky-for-macOS/conky-for-macOS/wiki
* Alot junk slipped in too!
* Merge net_stats branch
For now, I have only tested up / down bytes count on en0, and it works.
This is for #14
* Corrections
- Fix License headers in darwin* files
- Remove ConkyX entry from .gitignore which slipped into from the "forConkyX" branch which was used for another project ... ConkyX.
- Cleanup top.h (I will request the changes in a pull request finally)
* Fix identation and cleanup
* identation-fixes part1
* Try to fix problem compiling on linux
Improve checks for headers in ConkyPlatformChecks.cmake to amend the problem;
I mistakenly thought that statfs64 wasn't available in sys/statfs.h in macOS thus I tried to add platform specific code. Though, I add the checks in the wrong place and also messed up linux-specific code by replacing checks_include sys/statfs with check_symbol_exists statfs64
* attemp to completely fix linux problem!
2018-05-07 11:27:32 +00:00
|
|
|
#elif (defined(__APPLE__) && defined(__MACH__))
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(running_processes, &update_running_processes) obj->callbacks.print =
|
|
|
|
&print_running_processes;
|
|
|
|
END OBJ(threads, &update_threads) obj->callbacks.print = &print_threads;
|
|
|
|
END OBJ(running_threads, &update_running_threads) obj->callbacks.print =
|
|
|
|
&print_running_threads;
|
2009-11-15 16:42:59 +00:00
|
|
|
#else
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(running_processes, &update_running_processes) obj->callbacks.print =
|
|
|
|
&print_running_processes;
|
2012-06-28 16:56:01 +00:00
|
|
|
#endif
|
2009-11-15 16:42:59 +00:00
|
|
|
#endif /* __linux__ */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(shadecolor, nullptr)
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
obj->data.l =
|
|
|
|
arg != nullptr ? get_x11_color(arg) : default_shade_color.get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_bg;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(outlinecolor, nullptr)
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.l =
|
2018-05-12 23:26:31 +00:00
|
|
|
arg != nullptr ? get_x11_color(arg) : default_outline_color.get(*state);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_outline;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(stippled_hr, nullptr)
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
scan_stippled_hr(obj, arg);
|
|
|
|
obj->callbacks.print = &new_stippled_hr;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-08-07 16:09:34 +00:00
|
|
|
END OBJ(swap, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_swap;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(swapfree, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_swapfree;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ(swapmax, &update_meminfo) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_swapmax;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(swapperc, &update_meminfo) obj->callbacks.percentage =
|
|
|
|
&swap_percentage;
|
|
|
|
END OBJ(swapbar, &update_meminfo) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &swap_barval;
|
|
|
|
/* XXX: swapgraph, swapgauge? */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(sysname, nullptr) obj->callbacks.print = &print_sysname;
|
|
|
|
END OBJ(time, nullptr) scan_time(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_time;
|
|
|
|
obj->callbacks.free = &free_time;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(utime, nullptr) scan_time(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_utime;
|
|
|
|
obj->callbacks.free = &free_time;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(tztime, nullptr) scan_tztime(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_tztime;
|
|
|
|
obj->callbacks.free = &free_tztime;
|
2010-04-27 14:42:21 +00:00
|
|
|
#ifdef BUILD_ICAL
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(ical, 0, "ical requires arguments")
|
|
|
|
parse_ical_args(obj, arg, free_at_crash, s);
|
|
|
|
obj->callbacks.print = &print_ical;
|
|
|
|
obj->callbacks.free = &free_ical;
|
2010-04-27 14:42:21 +00:00
|
|
|
#endif
|
2010-04-30 17:32:42 +00:00
|
|
|
#ifdef BUILD_IRC
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(irc, 0, "irc requires arguments") parse_irc_args(obj, arg);
|
|
|
|
obj->callbacks.print = &print_irc;
|
|
|
|
obj->callbacks.free = &free_irc;
|
2010-04-30 17:32:42 +00:00
|
|
|
#endif
|
2010-01-20 17:17:30 +00:00
|
|
|
#ifdef BUILD_ICONV
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(iconv_start, 0, "Iconv requires arguments")
|
|
|
|
init_iconv_start(obj, free_at_crash, arg);
|
|
|
|
obj->callbacks.print = &print_iconv_start;
|
|
|
|
obj->callbacks.free = &free_iconv;
|
|
|
|
END OBJ(iconv_stop, 0) init_iconv_stop();
|
|
|
|
obj->callbacks.print = &print_iconv_stop;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(totaldown, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_totaldown;
|
|
|
|
END OBJ(totalup, &update_net_stats)
|
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_totalup;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(updates, nullptr) obj->callbacks.print = &print_updates;
|
|
|
|
END OBJ_IF(if_updatenr, nullptr) obj->data.i = arg != nullptr ? atoi(arg) : 0;
|
2018-05-12 16:03:00 +00:00
|
|
|
if (obj->data.i == 0)
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"if_updatenr needs a number above 0 as argument");
|
|
|
|
set_updatereset(obj->data.i > get_updatereset() ? obj->data.i
|
|
|
|
: get_updatereset());
|
|
|
|
obj->callbacks.iftest = &updatenr_iftest;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(alignr, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 1;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_alignr;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(alignc, nullptr) obj->data.l = arg != nullptr ? atoi(arg) : 0;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &new_alignc;
|
|
|
|
END OBJ(upspeed, &update_net_stats)
|
2018-08-06 22:09:20 +00:00
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_upspeed;
|
|
|
|
END OBJ(upspeedf, &update_net_stats)
|
2018-08-06 22:09:20 +00:00
|
|
|
parse_net_stat_arg(obj, arg, free_at_crash);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_upspeedf;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(upspeedgraph, &update_net_stats)
|
|
|
|
parse_net_stat_graph_arg(obj, arg, free_at_crash);
|
|
|
|
obj->callbacks.graphval = &upspeedgraphval;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(uptime_short, &update_uptime) obj->callbacks.print =
|
|
|
|
&print_uptime_short;
|
|
|
|
END OBJ(uptime, &update_uptime) obj->callbacks.print = &print_uptime;
|
2009-11-14 03:19:51 +00:00
|
|
|
#if defined(__linux__)
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(user_names, &update_users) obj->callbacks.print = &print_user_names;
|
|
|
|
obj->callbacks.free = &free_user_names;
|
|
|
|
END OBJ(user_times, &update_users) obj->callbacks.print = &print_user_times;
|
|
|
|
obj->callbacks.free = &free_user_times;
|
|
|
|
END OBJ_ARG(user_time, 0, "user time needs a console name as argument")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_user_time;
|
|
|
|
obj->callbacks.free = &free_user_time;
|
|
|
|
END OBJ(user_terms, &update_users) obj->callbacks.print = &print_user_terms;
|
|
|
|
obj->callbacks.free = &free_user_terms;
|
|
|
|
END OBJ(user_number, &update_users) obj->callbacks.print = &print_user_number;
|
|
|
|
END OBJ(gw_iface, &update_gateway_info) obj->callbacks.print =
|
|
|
|
&print_gateway_iface;
|
|
|
|
obj->callbacks.free = &free_gateway_info;
|
2018-08-13 12:09:24 +00:00
|
|
|
END OBJ_IF(if_gw, &update_gateway_info) obj->callbacks.iftest =
|
|
|
|
&gateway_exists;
|
|
|
|
obj->callbacks.free = &free_gateway_info;
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(gw_ip, &update_gateway_info) obj->callbacks.print = &print_gateway_ip;
|
|
|
|
obj->callbacks.free = &free_gateway_info;
|
2018-08-13 12:09:24 +00:00
|
|
|
END OBJ(iface, &update_gateway_info2) obj->data.s = STRNDUP_ARG;
|
|
|
|
obj->callbacks.print = &print_gateway_iface2;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
#endif /* __linux__ */
|
2018-05-12 16:03:00 +00:00
|
|
|
#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
|
|
|
|
defined(__DragonFly__) || defined(__OpenBSD__)) && \
|
|
|
|
(defined(i386) || defined(__i386__))
|
|
|
|
END OBJ(apm_adapter, 0) obj->callbacks.print = &print_apm_adapter;
|
|
|
|
END OBJ(apm_battery_life, 0) obj->callbacks.print = &print_apm_battery_life;
|
|
|
|
END OBJ(apm_battery_time, 0) obj->callbacks.print = &print_apm_battery_time;
|
2009-08-07 07:24:24 +00:00
|
|
|
#endif /* __FreeBSD__ */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(imap_unseen, nullptr) parse_imap_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_imap_unseen;
|
|
|
|
obj->callbacks.free = &free_mail_obj;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(imap_messages, nullptr) parse_imap_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_imap_messages;
|
|
|
|
obj->callbacks.free = &free_mail_obj;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(pop3_unseen, nullptr) parse_pop3_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_pop3_unseen;
|
|
|
|
obj->callbacks.free = &free_mail_obj;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(pop3_used, nullptr) parse_pop3_mail_args(obj, arg);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_pop3_used;
|
|
|
|
obj->callbacks.free = &free_mail_obj;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_IBM
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(smapi, 0, "smapi needs an argument") obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_smapi;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_IF_ARG(if_smapi_bat_installed, 0,
|
|
|
|
"if_smapi_bat_installed needs an argument") obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.iftest = &smapi_bat_installed;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.percentage = &smapi_bat_percentage;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_ARG(smapi_bat_temp, 0, "smapi_bat_temp needs an argument")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_smapi_bat_temp;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_ARG(smapi_bat_power, 0, "smapi_bat_power needs an argument")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_smapi_bat_power;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_ARG(smapi_bat_bar, 0, "smapi_bat_bar needs an argument") int cnt;
|
|
|
|
if (sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) {
|
|
|
|
NORM_ERR("first argument to smapi_bat_bar must be an integer value");
|
|
|
|
obj->data.i = -1;
|
|
|
|
} else
|
|
|
|
arg = scan_bar(obj, arg + cnt, 100);
|
|
|
|
obj->callbacks.barval = &smapi_bat_barval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_IBM */
|
|
|
|
#ifdef BUILD_MPD
|
2018-05-12 16:03:00 +00:00
|
|
|
#define mpd_set_maxlen(name) \
|
|
|
|
if (arg) { \
|
|
|
|
int i; \
|
|
|
|
sscanf(arg, "%d", &i); \
|
|
|
|
if (i > 0) \
|
|
|
|
obj->data.i = i + 1; \
|
|
|
|
else \
|
|
|
|
NORM_ERR(#name ": invalid length argument"); \
|
|
|
|
}
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_artist, nullptr) mpd_set_maxlen(mpd_artist);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_artist;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_albumartist, nullptr) mpd_set_maxlen(mpd_albumartist);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_albumartist;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_title, nullptr) mpd_set_maxlen(mpd_title);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_title;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_date, nullptr) mpd_set_maxlen(mpd_date);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_date;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_random, nullptr) obj->callbacks.print = &print_mpd_random;
|
|
|
|
END OBJ(mpd_repeat, nullptr) obj->callbacks.print = &print_mpd_repeat;
|
|
|
|
END OBJ(mpd_elapsed, nullptr) obj->callbacks.print = &print_mpd_elapsed;
|
|
|
|
END OBJ(mpd_length, nullptr) obj->callbacks.print = &print_mpd_length;
|
|
|
|
END OBJ(mpd_track, nullptr) mpd_set_maxlen(mpd_track);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_track;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_name, nullptr) mpd_set_maxlen(mpd_name);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_name;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_file, nullptr) mpd_set_maxlen(mpd_file);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_file;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_percent, nullptr) obj->callbacks.percentage = &mpd_percentage;
|
|
|
|
END OBJ(mpd_album, nullptr) mpd_set_maxlen(mpd_album);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_album;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_vol, nullptr) obj->callbacks.print = &print_mpd_vol;
|
|
|
|
END OBJ(mpd_bitrate, nullptr) obj->callbacks.print = &print_mpd_bitrate;
|
|
|
|
END OBJ(mpd_status, nullptr) obj->callbacks.print = &print_mpd_status;
|
|
|
|
END OBJ(mpd_bar, nullptr) scan_bar(obj, arg, 1);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.barval = &mpd_barval;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(mpd_smart, nullptr) mpd_set_maxlen(mpd_smart);
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_mpd_smart;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_IF(if_mpd_playing, nullptr) obj->callbacks.iftest =
|
|
|
|
&check_mpd_playing;
|
2009-08-07 07:24:24 +00:00
|
|
|
#undef mpd_set_maxlen
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_MPD */
|
|
|
|
#ifdef BUILD_MOC
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(moc_state, nullptr) obj->callbacks.print = &print_moc_state;
|
|
|
|
END OBJ(moc_file, nullptr) obj->callbacks.print = &print_moc_file;
|
|
|
|
END OBJ(moc_title, nullptr) obj->callbacks.print = &print_moc_title;
|
|
|
|
END OBJ(moc_artist, nullptr) obj->callbacks.print = &print_moc_artist;
|
|
|
|
END OBJ(moc_song, nullptr) obj->callbacks.print = &print_moc_song;
|
|
|
|
END OBJ(moc_album, nullptr) obj->callbacks.print = &print_moc_album;
|
|
|
|
END OBJ(moc_totaltime, nullptr) obj->callbacks.print = &print_moc_totaltime;
|
|
|
|
END OBJ(moc_timeleft, nullptr) obj->callbacks.print = &print_moc_timeleft;
|
|
|
|
END OBJ(moc_curtime, nullptr) obj->callbacks.print = &print_moc_curtime;
|
|
|
|
END OBJ(moc_bitrate, nullptr) obj->callbacks.print = &print_moc_bitrate;
|
|
|
|
END OBJ(moc_rate, nullptr) obj->callbacks.print = &print_moc_rate;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_MOC */
|
2011-05-10 20:40:53 +00:00
|
|
|
#ifdef BUILD_CMUS
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(cmus_state, 0) obj->callbacks.print = &print_cmus_state;
|
|
|
|
END OBJ(cmus_file, 0) obj->callbacks.print = &print_cmus_file;
|
|
|
|
END OBJ(cmus_title, 0) obj->callbacks.print = &print_cmus_title;
|
|
|
|
END OBJ(cmus_artist, 0) obj->callbacks.print = &print_cmus_artist;
|
|
|
|
END OBJ(cmus_album, 0) obj->callbacks.print = &print_cmus_album;
|
|
|
|
END OBJ(cmus_totaltime, 0) obj->callbacks.print = &print_cmus_totaltime;
|
|
|
|
END OBJ(cmus_timeleft, 0) obj->callbacks.print = &print_cmus_timeleft;
|
|
|
|
END OBJ(cmus_curtime, 0) obj->callbacks.print = &print_cmus_curtime;
|
|
|
|
END OBJ(cmus_random, 0) obj->callbacks.print = &print_cmus_random;
|
|
|
|
END OBJ(cmus_state, 0) obj->callbacks.print = &print_cmus_state;
|
|
|
|
END OBJ(cmus_file, 0) obj->callbacks.print = &print_cmus_file;
|
|
|
|
END OBJ(cmus_title, 0) obj->callbacks.print = &print_cmus_title;
|
|
|
|
END OBJ(cmus_artist, 0) obj->callbacks.print = &print_cmus_artist;
|
|
|
|
END OBJ(cmus_album, 0) obj->callbacks.print = &print_cmus_album;
|
|
|
|
END OBJ(cmus_totaltime, 0) obj->callbacks.print = &print_cmus_totaltime;
|
|
|
|
END OBJ(cmus_timeleft, 0) obj->callbacks.print = &print_cmus_timeleft;
|
|
|
|
END OBJ(cmus_curtime, 0) obj->callbacks.print = &print_cmus_curtime;
|
|
|
|
END OBJ(cmus_random, 0) obj->callbacks.print = &print_cmus_random;
|
|
|
|
END OBJ(cmus_repeat, 0) obj->callbacks.print = &print_cmus_repeat;
|
|
|
|
END OBJ(cmus_aaa, 0) obj->callbacks.print = &print_cmus_aaa;
|
|
|
|
END OBJ(cmus_track, 0) obj->callbacks.print = &print_cmus_track;
|
|
|
|
END OBJ(cmus_genre, 0) obj->callbacks.print = &print_cmus_genre;
|
|
|
|
END OBJ(cmus_date, 0) obj->callbacks.print = &print_cmus_date;
|
|
|
|
END OBJ(cmus_progress, 0) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &cmus_progress;
|
|
|
|
END OBJ(cmus_percent, 0) obj->callbacks.percentage = &cmus_percent;
|
2011-05-10 20:40:53 +00:00
|
|
|
#endif /* BUILD_CMUS */
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_XMMS2
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(xmms2_artist, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_artist;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_album, &update_xmms2) obj->callbacks.print = &print_xmms2_album;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_title, &update_xmms2) obj->callbacks.print = &print_xmms2_title;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_genre, &update_xmms2) obj->callbacks.print = &print_xmms2_genre;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_comment, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_comment;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_url, &update_xmms2) obj->callbacks.print = &print_xmms2_url;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_tracknr, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_tracknr;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_bitrate, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_bitrate;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_date, &update_xmms2) obj->callbacks.print = &print_xmms2_date;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_id, &update_xmms2) obj->callbacks.print = &print_xmms2_id;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_duration, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_duration;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_elapsed, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_elapsed;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_size, &update_xmms2) obj->callbacks.print = &print_xmms2_size;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_status, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_status;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_percent, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_percent;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_bar, &update_xmms2) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &xmms2_barval;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_smart, &update_xmms2) obj->callbacks.print = &print_xmms2_smart;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_playlist, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_playlist;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ(xmms2_timesplayed, &update_xmms2) obj->callbacks.print =
|
|
|
|
&print_xmms2_timesplayed;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
|
|
|
END OBJ_IF(if_xmms2_connected, &update_xmms2) obj->callbacks.iftest =
|
|
|
|
&if_xmms2_connected;
|
|
|
|
obj->callbacks.free = &free_xmms2;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_XMMS2 */
|
|
|
|
#ifdef BUILD_AUDACIOUS
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(audacious_status, 0) obj->callbacks.print = &print_audacious_status;
|
|
|
|
END OBJ_ARG(audacious_title, 0, "audacious_title needs an argument")
|
|
|
|
sscanf(arg, "%d", &obj->data.i);
|
|
|
|
if (obj->data.i > 0) {
|
|
|
|
++obj->data.i;
|
|
|
|
} else {
|
|
|
|
CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_audacious_title;
|
|
|
|
END OBJ(audacious_length, 0) obj->callbacks.print = &print_audacious_length;
|
|
|
|
END OBJ(audacious_length_seconds, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_length_seconds;
|
|
|
|
END OBJ(audacious_position, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_position;
|
|
|
|
END OBJ(audacious_position_seconds, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_position_seconds;
|
|
|
|
END OBJ(audacious_bitrate, 0) obj->callbacks.print = &print_audacious_bitrate;
|
|
|
|
END OBJ(audacious_frequency, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_frequency;
|
|
|
|
END OBJ(audacious_channels, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_channels;
|
|
|
|
END OBJ(audacious_filename, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_filename;
|
|
|
|
END OBJ(audacious_playlist_length, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_playlist_length;
|
|
|
|
END OBJ(audacious_playlist_position, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_playlist_position;
|
|
|
|
END OBJ(audacious_main_volume, 0) obj->callbacks.print =
|
|
|
|
&print_audacious_main_volume;
|
|
|
|
END OBJ(audacious_bar, 0) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &audacious_barval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_AUDACIOUS */
|
|
|
|
#ifdef BUIL_BMPX
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(bmpx_title, &update_bmpx) obj->callbacks.print = &print_bmpx_title;
|
|
|
|
END OBJ(bmpx_artist, &update_bmpx) obj->callbacks.print = &print_bmpx_artist;
|
|
|
|
END OBJ(bmpx_album, &update_bmpx) obj->callbacks.print = &print_bmpx_album;
|
|
|
|
END OBJ(bmpx_track, &update_bmpx) obj->callbacks.print = &print_bmpx_track;
|
|
|
|
END OBJ(bmpx_uri, &update_bmpx) obj->callbacks.print = &print_bmpx_uri;
|
|
|
|
END OBJ(bmpx_bitrate, &update_bmpx) obj->callbacks.print =
|
|
|
|
&print_bmpx_bitrate;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_BMPX */
|
|
|
|
#ifdef BUILD_EVE
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
|
|
|
|
scan_eve(obj, arg);
|
|
|
|
obj->callbacks.print = &print_eve;
|
|
|
|
obj->callbacks.free = &free_eve;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_EVE */
|
|
|
|
#ifdef BUILD_CURL
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(curl, 0, "curl needs arguments: <uri> <interval in minutes>")
|
|
|
|
curl_parse_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &curl_print;
|
|
|
|
obj->callbacks.free = &curl_obj_free;
|
2018-08-25 16:07:03 +00:00
|
|
|
END OBJ(github_notifications, 0) obj->callbacks.print = &print_github;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_CURL */
|
|
|
|
#ifdef BUILD_RSS
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(rss, 0,
|
|
|
|
"rss needs arguments: <uri> <interval in minutes> <action> "
|
|
|
|
"[act_par] [spaces in front]") rss_scan_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &rss_print_info;
|
|
|
|
obj->callbacks.free = &rss_free_obj_info;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_RSS */
|
|
|
|
#ifdef BUILD_WEATHER_METAR
|
2018-08-12 01:51:21 +00:00
|
|
|
END OBJ_ARG(weather, 0, "weather still needs to written...") obj->callbacks.print = &print_weather;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_WEATHER_METAR */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(lua, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"lua needs arguments: <function name> [function parameters]")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_lua;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
|
|
|
END OBJ_ARG(
|
2018-05-12 23:26:31 +00:00
|
|
|
lua_parse, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"lua_parse needs arguments: <function name> [function parameters]")
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_lua_parse;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(lua_bar, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"lua_bar needs arguments: <height>,<width> <function name> "
|
|
|
|
"[function parameters]") arg = scan_bar(obj, arg, 100);
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
} else {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"lua_bar needs arguments: <height>,<width> <function name> "
|
|
|
|
"[function parameters]");
|
|
|
|
}
|
|
|
|
obj->callbacks.barval = &lua_barval;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(
|
2018-05-12 23:26:31 +00:00
|
|
|
lua_graph, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"lua_graph needs arguments: <function name> [height],[width] [gradient "
|
2018-05-12 23:26:31 +00:00
|
|
|
"colour 1] [gradient colour 2] [scale] [-t] [-l]") char *buf = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
buf = scan_graph(obj, arg, 100);
|
2018-05-12 23:26:31 +00:00
|
|
|
if (buf != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->data.s = buf;
|
|
|
|
} else {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"lua_graph needs arguments: <function name> [height],[width] "
|
|
|
|
"[gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
|
|
|
|
}
|
|
|
|
obj->callbacks.graphval = &lua_barval;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(lua_gauge, nullptr,
|
2018-05-12 16:03:00 +00:00
|
|
|
"lua_gauge needs arguments: <height>,<width> <function name> "
|
|
|
|
"[function parameters]") arg = scan_gauge(obj, arg, 100);
|
2018-05-12 23:26:31 +00:00
|
|
|
if (arg != nullptr) {
|
2018-08-07 16:09:34 +00:00
|
|
|
obj->data.s = STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
} else {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"lua_gauge needs arguments: <height>,<width> <function name> "
|
|
|
|
"[function parameters]");
|
|
|
|
}
|
|
|
|
obj->callbacks.gaugeval = &lua_barval;
|
|
|
|
obj->callbacks.free = &gen_free_opaque;
|
2010-11-13 22:59:31 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_HDDTEMP
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(hddtemp, &update_hddtemp) if (arg) obj->data.s =
|
2018-08-07 16:09:34 +00:00
|
|
|
STRNDUP_ARG;
|
2018-05-12 16:03:00 +00:00
|
|
|
obj->callbacks.print = &print_hddtemp;
|
|
|
|
obj->callbacks.free = &free_hddtemp;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_HDDTEMP */
|
|
|
|
#ifdef BUILD_PORT_MONITORS
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments")
|
|
|
|
tcp_portmon_init(obj, arg);
|
|
|
|
obj->callbacks.print = &tcp_portmon_action;
|
|
|
|
obj->callbacks.free = &tcp_portmon_free;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_PORT_MONITORS */
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(entropy_avail, &update_entropy) obj->callbacks.print =
|
|
|
|
&print_entropy_avail;
|
|
|
|
END OBJ(entropy_perc, &update_entropy) obj->callbacks.percentage =
|
|
|
|
&entropy_percentage;
|
|
|
|
END OBJ(entropy_poolsize, &update_entropy) obj->callbacks.print =
|
|
|
|
&print_entropy_poolsize;
|
|
|
|
END OBJ(entropy_bar, &update_entropy) scan_bar(obj, arg, 1);
|
|
|
|
obj->callbacks.barval = &entropy_barval;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(blink, nullptr, "blink needs a argument") obj->sub =
|
|
|
|
static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_variable_text_internal(obj->sub, arg);
|
|
|
|
obj->callbacks.print = &print_blink;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ_ARG(to_bytes, nullptr, "to_bytes needs a argument") obj->sub =
|
|
|
|
static_cast<text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
extract_variable_text_internal(obj->sub, arg);
|
|
|
|
obj->callbacks.print = &print_to_bytes;
|
2010-04-19 12:54:03 +00:00
|
|
|
#ifdef BUILD_CURL
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(stock, 0, "stock needs arguments") stock_parse_arg(obj, arg);
|
|
|
|
obj->callbacks.print = &print_stock;
|
|
|
|
obj->callbacks.free = &free_stock;
|
2010-04-19 12:54:03 +00:00
|
|
|
#endif /* BUILD_CURL */
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(scroll, nullptr)
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 16:03:00 +00:00
|
|
|
/* allocate a follower to reset any color changes */
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 16:03:00 +00:00
|
|
|
parse_scroll_arg(obj, arg, free_at_crash, s);
|
|
|
|
obj->callbacks.print = &print_scroll;
|
|
|
|
obj->callbacks.free = &free_scroll;
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(combine, nullptr) try {
|
2018-05-12 16:03:00 +00:00
|
|
|
parse_combine_arg(obj, arg);
|
|
|
|
} catch (combine_needs_2_args_error &e) {
|
|
|
|
free(obj);
|
|
|
|
throw obj_create_error(e.what());
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_combine;
|
|
|
|
obj->callbacks.free = &free_combine;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_NVIDIA
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(
|
|
|
|
nvidia, 0,
|
|
|
|
"nvidia needs an argument") if (set_nvidia_query(obj, arg, NONSPECIAL)) {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"nvidia: invalid argument"
|
|
|
|
" specified: '%s'",
|
|
|
|
arg);
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &print_nvidia_value;
|
|
|
|
obj->callbacks.free = &free_nvidia;
|
|
|
|
END OBJ_ARG(
|
|
|
|
nvidiabar, 0,
|
|
|
|
"nvidiabar needs an argument") if (set_nvidia_query(obj, arg, BAR)) {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"nvidiabar: invalid argument"
|
|
|
|
" specified: '%s'",
|
|
|
|
arg);
|
|
|
|
}
|
|
|
|
obj->callbacks.barval = &get_nvidia_barval;
|
|
|
|
obj->callbacks.free = &free_nvidia;
|
|
|
|
END OBJ_ARG(
|
|
|
|
nvidiagraph, 0,
|
|
|
|
"nvidiagraph needs an argument") if (set_nvidia_query(obj, arg, GRAPH)) {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"nvidiagraph: invalid argument"
|
|
|
|
" specified: '%s'",
|
|
|
|
arg);
|
|
|
|
}
|
|
|
|
obj->callbacks.graphval = &get_nvidia_barval;
|
|
|
|
obj->callbacks.free = &free_nvidia;
|
|
|
|
END OBJ_ARG(
|
|
|
|
nvidiagauge, 0,
|
|
|
|
"nvidiagauge needs an argument") if (set_nvidia_query(obj, arg, GAUGE)) {
|
|
|
|
CRIT_ERR(obj, free_at_crash,
|
|
|
|
"nvidiagauge: invalid argument"
|
|
|
|
" specified: '%s'",
|
|
|
|
arg);
|
|
|
|
}
|
|
|
|
obj->callbacks.gaugeval = &get_nvidia_barval;
|
|
|
|
obj->callbacks.free = &free_nvidia;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_NVIDIA */
|
|
|
|
#ifdef BUILD_APCUPSD
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(
|
|
|
|
apcupsd, &update_apcupsd,
|
2018-05-12 23:26:31 +00:00
|
|
|
"apcupsd needs arguments: <host> <port>") if (apcupsd_scan_arg(arg) !=
|
|
|
|
0) {
|
2018-05-12 16:03:00 +00:00
|
|
|
CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
|
|
|
|
}
|
|
|
|
obj->callbacks.print = &gen_print_nothing;
|
|
|
|
END OBJ(apcupsd_name, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_name;
|
|
|
|
END OBJ(apcupsd_model, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_model;
|
|
|
|
END OBJ(apcupsd_upsmode, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_upsmode;
|
|
|
|
END OBJ(apcupsd_cable, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_cable;
|
|
|
|
END OBJ(apcupsd_status, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_status;
|
|
|
|
END OBJ(apcupsd_linev, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_linev;
|
|
|
|
END OBJ(apcupsd_load, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_load;
|
|
|
|
END OBJ(apcupsd_loadbar, &update_apcupsd) scan_bar(obj, arg, 100);
|
|
|
|
obj->callbacks.barval = &apcupsd_loadbarval;
|
2010-01-07 02:38:12 +00:00
|
|
|
#ifdef BUILD_X11
|
2018-05-12 23:26:31 +00:00
|
|
|
END OBJ(apcupsd_loadgraph, &update_apcupsd) char *buf = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
buf = scan_graph(obj, arg, 100);
|
|
|
|
free_and_zero(buf);
|
|
|
|
obj->callbacks.graphval = &apcupsd_loadbarval;
|
|
|
|
END OBJ(apcupsd_loadgauge, &update_apcupsd) scan_gauge(obj, arg, 100);
|
|
|
|
obj->callbacks.gaugeval = &apcupsd_loadbarval;
|
2010-11-13 22:59:31 +00:00
|
|
|
#endif /* BUILD_X11 */
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ(apcupsd_charge, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_charge;
|
|
|
|
END OBJ(apcupsd_timeleft, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_timeleft;
|
|
|
|
END OBJ(apcupsd_temp, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_temp;
|
|
|
|
END OBJ(apcupsd_lastxfer, &update_apcupsd) obj->callbacks.print =
|
|
|
|
&print_apcupsd_lastxfer;
|
2010-01-07 02:38:12 +00:00
|
|
|
#endif /* BUILD_APCUPSD */
|
2016-05-06 11:25:30 +00:00
|
|
|
#ifdef BUILD_JOURNAL
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_ARG(journal, 0, "journal needs arguments")
|
|
|
|
init_journal("journal", arg, obj, free_at_crash);
|
|
|
|
obj->callbacks.print = &print_journal;
|
|
|
|
obj->callbacks.free = &free_journal;
|
2016-05-06 11:25:30 +00:00
|
|
|
#endif /* BUILD_JOURNAL */
|
2016-06-24 14:17:20 +00:00
|
|
|
#ifdef BUILD_PULSEAUDIO
|
2018-05-12 16:03:00 +00:00
|
|
|
END OBJ_IF(if_pa_sink_muted, 0) obj->callbacks.iftest = &puau_muted;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_sink_description, 0) obj->callbacks.print =
|
|
|
|
&print_puau_sink_description;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_sink_active_port_name, 0) obj->callbacks.print =
|
|
|
|
&print_puau_sink_active_port_name;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_sink_active_port_description, 0) obj->callbacks.print =
|
|
|
|
&print_puau_sink_active_port_description;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_sink_volume, 0) obj->callbacks.percentage = &puau_vol;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_sink_volumebar, 0) scan_bar(obj, arg, 1);
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
obj->callbacks.barval = &puau_volumebarval;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
END OBJ(pa_card_active_profile, 0) obj->callbacks.print =
|
|
|
|
&print_puau_card_active_profile;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
|
|
|
END OBJ(pa_card_name, 0) obj->callbacks.print = &print_puau_card_name;
|
|
|
|
obj->callbacks.free = &free_pulseaudio;
|
|
|
|
init_pulseaudio(obj);
|
2016-06-24 14:17:20 +00:00
|
|
|
#endif /* BUILD_PULSEAUDIO */
|
2018-05-12 16:03:00 +00:00
|
|
|
END {
|
2018-05-12 23:26:31 +00:00
|
|
|
auto *buf = static_cast<char *>(malloc(text_buffer_size.get(*state)));
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
NORM_ERR("unknown variable '$%s'", s);
|
|
|
|
snprintf(buf, text_buffer_size.get(*state), "${%s}", s);
|
|
|
|
obj_be_plain_text(obj, buf);
|
|
|
|
free(buf);
|
|
|
|
}
|
2009-08-07 07:24:24 +00:00
|
|
|
#undef OBJ
|
2009-09-09 23:35:57 +00:00
|
|
|
#undef OBJ_IF
|
|
|
|
#undef OBJ_ARG
|
|
|
|
#undef OBJ_IF_ARG
|
|
|
|
#undef __OBJ_HEAD
|
|
|
|
#undef __OBJ_IF
|
|
|
|
#undef __OBJ_ARG
|
|
|
|
#undef END
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
return obj;
|
2009-08-07 07:24:24 +00:00
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2009-08-07 07:24:24 +00:00
|
|
|
/*
|
|
|
|
* - assumes that *string is '#'
|
|
|
|
* - removes the part from '#' to the end of line ('\n' or '\0')
|
|
|
|
* - it removes the '\n'
|
|
|
|
* - copies the last char into 'char *last' argument, which should be a pointer
|
|
|
|
* to a char rather than a string.
|
|
|
|
*/
|
2018-05-12 16:03:00 +00:00
|
|
|
static size_t remove_comment(char *string, char *last) {
|
|
|
|
char *end = string;
|
2018-05-13 18:27:58 +00:00
|
|
|
while (*end != '\0' && *end != '\n') { ++end; }
|
|
|
|
if (last != nullptr) { *last = *end; }
|
|
|
|
if (*end == '\n') { end++; }
|
2018-05-12 16:03:00 +00:00
|
|
|
strfold(string, end - string);
|
|
|
|
return end - string;
|
2009-08-07 07:24:24 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
size_t remove_comments(char *string) {
|
|
|
|
char *curplace;
|
|
|
|
size_t folded = 0;
|
|
|
|
for (curplace = string; *curplace != 0; curplace++) {
|
|
|
|
if (*curplace == '\\' && *(curplace + 1) == '#') {
|
|
|
|
// strcpy can't be used for overlapping strings
|
|
|
|
strfold(curplace, 1);
|
|
|
|
folded += 1;
|
|
|
|
} else if (*curplace == '#') {
|
2018-05-12 23:26:31 +00:00
|
|
|
folded += remove_comment(curplace, nullptr);
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return folded;
|
2009-08-07 07:24:24 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
int extract_variable_text_internal(struct text_object *retval,
|
|
|
|
const char *const_p) {
|
|
|
|
struct text_object *obj;
|
|
|
|
char *p, *s, *orig_p;
|
|
|
|
long line;
|
2018-05-12 23:26:31 +00:00
|
|
|
void *ifblock_opaque = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
char *tmp_p;
|
2018-05-12 23:26:31 +00:00
|
|
|
char *arg = nullptr;
|
2018-05-12 16:03:00 +00:00
|
|
|
size_t len = 0;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
p = strndup(const_p, max_user_text.get(*state) - 1);
|
2018-05-12 23:26:31 +00:00
|
|
|
while (text_contains_templates(p) != 0) {
|
2018-05-12 16:03:00 +00:00
|
|
|
char *tmp;
|
|
|
|
tmp = find_and_replace_templates(p);
|
|
|
|
free(p);
|
|
|
|
p = tmp;
|
|
|
|
}
|
|
|
|
s = orig_p = p;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (static_cast<int>(strcmp(p, const_p) != 0) != 0) {
|
2018-05-12 16:03:00 +00:00
|
|
|
DBGP2("replaced all templates in text: input is\n'%s'\noutput is\n'%s'",
|
|
|
|
const_p, p);
|
|
|
|
} else {
|
|
|
|
DBGP2("no templates to replace");
|
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
memset(retval, 0, sizeof(struct text_object));
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
line = global_text_lines;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
while (*p != 0) {
|
2018-05-13 18:27:58 +00:00
|
|
|
if (*p == '\n') { line++; }
|
2018-05-12 16:03:00 +00:00
|
|
|
if (*p == '$') {
|
|
|
|
*p = '\0';
|
|
|
|
obj = create_plain_text(s);
|
2018-05-13 18:27:58 +00:00
|
|
|
if (obj != nullptr) { append_object(retval, obj); }
|
2018-05-12 16:03:00 +00:00
|
|
|
*p = '$';
|
|
|
|
p++;
|
|
|
|
s = p;
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
if (*p != '$') {
|
2018-05-12 23:26:31 +00:00
|
|
|
auto *buf = static_cast<char *>(malloc(text_buffer_size.get(*state)));
|
2018-05-12 16:03:00 +00:00
|
|
|
const char *var;
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* variable is either $foo or ${foo} */
|
|
|
|
if (*p == '{') {
|
|
|
|
unsigned int brl = 1, brr = 0;
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
p++;
|
|
|
|
s = p;
|
2018-05-12 23:26:31 +00:00
|
|
|
while ((*p != 0) && brl != brr) {
|
2018-05-13 18:27:58 +00:00
|
|
|
if (*p == '{') { brl++; }
|
|
|
|
if (*p == '}') { brr++; }
|
2018-05-12 16:03:00 +00:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
p--;
|
|
|
|
} else {
|
|
|
|
s = p;
|
2018-05-13 18:27:58 +00:00
|
|
|
if (*p == '#') { p++; }
|
2018-05-12 23:26:31 +00:00
|
|
|
while ((*p != 0) &&
|
2018-08-02 15:15:16 +00:00
|
|
|
((isalnum((unsigned char)(*p)) != 0) || *p == '_')) {
|
2018-05-12 16:03:00 +00:00
|
|
|
p++;
|
|
|
|
}
|
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* copy variable to buffer */
|
2018-05-12 23:26:31 +00:00
|
|
|
len = (p - s > static_cast<int>(text_buffer_size.get(*state)) - 1)
|
|
|
|
? static_cast<int>(text_buffer_size.get(*state)) - 1
|
2018-05-12 16:03:00 +00:00
|
|
|
: (p - s);
|
|
|
|
strncpy(buf, s, len);
|
|
|
|
buf[len] = '\0';
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-13 18:27:58 +00:00
|
|
|
if (*p == '}') { p++; }
|
2018-05-12 16:03:00 +00:00
|
|
|
s = p;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* search for variable in environment */
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
var = getenv(buf);
|
2018-05-12 23:26:31 +00:00
|
|
|
if (var != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
obj = create_plain_text(var);
|
2018-05-13 18:27:58 +00:00
|
|
|
if (obj != nullptr) { append_object(retval, obj); }
|
2018-05-12 16:03:00 +00:00
|
|
|
free(buf);
|
|
|
|
continue;
|
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* if variable wasn't found in environment, use some special */
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
arg = nullptr;
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* split arg */
|
2018-05-12 23:26:31 +00:00
|
|
|
if (strchr(buf, ' ') != nullptr) {
|
2018-05-12 16:03:00 +00:00
|
|
|
arg = strchr(buf, ' ');
|
|
|
|
*arg = '\0';
|
|
|
|
arg++;
|
2018-08-02 15:15:16 +00:00
|
|
|
while (isspace((unsigned char)(*arg)) != 0) { arg++; }
|
2018-05-13 18:27:58 +00:00
|
|
|
if (*arg == 0) { arg = nullptr; }
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
/* lowercase variable name */
|
|
|
|
tmp_p = buf;
|
2018-05-12 23:26:31 +00:00
|
|
|
while (*tmp_p != 0) {
|
2018-08-14 12:07:16 +00:00
|
|
|
*tmp_p = tolower((unsigned char)*tmp_p);
|
2018-05-12 16:03:00 +00:00
|
|
|
tmp_p++;
|
|
|
|
}
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
try {
|
|
|
|
obj = construct_text_object(buf, arg, line, &ifblock_opaque, orig_p);
|
|
|
|
} catch (obj_create_error &e) {
|
|
|
|
free(buf);
|
|
|
|
free(orig_p);
|
2018-05-13 01:09:24 +00:00
|
|
|
throw;
|
2018-05-12 16:03:00 +00:00
|
|
|
}
|
2018-05-13 18:27:58 +00:00
|
|
|
if (obj != nullptr) { append_object(retval, obj); }
|
2018-05-12 16:03:00 +00:00
|
|
|
free(buf);
|
|
|
|
continue;
|
2018-05-12 23:26:31 +00:00
|
|
|
}
|
2018-05-13 18:27:58 +00:00
|
|
|
obj = create_plain_text("$");
|
|
|
|
s = p + 1;
|
|
|
|
if (obj != nullptr) { append_object(retval, obj); }
|
2018-05-12 23:26:31 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
} else if (*p == '\\' && *(p + 1) == '#') {
|
|
|
|
strfold(p, 1);
|
|
|
|
} else if (*p == '#') {
|
|
|
|
char c;
|
2018-05-12 23:26:31 +00:00
|
|
|
if ((remove_comment(p, &c) != 0u) && p >= orig_p && c == '\n') {
|
2018-05-12 16:03:00 +00:00
|
|
|
/* if remove_comment removed a newline, we need to 'back up' with p */
|
|
|
|
p--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p++;
|
|
|
|
}
|
|
|
|
obj = create_plain_text(s);
|
2018-05-13 18:27:58 +00:00
|
|
|
if (obj != nullptr) { append_object(retval, obj); }
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if (ifblock_stack_empty(&ifblock_opaque) == 0) {
|
2018-05-12 16:03:00 +00:00
|
|
|
NORM_ERR("one or more $endif's are missing");
|
|
|
|
}
|
2009-08-07 07:24:24 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
free(orig_p);
|
|
|
|
return 0;
|
2009-08-06 06:54:40 +00:00
|
|
|
}
|
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
void extract_object_args_to_sub(struct text_object *obj, const char *args) {
|
2018-05-12 23:26:31 +00:00
|
|
|
obj->sub =
|
|
|
|
static_cast<struct text_object *>(malloc(sizeof(struct text_object)));
|
2018-05-12 16:03:00 +00:00
|
|
|
memset(obj->sub, 0, sizeof(struct text_object));
|
|
|
|
extract_variable_text_internal(obj->sub, args);
|
2009-12-28 01:57:12 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 20:24:03 +00:00
|
|
|
/* Frees the list of text objects root points to. */
|
2018-05-12 16:03:00 +00:00
|
|
|
void free_text_objects(struct text_object *root) {
|
|
|
|
struct text_object *obj;
|
2009-08-06 06:54:40 +00:00
|
|
|
|
2018-05-12 23:26:31 +00:00
|
|
|
if ((root != nullptr) && (root->prev != nullptr)) {
|
|
|
|
for (obj = root->prev; obj != nullptr; obj = root->prev) {
|
2018-05-12 16:03:00 +00:00
|
|
|
root->prev = obj->prev;
|
2018-05-13 18:27:58 +00:00
|
|
|
if (obj->callbacks.free != nullptr) { (*obj->callbacks.free)(obj); }
|
2018-05-12 16:03:00 +00:00
|
|
|
free_text_objects(obj->sub);
|
|
|
|
free_and_zero(obj->sub);
|
|
|
|
free_and_zero(obj->special_data);
|
|
|
|
delete obj->cb_handle;
|
2009-11-29 20:24:03 +00:00
|
|
|
|
2018-05-12 16:03:00 +00:00
|
|
|
free(obj);
|
|
|
|
}
|
|
|
|
}
|
2009-08-05 22:46:51 +00:00
|
|
|
}
|