fix bug in MD5 sum printing
[flac.git] / src / metaflac / main.c
index e3ebdf0..4f3b56a 100644 (file)
@@ -33,17 +33,19 @@ more powerful operations yet to add:
 #include <stdlib.h>
 #include <string.h>
 
-#if HAVE_GETOPT_LONG
+#if 0
+/*[JEC] was:#if HAVE_GETOPT_LONG*/
+/*[JEC] see flac/include/share/getopt.h as to why the change */
 #  include <getopt.h>
 #else
 #  include "share/getopt.h"
 #endif
 
 /*
-   getopt format struct; note we don't use short options so we just
+   FLAC__share__getopt format struct; note we don't use short options so we just
    set the 'val' field to 0 everywhere to indicate a valid option.
 */
-static struct option long_options_[] = {
+static struct FLAC__share__option long_options_[] = {
        /* global options */
     { "preserve-modtime", 0, 0, 0 },
     { "with-filename", 0, 0, 0 },
@@ -304,10 +306,10 @@ FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options)
     int option_index = 1;
        FLAC__bool had_error = false;
 
-    while ((ret = getopt_long(argc, argv, "", long_options_, &option_index)) != -1) {
+    while ((ret = FLAC__share__getopt_long(argc, argv, "", long_options_, &option_index)) != -1) {
         switch (ret) {
             case 0:
-                               had_error |= !parse_option(option_index, optarg, options);
+                               had_error |= !parse_option(option_index, FLAC__share__optarg, options);
                 break;
                        case '?':
                        case ':':
@@ -320,22 +322,22 @@ FLAC__bool parse_options(int argc, char *argv[], CommandLineOptions *options)
     }
 
        if(options->prefix_with_filename == 2)
-               options->prefix_with_filename = (argc - optind > 1);
+               options->prefix_with_filename = (argc - FLAC__share__optind > 1);
 
-       if(optind >= argc && !options->show_long_help) {
+       if(FLAC__share__optind >= argc && !options->show_long_help) {
                fprintf(stderr,"ERROR: you must specify at least one FLAC file;\n");
                fprintf(stderr,"       metaflac cannot be used as a pipe\n");
                had_error = true;
        }
 
-       options->num_files = argc - optind;
+       options->num_files = argc - FLAC__share__optind;
 
        if(options->num_files > 0) {
                unsigned i = 0;
                if(0 == (options->filenames = malloc(sizeof(char *) * options->num_files)))
                        die("out of memory allocating space for file names list");
-               while(optind < argc)
-                       options->filenames[i++] = local_strdup(argv[optind++]);
+               while(FLAC__share__optind < argc)
+                       options->filenames[i++] = local_strdup(argv[FLAC__share__optind++]);
        }
 
        if(options->args.checks.num_major_ops > 0) {
@@ -1482,9 +1484,9 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
                        PPR; printf("  total samples: %llu\n", block->data.stream_info.total_samples);
                        PPR; printf("  MD5 signature: ");
                        for(i = 0; i < 16; i++) {
-                               PPR; printf("%02x", block->data.stream_info.md5sum[i]);
+                               printf("%02x", (unsigned)block->data.stream_info.md5sum[i]);
                        }
-                       PPR; printf("\n");
+                       printf("\n");
                        break;
                case FLAC__METADATA_TYPE_PADDING:
                        /* nothing to print */
@@ -1506,7 +1508,12 @@ void write_metadata(const char *filename, FLAC__StreamMetadata *block, unsigned
                case FLAC__METADATA_TYPE_SEEKTABLE:
                        PPR; printf("  seek points: %u\n", block->data.seek_table.num_points);
                        for(i = 0; i < block->data.seek_table.num_points; i++) {
-                               PPR; printf("    point %d: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
+                               if(block->data.seek_table.points[i].sample_number != FLAC__STREAM_METADATA_SEEKPOINT_PLACEHOLDER) {
+                                       PPR; printf("    point %d: sample_number=%llu, stream_offset=%llu, frame_samples=%u\n", i, block->data.seek_table.points[i].sample_number, block->data.seek_table.points[i].stream_offset, block->data.seek_table.points[i].frame_samples);
+                               }
+                               else {
+                                       PPR; printf("    point %d: PLACEHOLDER\n", i);
+                               }
                        }
                        break;
                case FLAC__METADATA_TYPE_VORBIS_COMMENT: