Browse Source

Cleanup ident handling.

Georgi Chorbadzhiyski 12 years ago
parent
commit
f8f7295862
3 changed files with 14 additions and 11 deletions
  1. 2
    1
      data.h
  2. 2
    1
      notify.c
  3. 10
    9
      tsdecrypt.c

+ 2
- 1
data.h View File

223
 	struct camd			camd;
223
 	struct camd			camd;
224
 
224
 
225
 	// Config
225
 	// Config
226
-	char				ident[128];
226
+	char				*ident;
227
+
227
 	char				syslog_host[128];
228
 	char				syslog_host[128];
228
 	int					syslog_port;
229
 	int					syslog_port;
229
 	int					syslog_active;
230
 	int					syslog_active;

+ 2
- 1
notify.c View File

116
 
116
 
117
 struct notify *notify_alloc(struct ts *ts) {
117
 struct notify *notify_alloc(struct ts *ts) {
118
 	unsigned int i;
118
 	unsigned int i;
119
-	if (!ts->ident[0] || !ts->notify_program)
119
+	if (!ts->ident || !ts->notify_program)
120
 		return NULL;
120
 		return NULL;
121
 	struct notify *n = calloc(1, sizeof(struct notify));
121
 	struct notify *n = calloc(1, sizeof(struct notify));
122
 	n->notifications = queue_new();
122
 	n->notifications = queue_new();
123
 	strncpy(n->ident, ts->ident, sizeof(n->ident) - 1);
123
 	strncpy(n->ident, ts->ident, sizeof(n->ident) - 1);
124
+	n->ident[sizeof(n->ident) - 1] = '\0';
124
 	for (i=0; i<strlen(n->ident); i++) {
125
 	for (i=0; i<strlen(n->ident); i++) {
125
 		if (n->ident[i] == '/')
126
 		if (n->ident[i] == '/')
126
 			n->ident[i] = '-';
127
 			n->ident[i] = '-';

+ 10
- 9
tsdecrypt.c View File

281
 		char *p = NULL;
281
 		char *p = NULL;
282
 		switch (j) {
282
 		switch (j) {
283
 			case 'i':
283
 			case 'i':
284
-				strncpy(ts->ident, optarg, sizeof(ts->ident) - 1);
285
-				ts->ident[sizeof(ts->ident) - 1] = 0;
284
+				ts->ident = optarg;
286
 				break;
285
 				break;
287
 			case 'd':
286
 			case 'd':
288
 				ts->pidfile = optarg;
287
 				ts->pidfile = optarg;
473
 				exit(EXIT_SUCCESS);
472
 				exit(EXIT_SUCCESS);
474
 		}
473
 		}
475
 	}
474
 	}
476
-	if (!ts->ident[0]) {
475
+	if (!ts->ident) {
477
 		if (ts->syslog_active || ts->notify_program)
476
 		if (ts->syslog_active || ts->notify_program)
478
 			ident_err = 1;
477
 			ident_err = 1;
479
 	}
478
 	}
502
 		exit(EXIT_FAILURE);
501
 		exit(EXIT_FAILURE);
503
 	}
502
 	}
504
 
503
 
505
-	ts_LOGf("Ident      : %s\n", ts->ident[0] ? ts->ident : "*NOT SET*");
504
+	if (ts->ident)
505
+		ts_LOGf("Ident      : %s\n", ts->ident);
506
 	if (ts->notify_program)
506
 	if (ts->notify_program)
507
 		ts_LOGf("Notify prg : %s\n", ts->notify_program);
507
 		ts_LOGf("Notify prg : %s\n", ts->notify_program);
508
 	if (ts->pidfile)
508
 	if (ts->pidfile)
613
 	if (!ts->ecm_cw_log)
613
 	if (!ts->ecm_cw_log)
614
 		ts_LOGf("ECM/CW log : disabled\n");
614
 		ts_LOGf("ECM/CW log : disabled\n");
615
 
615
 
616
-	for (i=0; i<(int)sizeof(ts->ident); i++) {
617
-		if (!ts->ident[i])
618
-			break;
619
-		if (ts->ident[i] == '/')
620
-			ts->ident[i] = '-';
616
+	if (ts->ident) {
617
+		int len = strlen(ts->ident);
618
+		for (i = 0; i < len; i++) {
619
+			if (ts->ident[i] == '/')
620
+				ts->ident[i] = '-';
621
+		}
621
 	}
622
 	}
622
 }
623
 }
623
 
624
 

Loading…
Cancel
Save