[hipl-commit] [trunk] Rev 3589: uncrustified tools

  • From: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Thu, 11 Feb 2010 01:16:17 +0200

Committer: Rene Hummen <rene.hummen@xxxxxxxxxxxxxxxxx>
Date: Thu Feb 11 00:16:07 2010 +0100
Revision: 3589
Revision-id: rene.hummen@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: trunk

Log:
  uncrustified tools

Modified:
  M  tools/hipconftool.c
  M  tools/pisacert.c

=== modified file 'tools/hipconftool.c'
--- tools/hipconftool.c 2010-01-19 11:02:34 +0000
+++ tools/hipconftool.c 2010-02-10 23:16:07 +0000
@@ -20,34 +20,31 @@
  */
 #ifndef HIP_UNITTEST_MODE /* Unit testing code does not compile with main */
 
-int main(int argc, char *argv[]) {
-
-       int err = 0;
-
-#if 0
-       const char *cfile = "default";
-#endif
-
-       /* we don't want log messages via syslog */
-       hip_set_logtype(LOGTYPE_STDERR);
-       hip_set_logfmt(LOGFMT_SHORT);
-
-       // workaround for bug #604
-       hip_set_logdebug(LOGDEBUG_ALL);
-
-#if 0
-       HIP_IFEL(hip_set_auto_logdebug(cfile), -1,
-                "Error: Cannot set the debugging parameter.\n");
-#endif
-
-
-       HIP_IFEL(hip_do_hipconf(argc, argv, 0), -2,
-                "Error: Cannot configure the HIP daemon.\n");
-
- out_err:
-       return err;
-
+int main(int argc, char *argv[])
+{
+    int err = 0;
+
+#if 0
+    const char *cfile = "default";
+#endif
+
+    /* we don't want log messages via syslog */
+    hip_set_logtype(LOGTYPE_STDERR);
+    hip_set_logfmt(LOGFMT_SHORT);
+
+    // workaround for bug #604
+    hip_set_logdebug(LOGDEBUG_ALL);
+
+#if 0
+    HIP_IFEL(hip_set_auto_logdebug(cfile), -1,
+             "Error: Cannot set the debugging parameter.\n");
+#endif
+
+    HIP_IFEL(hip_do_hipconf(argc, argv, 0), -2,
+             "Error: Cannot configure the HIP daemon.\n");
+
+out_err:
+    return err;
 }
 
 #endif /* HIP_UNITTEST_MODE */
-

=== modified file 'tools/pisacert.c'
--- tools/pisacert.c    2010-02-08 15:18:06 +0000
+++ tools/pisacert.c    2010-02-10 23:16:07 +0000
@@ -19,26 +19,27 @@
  */
 int get_default_hit(struct in6_addr *result)
 {
-       int err = 0;
-       hip_common_t *msg = NULL;
-       struct hip_tlv_common *param = NULL;
-       struct in6_addr *hit = NULL;
-
-       msg = hip_msg_alloc();
-       HIP_IFE(!msg, -1);
-
-       HIP_IFE(hip_build_user_hdr(msg, SO_HIP_DEFAULT_HIT, 0), -1);
-       HIP_IFE(hip_send_recv_daemon_info(msg, 0, 0), -ECOMM);
-
-       param = hip_get_param(msg, HIP_PARAM_HIT);
-       hit = (struct in6_addr *) hip_get_param_contents_direct(param);
-       memcpy(result, hit, sizeof(struct in6_addr));
+    int err                      = 0;
+    hip_common_t *msg            = NULL;
+    struct hip_tlv_common *param = NULL;
+    struct in6_addr *hit         = NULL;
+
+    msg = hip_msg_alloc();
+    HIP_IFE(!msg, -1);
+
+    HIP_IFE(hip_build_user_hdr(msg, SO_HIP_DEFAULT_HIT, 0), -1);
+    HIP_IFE(hip_send_recv_daemon_info(msg, 0, 0), -ECOMM);
+
+    param = hip_get_param(msg, HIP_PARAM_HIT);
+    hit   = (struct in6_addr *) hip_get_param_contents_direct(param);
+    memcpy(result, hit, sizeof(struct in6_addr));
 
 out_err:
-       if (msg)
-               free(msg);
+    if (msg) {
+        free(msg);
+    }
 
-       return err;
+    return err;
 }
 
 /**
@@ -52,63 +53,65 @@
  * @return 0 on success
  */
 int create_certificate(time_t *not_before, time_t *not_after,
-                      struct in6_addr *hit, char *certificate, size_t size)
+                       struct in6_addr *hit, char *certificate, size_t size)
 {
-       int err = 0;
-       struct hip_cert_spki_info cert = { 0 };
-
-       HIP_IFEL(!not_before || !not_after || !hit || !certificate, -1,
-                "NULL parameter found.\n");
-
-       hip_cert_spki_create_cert(&cert, "hit", hit, "hit", hit, not_before,
-                                 not_after);
-
-       snprintf(certificate, size, "(sequence %s%s%s)", cert.public_key,
-                cert.cert, cert.signature);
+    int err                        = 0;
+    struct hip_cert_spki_info cert = { 0 };
+
+    HIP_IFEL(!not_before || !not_after || !hit || !certificate, -1,
+             "NULL parameter found.\n");
+
+    hip_cert_spki_create_cert(&cert, "hit", hit, "hit", hit, not_before,
+                              not_after);
+
+    snprintf(certificate, size, "(sequence %s%s%s)", cert.public_key,
+             cert.cert, cert.signature);
 out_err:
-       if (err != 0 && certificate)
-               certificate[0] = '\0';
-       return err;
+    if (err != 0 && certificate) {
+        certificate[0] = '\0';
+    }
+    return err;
 }
 
 int main(int argc, char *argv[])
 {
-       time_t not_before = 0, not_after = 0;
-       struct in6_addr hit;
-       int err = 0, days = 0;
-       FILE *f = NULL;
-       char certificate[1024] = "";
-       size_t ignored;
-       
-       HIP_IFEL(argc != 3, -1, "Wrong number of arguments.\n");
-
-       HIP_IFEL(getuid() != 0, -1, "You're not superuser.\n");
-
-       days = atoi(argv[1]);
-       HIP_IFEL(days <= 0, -1, "Specify a positive number of days.\n");
-
-       f = fopen(argv[2], "w");
-       HIP_IFEL(f == NULL, -1, "Could not write to file.\n");
-
-       time(&not_before);
-       time(&not_after);
-       not_after += days * 24 * 60 * 60;
-
-       HIP_IFEL(get_default_hit(&hit), -1, "Could not get HIT from hipd.\n");
-       HIP_IFEL(create_certificate(&not_before, &not_after, &hit,
-                                   certificate, sizeof(certificate)) != 0,
-                -1, "Could not create the certificate.\n");
-
-       ignored = fwrite(certificate, strlen(certificate), 1, f);
+    time_t not_before      = 0, not_after = 0;
+    struct in6_addr hit;
+    int err                = 0, days = 0;
+    FILE *f                = NULL;
+    char certificate[1024] = "";
+    size_t ignored;
+
+    HIP_IFEL(argc != 3, -1, "Wrong number of arguments.\n");
+
+    HIP_IFEL(getuid() != 0, -1, "You're not superuser.\n");
+
+    days = atoi(argv[1]);
+    HIP_IFEL(days <= 0, -1, "Specify a positive number of days.\n");
+
+    f    = fopen(argv[2], "w");
+    HIP_IFEL(f == NULL, -1, "Could not write to file.\n");
+
+    time(&not_before);
+    time(&not_after);
+    not_after += days * 24 * 60 * 60;
+
+    HIP_IFEL(get_default_hit(&hit), -1, "Could not get HIT from hipd.\n");
+    HIP_IFEL(create_certificate(&not_before, &not_after, &hit,
+                                certificate, sizeof(certificate)) != 0,
+             -1, "Could not create the certificate.\n");
+
+    ignored = fwrite(certificate, strlen(certificate), 1, f);
 
 out_err:
-       if (err == -1) {
-               fprintf(stderr, "usage: pisacert days filename\n");
-               fprintf(stderr, "must be run as superuser, e.g. with sudo\n");
-       }
-
-       if (f)
-               fclose(f);
-
-       return err;
+    if (err == -1) {
+        fprintf(stderr, "usage: pisacert days filename\n");
+        fprintf(stderr, "must be run as superuser, e.g. with sudo\n");
+    }
+
+    if (f) {
+        fclose(f);
+    }
+
+    return err;
 }

Other related posts:

  • » [hipl-commit] [trunk] Rev 3589: uncrustified tools - Rene Hummen