Hi,
Stupid request, but useful: I suggest to add the version description in the top of help command (minisatip --help). I check several binary versions, and I need to start them to check the version. Please, can you add this?
Also, please, print the help when no arguments in the command line.
Thank you!
#182: version on help
maybe like this or an option -V --version
I did also try to make the program name full virtual and fix the PID_FILE issue
```
--- minisatip.c.orig 2015-10-27 12:26:21.302843550 +0100
+++ minisatip.c 2015-10-27 13:30:21.890921843 +0100
@@ -47,7 +47,7 @@
#define DESC_XML desc.xml
char version[] = VERSION;
-char app_name[] = minisatip;
+const char *app_name = minisatip;
extern sockets s[MAX_SOCKS];
char public[] = Public: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN;
@@ -111,6 +111,9 @@
void usage()
{
+ printf(%s version %s, compiled with s2api version: %04X
,
+ app_name, version, DVBAPIVERSION);
+
printf(
%s [-[fgltz]] [-a x:y:z] [-b X:Y] [-c X] [-d A:C-U ] [-D device_id] [-e X-Y,Z] [-i prio] [-j A1:S1-F1[-PIN]] [-m mac] [-o oscam_host:dvbapi_port] [-p public_host] [-r remote_rtp_host] [-R document_root] [-s [DELSYS:]host[:port] [-u A1:S1-F1[-PIN]] [-w http_server[:port]] [-x http_port] [-X xml_path] [-y rtsp_port]
@@ -999,7 +1002,11 @@
void write_pid_file()
{
FILE *f;
- if ((f = fopen(PID_FILE, wt)))
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), PID_FILE, app_name);
+
+ if ((f = fopen(buf, wt)))
{
fprintf(f, %d, getpid());
fclose(f);
@@ -1010,6 +1017,8 @@
int main(int argc, char *argv[])
{
+ if (argv[0] && argv[0][0])
+ app_name = basename(argv[0]);
realpath(argv[0], pn);
set_signal_handler();
@@ -1054,7 +1063,10 @@
init_dvbapi();
#endif
select_and_execute();
- unlink(PID_FILE);
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), PID_FILE, app_name);
+ unlink(buf);
free_all();
if (opts.slog)
closelog();
```
```
--- dvbapi.c.orig 2015-10-27 12:49:31.533115743 +0100
+++ dvbapi.c 2015-10-27 12:50:04.584710833 +0100
@@ -48,7 +48,8 @@
#include tables.h
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
const int64_t DVBAPI_ITEM = 0x1000000000000;
int dvbapi_sock = -1;
```
```
--- satipc.c.orig 2015-10-27 12:50:19.119532769 +0100
+++ satipc.c 2015-10-27 12:51:13.328868660 +0100
@@ -49,7 +49,8 @@
extern char *fe_delsys[];
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
uint16_t apid[MAX_ADAPTERS][MAX_PIDS]; // pids to add
uint16_t dpid[MAX_ADAPTERS][MAX_PIDS]; // pids to delete
```
```
--- utils.c.orig 2015-10-27 12:47:52.423329921 +0100
+++ utils.c 2015-10-27 12:49:02.600470192 +0100
@@ -52,7 +52,8 @@
#include minisatip.h
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
#define MAX_DATA 1500 // 16384
#define MAX_SINFO 100
```
```
--- utils.h.orig 2015-10-27 14:04:00.108720452 +0100
+++ utils.h 2015-10-27 14:04:57.801693317 +0100
@@ -34,7 +34,7 @@
#define LOGL(level,a,...) { if(level<=opts.log)_log(level,__FILE__,__LINE__,a, ##__VA_ARGS__);}
-#define FAIL(a,...) {LOGL(0,a,##__VA_ARGS__);unlink(PID_FILE);exit(1);}
+#define FAIL(a,...) {LOGL(0,a,##__VA_ARGS__);char buf[255];snprintf(buf, sizeof(buf), PID_FILE, app_name);unlink(PID_FILE);exit(1);}
#define LOG_AND_RETURN(rc,a,...) {LOG(a,##__VA_ARGS__);return rc;}
#define malloc1(a) mymalloc(a,__FILE__,__LINE__)
#define free1(a) myfree(a,__FILE__,__LINE__)
```
I did also try to make the program name full virtual and fix the PID_FILE issue
```
--- minisatip.c.orig 2015-10-27 12:26:21.302843550 +0100
+++ minisatip.c 2015-10-27 13:30:21.890921843 +0100
@@ -47,7 +47,7 @@
#define DESC_XML desc.xml
char version[] = VERSION;
-char app_name[] = minisatip;
+const char *app_name = minisatip;
extern sockets s[MAX_SOCKS];
char public[] = Public: OPTIONS, DESCRIBE, SETUP, PLAY, TEARDOWN;
@@ -111,6 +111,9 @@
void usage()
{
+ printf(%s version %s, compiled with s2api version: %04X
,
+ app_name, version, DVBAPIVERSION);
+
printf(
%s [-[fgltz]] [-a x:y:z] [-b X:Y] [-c X] [-d A:C-U ] [-D device_id] [-e X-Y,Z] [-i prio] [-j A1:S1-F1[-PIN]] [-m mac] [-o oscam_host:dvbapi_port] [-p public_host] [-r remote_rtp_host] [-R document_root] [-s [DELSYS:]host[:port] [-u A1:S1-F1[-PIN]] [-w http_server[:port]] [-x http_port] [-X xml_path] [-y rtsp_port]
@@ -999,7 +1002,11 @@
void write_pid_file()
{
FILE *f;
- if ((f = fopen(PID_FILE, wt)))
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), PID_FILE, app_name);
+
+ if ((f = fopen(buf, wt)))
{
fprintf(f, %d, getpid());
fclose(f);
@@ -1010,6 +1017,8 @@
int main(int argc, char *argv[])
{
+ if (argv[0] && argv[0][0])
+ app_name = basename(argv[0]);
realpath(argv[0], pn);
set_signal_handler();
@@ -1054,7 +1063,10 @@
init_dvbapi();
#endif
select_and_execute();
- unlink(PID_FILE);
+ char buf[255];
+
+ snprintf(buf, sizeof(buf), PID_FILE, app_name);
+ unlink(buf);
free_all();
if (opts.slog)
closelog();
```
```
--- dvbapi.c.orig 2015-10-27 12:49:31.533115743 +0100
+++ dvbapi.c 2015-10-27 12:50:04.584710833 +0100
@@ -48,7 +48,8 @@
#include tables.h
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
const int64_t DVBAPI_ITEM = 0x1000000000000;
int dvbapi_sock = -1;
```
```
--- satipc.c.orig 2015-10-27 12:50:19.119532769 +0100
+++ satipc.c 2015-10-27 12:51:13.328868660 +0100
@@ -49,7 +49,8 @@
extern char *fe_delsys[];
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
uint16_t apid[MAX_ADAPTERS][MAX_PIDS]; // pids to add
uint16_t dpid[MAX_ADAPTERS][MAX_PIDS]; // pids to delete
```
```
--- utils.c.orig 2015-10-27 12:47:52.423329921 +0100
+++ utils.c 2015-10-27 12:49:02.600470192 +0100
@@ -52,7 +52,8 @@
#include minisatip.h
extern struct struct_opts opts;
-extern char version[], app_name[];
+extern char version[];
+extern const char *app_name;
#define MAX_DATA 1500 // 16384
#define MAX_SINFO 100
```
```
--- utils.h.orig 2015-10-27 14:04:00.108720452 +0100
+++ utils.h 2015-10-27 14:04:57.801693317 +0100
@@ -34,7 +34,7 @@
#define LOGL(level,a,...) { if(level<=opts.log)_log(level,__FILE__,__LINE__,a, ##__VA_ARGS__);}
-#define FAIL(a,...) {LOGL(0,a,##__VA_ARGS__);unlink(PID_FILE);exit(1);}
+#define FAIL(a,...) {LOGL(0,a,##__VA_ARGS__);char buf[255];snprintf(buf, sizeof(buf), PID_FILE, app_name);unlink(PID_FILE);exit(1);}
#define LOG_AND_RETURN(rc,a,...) {LOG(a,##__VA_ARGS__);return rc;}
#define malloc1(a) mymalloc(a,__FILE__,__LINE__)
#define free1(a) myfree(a,__FILE__,__LINE__)
```