Skip to content

Commit ba3a0d2

Browse files
committed
2 parents 98eda5e + 4828b0e commit ba3a0d2

File tree

8 files changed

+15
-5
lines changed

8 files changed

+15
-5
lines changed

conf/example.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ qBHnuLhINOFURgXeYmPMaEDIHkmdQ2GJg3aSfzPeBtxAfawxf6pf
3232
xsntmex /var/tfdb/xsntmex
3333
userdb /var/tfdb/lsr
3434
xsace /var/tfdb/xsace
35-
defusr user
35+
defusr user
3636
tlb /var/tfdb/tlb
3737
pubkey {-----BEGIN PUBLIC KEY-----
3838
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmm8HzASM58ZMT237SR/h

doc/tfproto_xs1.doc

6 KB
Binary file not shown.

doc/tfproto_xs1.pdf

-3.85 KB
Binary file not shown.

include/log.h

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
/* Enum to indicate the category of the log action */
2727
enum logcat { LGC_CRITICAL, LGC_INFO, LGC_WARNING };
2828

29+
extern int dmode;
30+
2931
/* This function write to syslog */
3032
void wrlog(const char *msg, enum logcat cat);
3133

include/util.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
/* Short length string. */
5656
#define SHORTSTR 255
5757
/* Default creation file permission: 0644. */
58-
#define DEFFILE_PERM S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
58+
#define DEFFILE_PERM S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
5959
/* Default creation directory permission: 0755. */
6060
#define DEFDIR_PERM S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH
6161

src/log.c

+7
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
#include <syslog.h>
66
#include <unistd.h>
77
#include <log.h>
8+
#include <stdio.h>
89

910
/* Strings for using with syslog */
1011
#define LGC_CRITICAL_STR "[ CRITICAL ]"
1112
#define LGC_INFO_STR "[ INFO ]"
1213
#define LGC_WARNING_STR "[ WARNING ]"
1314

15+
/* non-zero if tfprotocol is running in daemon mode. */
16+
int dmode;
17+
1418
void wrlog(const char *msg, enum logcat cat)
1519
{
1620
char *catpt = NULL;
@@ -26,5 +30,8 @@ void wrlog(const char *msg, enum logcat cat)
2630
break;
2731
}
2832
syslog(LOG_INFO | LOG_DAEMON, "%s %d %s %s","PID: :", getpid(), msg, catpt);
33+
if (!dmode)
34+
printf("%s %s %s %d\n", catpt, msg, "PID: ", getpid());
2935
closelog();
3036
}
37+

src/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ static void mkdaemon(void);
2525

2626
int main(int argc, char **argv)
2727
{
28+
if (argc >= 3)
29+
dmode = 1;
2830
if (argc < 2) {
2931
wrlog(ELOGDARG, LGC_CRITICAL);
3032
exit(EXIT_FAILURE);

src/xs1/xs1.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ static int xs1_chkidx(const char *pt)
259259
if (!strcmp(num, ""))
260260
return -1;
261261
int32_t idx = atoll(num);
262-
if (idx < 0 || idx >= ds.count || !(ds.fds + idx) ||
263-
*(ds.fds + idx) == -1)
262+
if (idx < 0 || idx >= ds.count || *(ds.fds + idx) == -1)
264263
return -1;
265264
return idx;
266265
}
@@ -529,7 +528,7 @@ static void xs1_cmdreadv2(void)
529528

530529
static int xs1_chkidx_int64(int64_t idx)
531530
{
532-
if (idx < 0 || idx >= ds.count || !(ds.fds + idx) || *(ds.fds + idx) == -1)
531+
if (idx < 0 || idx >= ds.count || *(ds.fds + idx) == -1)
533532
return -1;
534533
return idx;
535534
}

0 commit comments

Comments
 (0)