Bump patch version post tag.
[asdcplib.git] / src / kmfilegen.cpp
index 3f3ba11c4a5c4c3e75014311f2068652364d50bb..2ce033251fa84b23086ba788030fe13a642ea857 100755 (executable)
@@ -1,5 +1,5 @@
 /*
-Copyright (c) 2005-2008, John Hurst
+Copyright (c) 2005-2009, John Hurst
 All rights reserved.
 
 Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 using namespace Kumu;
 
 // constants
-static const char* PACKAGE = "kmfilegen";  // program name for messages
+static const char* PROGRAM_NAME = "kmfilegen";  // program name for messages
 const ui32_t RNG_KEY_SIZE = 16;
 const ui32_t RNG_KEY_SIZE_BITS = 128;
 const ui32_t RNG_BLOCK_SIZE = 16;
@@ -69,12 +69,12 @@ banner(FILE* stream = stdout)
 {
   fprintf(stream, "\n\
 %s (asdcplib %s)\n\n\
-Copyright (c) 2005-2008 John Hurst\n\
+Copyright (c) 2005-2009 John Hurst\n\
 %s is part of the asdcplib DCP tools package.\n\
 asdcplib may be copied only under the terms of the license found at\n\
 the top of every file in the asdcplib distribution kit.\n\n\
 Specify the -h (help) option for further information about %s\n\n",
-         PACKAGE, ASDCP::Version(), PACKAGE, PACKAGE);
+         PROGRAM_NAME, Kumu::Version(), PROGRAM_NAME, PROGRAM_NAME);
 }
 
 
@@ -102,7 +102,7 @@ USAGE: %s [-c <file-size>] [-v] <output-file>\n\
 \n\
   NOTES: o There is no option grouping, all options must be distinct arguments.\n\
          o All option arguments must be separated from the option by whitespace.\n\
-\n", PACKAGE, PACKAGE, PACKAGE, PACKAGE);
+\n", PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME);
 }
 
 enum MajorMode_t {
@@ -123,15 +123,16 @@ public:
   bool   verbose_flag;   // true if the verbose option was selected
   bool   version_flag;   // true if the version display option was selected
   bool   help_flag;      // true if the help display option was selected
-  const char* filename;  // filename to be processed
-  const char* write_filename;  // filename to write with val_write_flag
+  std::string filename;  // filename to be processed
+  std::string write_filename;  // filename to write with val_write_flag
   ui32_t chunk_count;
   MajorMode_t mode;      // MajorMode selector
 
   //
   CommandOptions(int argc, const char** argv) :
-    error_flag(true), order(""), verbose_flag(false), version_flag(false), help_flag(false),
-    filename(""), write_filename(""), chunk_count(0), mode(MMT_VALIDATE)
+    error_flag(true), order(""), verbose_flag(false),
+    version_flag(false), help_flag(false),
+    chunk_count(0), mode(MMT_VALIDATE)
   {
     //    order = "rand";
 
@@ -151,7 +152,7 @@ public:
              case 'c':
                mode = MMT_CREATE;
                TEST_EXTRA_ARG(i, 'c');
-               chunk_count = atoi(argv[i]);
+               chunk_count = Kumu::xabs(strtol(argv[i], 0, 10));
                break;
                
              case 'V': version_flag = true; break;
@@ -187,7 +188,7 @@ public:
          {
            if (argv[i][0] != '-' )
              {
-               if ( filename != "" )
+               if ( ! filename.empty() )
                  {
                    fprintf(stderr, "Extra filename found: %s\n", argv[i]);
                    return;
@@ -206,7 +207,7 @@ public:
     if ( help_flag || version_flag )
       return;
     
-    if ( strlen ( filename ) == 0 )
+    if ( filename.empty() )
       {
        fprintf(stderr, "Filename required.\n");
        return;
@@ -221,7 +222,7 @@ public:
       if ( strcmp(order, "") == 0 )
        order = "rand";
 
-    if ( strcmp ( filename, write_filename ) == 0 )
+    if ( filename == write_filename )
       {
        fprintf(stderr, "Output and input files must be different.\n");
        return;
@@ -382,7 +383,7 @@ randomize_list(read_list_t* read_list, ui32_t check_total)
 Result_t
 ReadValidateWriteLargeFile(CommandOptions& Options)
 {
-  assert(Options.write_filename);
+  assert(!Options.write_filename.empty());
   ui32_t  check_total = 0;
   ui32_t  write_total = 0;
   ui32_t  read_count = 0;
@@ -574,7 +575,7 @@ main(int argc, const char **argv)
 
   if ( Options.error_flag )
     {
-      fprintf(stderr, "There was a problem. Type %s -h for help.\n", PACKAGE);
+      fprintf(stderr, "There was a problem. Type %s -h for help.\n", PROGRAM_NAME);
       return 3;
     }