Bladeren bron

A few corrections

Use char instead of char* for the single character and don't do this
weird casting thing where a char gets stored in the pointer.
tags/1.3
Timo Röhling 9 jaren geleden
bovenliggende
commit
8653cca9b1
1 gewijzigde bestanden met toevoegingen van 11 en 6 verwijderingen
  1. 11
    6
      postsrsd.c

+ 11
- 6
postsrsd.c Bestand weergeven

@@ -240,7 +240,8 @@ int main (int argc, char **argv)
240 240
   int opt, timeout = 1800, family = AF_INET;
241 241
   int daemonize = FALSE;
242 242
   char *forward_service = NULL, *reverse_service = NULL,
243
-       *user = NULL, *domain = NULL, *chroot_dir = NULL, separator = NULL;
243
+       *user = NULL, *domain = NULL, *chroot_dir = NULL;
244
+  char separator = '=';
244 245
   int forward_sock, reverse_sock;
245 246
   char *secret_file = NULL, *pid_file = NULL;
246 247
   FILE *pf = NULL, *sf = NULL;
@@ -272,7 +273,7 @@ int main (int argc, char **argv)
272 273
         domain = strdup(optarg);
273 274
         break;
274 275
       case 'a':
275
-        separator = (char)*optarg;
276
+        separator = *optarg;
276 277
         break;
277 278
       case 'f':
278 279
         forward_service = strdup(optarg);
@@ -323,7 +324,7 @@ int main (int argc, char **argv)
323 324
         if ( getenv("SRS_DOMAIN") != NULL )
324 325
           domain = strdup(getenv("SRS_DOMAIN"));
325 326
         if ( getenv("SRS_SEPARATOR") != NULL )
326
-          separator = (char)*getenv("SRS_SEPARATOR");
327
+          separator = *getenv("SRS_SEPARATOR");
327 328
         if ( getenv("SRS_FORWARD_PORT") != NULL )
328 329
           forward_service = strdup(getenv("SRS_FORWARD_PORT"));
329 330
         if ( getenv("SRS_REVERSE_PORT") != NULL )
@@ -369,6 +370,11 @@ int main (int argc, char **argv)
369 370
     return EXIT_FAILURE;
370 371
   }
371 372
 
373
+  if (separator != '=' && separator != '+' && separator != '-') {
374
+    fprintf (stderr, "%s: SRS separator character must be one of '=+-'\n", self);
375
+    return EXIT_FAILURE;
376
+  }
377
+
372 378
   /* The stuff we do first may not be possible from within chroot or without privileges */
373 379
 
374 380
   /* Open pid file for writing (the actual process ID is filled in later) */
@@ -461,9 +467,8 @@ int main (int argc, char **argv)
461 467
       srs_add_secret (srs, secret);
462 468
   }
463 469
   fclose (sf);
464
-  if (separator && srs_set_separator (srs, separator) != SRS_SUCCESS) {
465
-    srs_set_separator (srs, '=');
466
-  }
470
+
471
+  srs_set_separator (srs, separator);
467 472
 
468 473
   fds[0].fd = forward_sock;
469 474
   fds[0].events = POLLIN;

Laden…
Annuleren
Opslaan