Closed j16sdiz closed 1 year ago
Remove
#define _POSIX_C_SOURCE
from CR_main.c fix the compilation on macOS
@j16sdiz Were you able to compile this on macOS Ventura? 1) If yes, can you please post some instructions.... 2) Could you upload an executable version (for macOS) please?
Thanks...
XCode 14.2 , Ventrus 13.1
Without code change:
cr_main.c:1282:48: error: implicit declaration of function 'strtok_r' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
for (_val = strdup(_val_conf_glob); (_s = strtok_r(_val, ":", &_saveptr)) != 0; _val = 0) {
^
cr_main.c:1282:48: note: did you mean 'strtok'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:90:7: note: 'strtok' declared here
char *strtok(char *__str, const char *__sep);
^
After remove the _POSIX_C_SOURCE
, everything works.
I can't upload the binary file.
@j16sdiz
I was able to compile as well by removing the#define _POSIX_C_SOURCE
from CR_main.c
Running hl -H
returns:
........... ........... -P : display configuration(s) matching regexp -x : display options count for each config (with -vH options) Configurations :
Running
hl --ifconfig
hl: undefined configuration (ifconfig) !
Can you post here the output of the below 2 commands?
hl -H
hl --ifconfig
Hello,
I fixed problems in the compilation of hl on macOS, it should work now.
Here is the output of hl -H on my system :
hl -H
./hl: version 1.160
Usage: ./hl [-oO][-h|-H|-V|-[[%.]eiuvdDEL1234][-[rgybmcwRGYBMCWnAIsNpPxJTt] regexp ...][--config_name ...] ]
-o : usage will be displayed on stdout (default = stderr)
-O : debug messages will be displayed on stdout (default = stderr)
-h : help
-H : help + configuration names
-V : version
-v : verbose
-u : do not bufferize output on stdout
-e : extended regular expressions
-i : ignore case
-E : print on stderr
-r : red
-g : green
-y : yellow
-b : blue
-m : magenta
-c : cyan
-w : white
-R : red (reverse video)
-G : green (reverse video)
-Y : yellow (reverse video)
-B : blue (reverse video)
-M : magenta (reverse video)
-C : cyan (reverse video)
-W : white (reverse video)
-n : never colorize
-%c : specifies the beginning of a range colorized in color 'c'
-. : specifies the end of the previous range
-d : debug
-D : display regular expressions
-L : lex debug
-1 : color brightness (half-bright)
-2 : color brightness (normal : default)
-3 : color brightness (bright)
-4 : color brightness (underscore)
-A : alternate colors when string matched by selection regex changes
-I : alternate colors when string matched by selection regex does not change
Syntax for alternate options : -{A|I}[[s],c1c2...cn]
where s is a number from 0 to 9 indicating the selection regexp number,
and c1, c2, ... cn are color specifiers to use
Alternate colors implies extended regular expressions (-e)
-s : alternate colors when the string matched by the selection regex is the image
by a simple function (+, -, * or /) of the value of the previous matching string
Syntax for sequential control option : -s[[-+*/]p[adox]:][n],c1c2...cn]
where p is a positive integer (parameter),
n is a number from 0 to 9 indicating the selection regexp number,
and c1, c2, ... cn are color specifiers to use
d : decimal (default)
o : octal
x : hexadecimal
a : ascii (first character of the matching string)
Alternate colors implies extended regular expressions (-e)
-J : Colorize date according to the day of the week
Syntax for day of week option : -J[Ys1ms2ds3[,c1c2...c7]]
where :
s1 : number of the sub-regex for the year
s2 : number of the sub-regex for the month
s3 : number of the sub-regex for the day of the month
and c1c2...c7 are the optional color specifiers for Sunday to Saturday
-T : Colorize string according to specified thresholds values
Syntax for thresholds option : -Ts[x],s1[:c1],s2[:c2]...s10[:c10]
where :
s is a number from 0 to 9 indicating the selection regexp number,
x indicates that thresholds are in hexadecimal
si : value of the i-th threshold for 1 <= i <= 10
c1 : color of the i-th range for 1 <= i <= 10
-t : Colorize string according to time periods
Syntax for time periods option : -tp[0][R][:num][:spec][,c1c2...c10]
where :
p is a time period specifier in [YmwdHMSun]
0 tells that the date must be framed at the beginning of the period
R is an optional flag telling to use an optional time reference
instead of the current time. The optional time reference must be
specified before the regex argument
num is an optional number of time periods (default is 1)
spec is a string specifying the position of date elements,
composed of letters in [YmbdHMSus], each one followed by the
number of the sub-regex it is associated to,
and c1c2...c7 are the optional color specifiers for the time periods
-N : consistent numbering of sub-expressions in -A/-I and -s
-p : display configuration(s) matching glob-like expression (pattern)
-P : display configuration(s) matching regexp
-x : display options count for each config (with -vH options)
Configurations :
--C
--pil-box
--PIL-BOX
--HP41
--HP41_DIR
--HP41_PRGM
--HP41_CAT
--HP41_tree_hdrives
--dmidecode
--show_disks
--show_all_disks
--sccs
--acl
--args
--chronyc
--apt-get
--cal
--diff
--jigdo
--ll
--ls_doc
--man
--mpg123
--namei
--nm
--non_text
--objdump
--samba
--sc
--xxd
--conf
--cr
--ref_list
--cm
--date
--ymdHMS
--mdHMS
--dHMS
--dHMS_debug
--dow
--dow_B
--dow_A
--dow_line
--dow_WE
--dow_WE_B
--dow_WE_A
--dow_WE_line
--sunday
--monday
--tuesday
--wednesday
--thursday
--friday
--saturday
--dhcpd
--diff_tree
--diff_tree2
--dupA1
--dupI1
--dupA2
--dupI2
--dupA3
--dupI3
--dupA4
--dupI4
--dupA5
--dupI5
--dupA6
--dupI6
--dupA7
--dupI7
--dupA8
--dupI8
--dupA9
--dupI9
--dupcA1
--dupcI1
--dupcA2
--dupcI2
--dupcA3
--dupcI3
--dupcA4
--dupcI4
--dupcA5
--dupcI5
--dupcA6
--dupcI6
--dupcA7
--dupcI7
--dupcA8
--dupcI8
--dupcA9
--dupcI9
--error
--err
--errs
--errors
--error_kw
--warning_kw
--remark_kw
--warning
--remark
--file
--hosts
--passwd
--passwd_chk
--iptables
--t0
--tR
--tB
--tC
--tG
--T0
--TR
--TB
--TC
--TG
--compact_t0
--compact_T0
--ha_log
--heartbeat
--heat
--colors
--colors42
--color_names
--hl
--hl_conf
--hl_debug
--hl_opts
--hl_usage
--hl_tool
--hl_tool_count
--rev_color_names
--hi_red
--hi_green
--hi_yellow
--hi_blue
--hi_magenta
--hi_cyan
--hi_white
--dim_red
--dim_green
--dim_yellow
--dim_blue
--dim_magenta
--dim_cyan
--dim_white
--red
--green
--yellow
--blue
--magenta
--cyan
--white
--ibstat
--ib_status
--load_node
--log_d
--log_d_debug
--log_dHMS
--ls_w
--Lustre
--make_tftpboot
--man
--md
--mgp
--module-lua
--nagios_log
--eth
--eth_VIP
--ethtool
--eth_cpt
--fail2ban
--ifconfig
--IP
--ip
--MAC
--netstat
--ping
--tcpdump
--validate_IP
--path1
--path2
--path3
--path4
--path5
--path6
--path7
--path8
--path9
--path10
--path11
--path12
--path13
--path14
--path15
--path16
--path17
--path18
--path19
--path20
--percent
--rc
--out_err
--pxelinux_cfg
--pxe_tcpdump
--quotes
--squotes
--dquotes
--rpm-name
--rpn
--rpn.catalog
--rpn.debug
--rpn.doc
--rpn.op_id
--rpn.types
--rpn.webstats
--diff_hosts
--sh
--iostat
--zabbix_netstat
--stats_messages
--parenthesis
--square_b
--curly_b
--angle_b
--tabs
--spaces
--syslog_day
--syslog_hour
--syslog_min
--syslog_sec
--chkconfig
--df
--dpkg-query
--fdisk
--free
--free_used_swap
--on-off
--ps
--ps_cpu
--ps_cpu_time
--service
--services
--smartctl
--strace
--stty
--swap
--w
--systemctl
--cfgT
--cfg1
--cfg2
--cfg3
--cfg4
--cfg5
--before1
--before2
--before3
--before4
--before5
--after1
--after2
--after3
--after4
--after5
--syslog
--who
--exple_time
--valgrind.memcheck
--virsh_list
--virsh
--xml
--za
--za0
--za_conf
--zalc
--za_log
--za_ls
--za_usage
--za_videos
--za_tty
--za_tty_no_ref
--apt-get
--cal
--chkconfig
--df
--diff
--dpkg-query
--dmidecode
--ethtool
--fdisk
--free
--ifconfig
--iostat
--iptables
--man
--mpg123
--namei
--netstat
--objdump
--ps
--smartctl
--strace
--stty
--tcpdump
--w
--xxd
--acl
--C
--colors
--colors42
--color_names
--err
--eth
--eth_VIP
--fail2ban
--ha_log
--heartbeat
--hl
--hl_conf
--hl_usage
--hosts
--IP
--ip
--jigdo
--ls_doc
--MAC
--on-off
--passwd
--passwd_chk
--percent
--ps_cpu
--ps_cpu_time
--rev_color_names
--samba
--sep3
--services
--sh
--show_disks
--validate_IP
--virsh_list
--hi_red
--hi_green
--hi_yellow
--hi_blue
--hi_magenta
--hi_cyan
--hi_white
--dim_red
--dim_green
--dim_yellow
--dim_blue
--dim_magenta
--dim_cyan
--dim_white
--red
--green
--yellow
--blue
--magenta
--cyan
--white
hl --ifconfig does not display anything as long as you don't give any input to it.
Here is the configuration ifconfig displayed by hl -vop ifconfig :
hl -vop ifconfig
# /Users/martial/hl/config_files/hl_network.cfg
ifconfig :
-e
-2b '\<(inet|netmask|broadcast)\>'
-3G 'inet addr:([0-9]{1,3}(\.[0-9]{1,3}){3})'
-2
-m '^((eth|(vir)?br|vnet)[0-9.]*:[0-9]+)\>'
-b '^((eth|(vir)?br|vnet)[0-9.]*\.[0-9]+)\>'
-c '(([0-9a-f]{2}:){5}[0-9a-f]{2})'
-3g '\<(UP\>|\<RUNNING)\>'
-2y '\<(MULTICAST|BROADCAST)\>'
-2g '\<127\.0\.0\.1\>'
-3g '(([0-9]{1,3}\.){3}[0-9]{1,3}\>)'
-2y '(^(eth|(vir)?br|vnet)[0-9.:]*)\>'
-3m '[0-9a-f]{4}::[0-9a-f]{4}\:[0-9a-f]{4}:[0-9a-f]{4}:[0-9a-f]{4}'
-2r ' ((errors|dropped|overruns):[^0][0-9]*)'
-2B '\<eth[0-9]'
-2Y '\<ib[0-9]'
-3c 'flags=4163'
-3r 'flags=4099'
-3c 'mtu +2044'
-3r 'mtu +[0-9]+'
# /etc/default/hl
ifconfig :
-ei
-3G 'inet addr:([0-9]{1,3}(\.[0-9]{1,3}){3})'
-2
-m '^((eth|(vir)?br|vnet)[0-9.]*:[0-9]+)\>'
-b '^((eth|(vir)?br|vnet)[0-9.]*\.[0-9]+)\>'
-c '(([0-9a-f]{2}:){5}[0-9a-f]{2})'
-3g '\<(UP\>|\<RUNNING)\>'
-2g '(([0-9]{1,3}\.){3}[0-9]{1,3}\>)'
-2y '(^(eth|(vir)?br|vnet)[0-9.:]*)\>'
-3m '[0-9a-f]{4}::[0-9a-f]{4}\:[0-9a-f]{4}:[0-9a-f]{4}:[0-9a-f]{4}'
-2r ' ((errors|dropped|overruns):[^0][0-9]*)'
The macOS compilation works without an error, however, I still cannot get any configurations showing under hl -H
Compiling under macOS
~/Downloads/hl-master % make clean; make
rm -f hl src/hl src/*.o
cd src; make
gcc -c -o cr_main.o cr_main.c
gcc -c -o cr_gpri.o cr_gpri.c
lex -t cr_lex.l > cr_lex.c
gcc -c -o cr_lex.o cr_lex.c
./hl: version 1.160
(END)
The compiling process then just waits indefinitely.... I have to press Q to return to terminal.
Result after pressing q
~/Downloads/hl-master % make clean; make
rm -f hl src/hl src/*.o
cd src; make
gcc -c -o cr_main.o cr_main.c
gcc -c -o cr_gpri.o cr_gpri.c
lex -t cr_lex.l > cr_lex.c
gcc -c -o cr_lex.o cr_lex.c
./hl: version 1.160
mv src/hl .
./hl -V || :
./hl: version 1.160
~/Downloads/hl-master %
Executing hl -H still does not return any configurations...
~/Downloads/hl-master % ./hl -H
./hl: version 1.160
Usage: ./hl [-oO][-h|-H|-V|-[[%.]eiuvdDEL1234][-[rgybmcwRGYBMCWnAIsNpPxJTt] regexp ...][--config_name ...] ]
-o : usage will be displayed on stdout (default = stderr)
-O : debug messages will be displayed on stdout (default = stderr)
-h : help
-H : help + configuration names
-V : version
-v : verbose
-u : do not bufferize output on stdout
-e : extended regular expressions
-i : ignore case
-E : print on stderr
-r : red
-g : green
-y : yellow
-b : blue
-m : magenta
-c : cyan
-w : white
-R : red (reverse video)
-G : green (reverse video)
-Y : yellow (reverse video)
-B : blue (reverse video)
-M : magenta (reverse video)
-C : cyan (reverse video)
-W : white (reverse video)
-n : never colorize
-%c : specifies the beginning of a range colorized in color 'c'
-. : specifies the end of the previous range
-d : debug
-D : display regular expressions
-L : lex debug
-1 : color brightness (half-bright)
-2 : color brightness (normal : default)
-3 : color brightness (bright)
-4 : color brightness (underscore)
-A : alternate colors when string matched by selection regex changes
-I : alternate colors when string matched by selection regex does not change
Syntax for alternate options : -{A|I}[[s],c1c2...cn]
where s is a number from 0 to 9 indicating the selection regexp number,
and c1, c2, ... cn are color specifiers to use
Alternate colors implies extended regular expressions (-e)
-s : alternate colors when the string matched by the selection regex is the image
by a simple function (+, -, * or /) of the value of the previous matching string
Syntax for sequential control option : -s[[-+*/]p[adox]:][n],c1c2...cn]
where p is a positive integer (parameter),
n is a number from 0 to 9 indicating the selection regexp number,
and c1, c2, ... cn are color specifiers to use
d : decimal (default)
o : octal
x : hexadecimal
a : ascii (first character of the matching string)
Alternate colors implies extended regular expressions (-e)
-J : Colorize date according to the day of the week
Syntax for day of week option : -J[Ys1ms2ds3[,c1c2...c7]]
where :
s1 : number of the sub-regex for the year
s2 : number of the sub-regex for the month
s3 : number of the sub-regex for the day of the month
and c1c2...c7 are the optional color specifiers for Sunday to Saturday
-T : Colorize string according to specified thresholds values
Syntax for thresholds option : -Ts[x],s1[:c1],s2[:c2]...s10[:c10]
where :
s is a number from 0 to 9 indicating the selection regexp number,
x indicates that thresholds are in hexadecimal
si : value of the i-th threshold for 1 <= i <= 10
c1 : color of the i-th range for 1 <= i <= 10
-t : Colorize string according to time periods
Syntax for time periods option : -tp[0][R][:num][:spec][,c1c2...c10]
where :
p is a time period specifier in [YmwdHMSun]
0 tells that the date must be framed at the beginning of the period
R is an optional flag telling to use an optional time reference
instead of the current time. The optional time reference must be
specified before the regex argument
num is an optional number of time periods (default is 1)
spec is a string specifying the position of date elements,
composed of letters in [YmbdHMSus], each one followed by the
number of the sub-regex it is associated to,
and c1c2...c7 are the optional color specifiers for the time periods
-N : consistent numbering of sub-expressions in -A/-I and -s
-p : display configuration(s) matching glob-like expression (pattern)
-P : display configuration(s) matching regexp
-x : display options count for each config (with -vH options)
Configurations :
~/Downloads/hl-master %
~/Downloads/hl-master % hl --ifconfig
hl: undefined configuration (ifconfig) !
~/Downloads/hl-master %
~/Downloads/hl-master % hl -vop ifconfig
~/Downloads/hl-master %
Can you please execute the following command and post the result :
./hl -ovh | grep HL_CONF
Here is the result I get on my machine :
$ ./hl -ovh | grep HL_CONF
Environment variable HL_CONF = "/Users/martial/.hl.cfg:/Users/martial/hl_conf:/Users/martial/hl/config_files"
Environment variable HL_CONF_GLOB = "hl_*.cfg:hl.cfg:.hl_*.cfg:.hl.cfg"
Can you please execute the following command and post the result :
./hl -ovh | grep HL_CONF
Here is the result I get on my machine :
$ ./hl -ovh | grep HL_CONF Environment variable HL_CONF = "/Users/martial/.hl.cfg:/Users/martial/hl_conf:/Users/martial/hl/config_files" Environment variable HL_CONF_GLOB = "hl_*.cfg:hl.cfg:.hl_*.cfg:.hl.cfg"
Results of command on my machine...
~/Downloads % hl -ovh | grep HL_CONF Environment variable HL_CONF is undefined. Default value = "~/.hl.cfg;/etc/default/hl". Environment variable HL_CONF_GLOB is undefined. Default value = "hl_*.cfg:hl.cfg:.hl_*.cfg:.hl.cfg". ~/Downloads %
I think the issue is that I haven't copied any associated files anywhere.
**Could you please provide some instructions as to where I should copy the associated files?**
I have compiled **hl** and moved the binary to /opt/homebrew/bin (as this folder is in my path and where most of my other binaries are kept).
_Apologies for the noob questions..._
- Which _additional folders_ should I copy and _where_?
- I also could not locate the _.hl.cfg_ file.
You can notice that your environment variables are undefined, so they have default values which may not be relevant. HL_CONF_GLOB default value may be left as-is (uninitialized) but your should at least define the HL_CONF variable vith the pathname of the directory containing the configurations files. For example, if your working directory was $HOME when you cloned hl, you should have the configuration files in :
$HOME/hl/config_files
so you can put the following line into your $HOME/.bash_profile file :
export HL_CONF="$HOME/hl/config_files"
Regarding the .hl.cfg file, this file is meant to allow each user to have his own hl configurations, so it's located in your $HOME directory, and it's up to you to create it. You may take standard configurations from $HOME/hl/config_files files, put them into $HOME/.hl.cfg and change them, for example by replacing the options used to specify the colors. If there is an option like '-3g ........' , you can replace -3g with -3Y and find what has changed in the results. Does this help you ?
Understood... and all working now !
Thanks for your help... 👍
Perfect, so I close this issue.
Problem solved.
Remove
#define _POSIX_C_SOURCE
from CR_main.c fix the compilation on macOS