Diff for /mqtt/src/mqtt_ping.c between versions 1.3 and 1.4

version 1.3, 2012/07/03 12:46:00 version 1.4, 2017/10/08 22:49:25
Line 12  terms: Line 12  terms:
 All of the documentation and software included in the ELWIX and AITNET  All of the documentation and software included in the ELWIX and AITNET
 Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>  Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org>
   
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
         by Michael Pounov <misho@elwix.org>.  All rights reserved.          by Michael Pounov <misho@elwix.org>.  All rights reserved.
   
 Redistribution and use in source and binary forms, with or without  Redistribution and use in source and binary forms, with or without
Line 48  SUCH DAMAGE. Line 48  SUCH DAMAGE.
 #include "client.h"  #include "client.h"
   
   
 io_enableDEBUG;  
   
 extern char compiled[], compiledby[], compilehost[];  extern char compiled[], compiledby[], compilehost[];
   
 struct tagArgs *args;  struct tagArgs *args;
Line 96  Ping(int sock, int num, struct timeval * __restrict ac Line 94  Ping(int sock, int num, struct timeval * __restrict ac
         timersub(&after, &before, &calc);          timersub(&after, &before, &calc);
         timeradd(accu, &calc, accu);          timeradd(accu, &calc, accu);
   
        printf(" + Ping %d MQTT broker %s ... %f sec.\n", num, io_n2addr(&args->addr, &val),         printf(" + Ping %d MQTT broker %s ... %f sec.\n", num, e_n2addr(&args->addr, &val), 
                         calc.tv_sec + calc.tv_usec / 1.e6);                          calc.tv_sec + calc.tv_usec / 1.e6);
         AIT_FREE_VAL(&val);          AIT_FREE_VAL(&val);
   
Line 114  main(int argc, char **argv) Line 112  main(int argc, char **argv)
         register int i;          register int i;
         struct timeval accu;          struct timeval accu;
   
        if (!(args = io_malloc(sizeof(struct tagArgs)))) {        if (!(args = e_malloc(sizeof(struct tagArgs)))) {
                 printf("Error:: in alloc arguments #%d - %s\n", errno, strerror(errno));                  printf("Error:: in alloc arguments #%d - %s\n", errno, strerror(errno));
                 return 1;                  return 1;
         } else          } else
Line 124  main(int argc, char **argv) Line 122  main(int argc, char **argv)
         if (!(args->msg = mqtt_msgAlloc(USHRT_MAX))) {          if (!(args->msg = mqtt_msgAlloc(USHRT_MAX))) {
                 printf("Error:: in mqtt buffer #%d - %s\n", mqtt_GetErrno(), mqtt_GetError());                  printf("Error:: in mqtt buffer #%d - %s\n", mqtt_GetErrno(), mqtt_GetError());
                 args->free(args);                  args->free(args);
                io_free(args);                e_free(args);
                 return 1;                  return 1;
         }          }
   
Line 153  main(int argc, char **argv) Line 151  main(int argc, char **argv)
                                 port = (u_short) strtol(optarg, NULL, 0);                                  port = (u_short) strtol(optarg, NULL, 0);
                                 break;                                  break;
                         case 'v':                          case 'v':
                                io_incDebug;                                e_incVerbose;
                                 break;                                  break;
                         case 'h':                          case 'h':
                         default:                          default:
                                 args->free(args);                                  args->free(args);
                                io_free(args);                                e_free(args);
                                 Usage();                                  Usage();
                                 return 1;                                  return 1;
                 }                  }
Line 167  main(int argc, char **argv) Line 165  main(int argc, char **argv)
         if (argc < 2) {          if (argc < 2) {
                 printf("Error:: host for connect not found or connection id!\n\n");                  printf("Error:: host for connect not found or connection id!\n\n");
                 args->free(args);                  args->free(args);
                io_free(args);                e_free(args);
                 Usage();                  Usage();
                 return 1;                  return 1;
         } else {          } else {
                 AIT_FREE_VAL(&args->ConnID);                  AIT_FREE_VAL(&args->ConnID);
                 AIT_SET_STR(&args->ConnID, argv[1]);                  AIT_SET_STR(&args->ConnID, argv[1]);
         }          }
        if (!io_gethostbyname(*argv, port, &args->addr)) {        if (!e_gethostbyname(*argv, port, &args->addr)) {
                printf("Error:: host not valid #%d - %s\n", io_GetErrno(), io_GetError());                printf("Error:: host not valid #%d - %s\n", elwix_GetErrno(), elwix_GetError());
                 args->free(args);                  args->free(args);
                io_free(args);                e_free(args);
                 Usage();                  Usage();
                 return 1;                  return 1;
         }          }
        printf("Connecting to %s:%d ... ", io_n2addr(&args->addr, &val), io_n2port(&args->addr));        printf("Connecting to %s:%d ... ", e_n2addr(&args->addr, &val), e_n2port(&args->addr));
         AIT_FREE_VAL(&val);          AIT_FREE_VAL(&val);
   
         if (!(args->cli = mqtt_cli_Open(&args->addr.sa, args->ka))) {          if (!(args->cli = mqtt_cli_Open(&args->addr.sa, args->ka))) {
                 args->free(args);                  args->free(args);
                io_free(args);                e_free(args);
                 return 2;                  return 2;
         }          }
   
Line 229  main(int argc, char **argv) Line 227  main(int argc, char **argv)
         mqtt_cli_Close(&args->cli);          mqtt_cli_Close(&args->cli);
   
         args->free(args);          args->free(args);
        io_free(args);        e_free(args);
         return ret;          return ret;
 }  }

Removed from v.1.3  
changed lines
  Added in v.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>