Commits

Wez Furlong committed 9770427

more fun with int types

Comments (0)

Files changed (5)

src/AP_AtomExtracts.cpp

 				}
 				
 				//codec, language
-				fprintf(stdout, "  %s  %s   %llu", uint32tochar4(track_info.track_codec, uint32_buffer), track_info.unpacked_lang, track_info.sample_aggregate);
+				fprintf(stdout, "  %s  %s   %" PRIu64 "", uint32tochar4(track_info.track_codec, uint32_buffer), track_info.unpacked_lang, track_info.sample_aggregate);
 				
 				if (track_info.encoder_name[0] != 0 && track_info.contains_esds) {
 					purge_extraneous_characters(track_info.encoder_name);

src/AP_ID3v2_tags.cpp

 					playcount = 1;
 				}
 			} else {
-				sscanf(frame_payload, "%llu", &playcount);
+				sscanf(frame_payload, "%" PRIu64 "", &playcount);
 			}
 			
 			if (playcount < 268435455) {
 							popm_playcount = 1;
 						}
 					} else {
-						sscanf(adjunct_payload->dataArg, "%llu", &popm_playcount);
+						sscanf(adjunct_payload->dataArg, "%" PRIu64 "", &popm_playcount);
 					}
 				}
 			}

src/AP_MetadataListings.cpp

 								break;
 							}
 							case 8 : {
-								fprintf(stdout, "%llu\n", UInt64FromBigEndian(data_payload) );
+								fprintf(stdout, "%" PRIu64 "\n", UInt64FromBigEndian(data_payload) );
 								break;
 							}
 					}
 		}
 		if (supplemental_info && 0x04) { //PRINT_PADDING_SPACE
 			if (!moov_atom_was_mooved) {
-				fprintf(stdout, "padding available: %llu bytes\n", dynUpd.padding_bytes);
+				fprintf(stdout, "padding available: %" PRIu64 " bytes\n", dynUpd.padding_bytes);
 			} else {
 				fprintf(stdout, "padding available: 0 (reorg)\n");
 			}
 		}
 		if (supplemental_info && 0x08 && dynUpd.moov_udta_atom != NULL) { //PRINT_USER_DATA_SPACE
-			fprintf(stdout, "user data space: %llu\n", dynUpd.moov_udta_atom->AtomicLength);
+			fprintf(stdout, "user data space: %" PRIu64 "\n", dynUpd.moov_udta_atom->AtomicLength);
 		}
 		if (supplemental_info && 0x10) { //PRINT_USER_DATA_SPACE
 			fprintf(stdout, "media data space: %u\n", APar_ProvideTallyForAtom("mdat") );
 			if (target_frameinfo->ID3v2_Frame_Fields->field_length == 4) {
 				fprintf(stdout, ": %u\n", syncsafe32_to_UInt32(target_frameinfo->ID3v2_Frame_Fields->field_string) );
 			} else if (target_frameinfo->ID3v2_Frame_Fields->field_length > 4) {
-				fprintf(stdout, ": %llu\n", syncsafeXX_to_UInt64(target_frameinfo->ID3v2_Frame_Fields->field_string, target_frameinfo->ID3v2_Frame_Fields->field_length) );
+				fprintf(stdout, ": %" PRIu64 "\n", syncsafeXX_to_UInt64(target_frameinfo->ID3v2_Frame_Fields->field_string, target_frameinfo->ID3v2_Frame_Fields->field_length) );
 			}
 		
 		} else if (target_frameinfo->ID3v2_FrameType == ID3_POPULAR_FRAME) {
 				if ((target_frameinfo->ID3v2_Frame_Fields+2)->field_length == 4) {
 					fprintf(stdout, "; playcount=%u\n", syncsafe32_to_UInt32((target_frameinfo->ID3v2_Frame_Fields+2)->field_string));
 				} else if ((target_frameinfo->ID3v2_Frame_Fields+2)->field_length > 4) {
-					fprintf(stdout, "; playcount=%llu\n", syncsafeXX_to_UInt64((target_frameinfo->ID3v2_Frame_Fields+2)->field_string, (target_frameinfo->ID3v2_Frame_Fields+2)->field_length));
+					fprintf(stdout, "; playcount=%" PRIu64 "\n", syncsafeXX_to_UInt64((target_frameinfo->ID3v2_Frame_Fields+2)->field_string, (target_frameinfo->ID3v2_Frame_Fields+2)->field_length));
 				} else {
 					fprintf(stdout, "\n"); //don't know what it was supposed to be, so skip it
 				}
 		
 		if (thisAtom->AtomicLength == 0) {
 			fprintf(stdout,
-				"%sAtom %s @ %llu of size: %llu (%llu*), ends @ %llu\n",
+				"%sAtom %s @ %" PRIu64 " of size: %" PRIu64 " (%" PRIu64 "*), ends @ %" PRIu64 "\n",
 				tree_padding, twenty_byte_buffer, thisAtom->AtomicStart,
 				( (uint64_t)file_size - thisAtom->AtomicStart),
 				thisAtom->AtomicLength, (uint64_t)file_size );
 				"\t\t\t (*)denotes length of atom goes to End-of-File\n");
 		
 		} else if (thisAtom->AtomicLength == 1) {
-			fprintf(stdout, "%sAtom %s @ %llu of size: %llu (^), ends @ %llu\n", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLengthExtended, (thisAtom->AtomicStart + thisAtom->AtomicLengthExtended) );
+			fprintf(stdout, "%sAtom %s @ %" PRIu64 " of size: %" PRIu64 " (^), ends @ %" PRIu64 "\n", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLengthExtended, (thisAtom->AtomicStart + thisAtom->AtomicLengthExtended) );
 			fprintf(stdout, "\t\t\t (^)denotes a 64-bit atom length\n");
 			
 		//uuid atoms of any sort
 			if (UnicodeOutputStatus == WIN32_UTF16) {
 				fprintf(stdout, "%sAtom uuid=", tree_padding);
 				APar_fprintf_UTF8_data(twenty_byte_buffer);
-				fprintf(stdout, " @ %llu of size: %llu, ends @ %llu\n", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, " @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			} else {
-				fprintf(stdout, "%sAtom uuid=%s @ %llu of size: %llu, ends @ %llu\n", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, "%sAtom uuid=%s @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			}
 			
 		} else if (thisAtom->AtomicClassification == EXTENDED_ATOM && thisAtom->uuid_style != UUID_DEPRECATED_FORM) {
 			if (thisAtom->uuid_style == UUID_AP_SHA1_NAMESPACE) {
 				fprintf(stdout, "%sAtom uuid=", tree_padding);
 				APar_print_uuid( (ap_uuid_t*)thisAtom->AtomicName, false);
-				fprintf(stdout, "(APuuid=%s) @ %llu of size: %llu, ends @ %llu\n", twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, "(APuuid=%s) @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			} else {
 				fprintf(stdout, "%sAtom uuid=", tree_padding);
 				APar_print_uuid( (ap_uuid_t*)thisAtom->AtomicName, false);
-				fprintf(stdout, " @ %llu of size: %llu, ends @ %llu\n", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, " @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			}
 
 		//3gp assets (most of them anyway)
 			if (UnicodeOutputStatus == WIN32_UTF16) {
 				fprintf(stdout, "%sAtom ", tree_padding);
 				APar_fprintf_UTF8_data(twenty_byte_buffer);
-				fprintf(stdout, " [%s] @ %llu of size: %llu, ends @ %llu\n", unpacked_lang, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, " [%s] @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", unpacked_lang, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			} else {
-				fprintf(stdout, "%sAtom %s [%s] @ %llu of size: %llu, ends @ %llu\n", tree_padding, twenty_byte_buffer, unpacked_lang, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, "%sAtom %s [%s] @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "\n", tree_padding, twenty_byte_buffer, unpacked_lang, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			}
 
 		//all other atoms (the bulk of them will fall here)
 			if (UnicodeOutputStatus == WIN32_UTF16) {
 				fprintf(stdout, "%sAtom ", tree_padding);
 				APar_fprintf_UTF8_data(twenty_byte_buffer);
-				fprintf(stdout, " @ %llu of size: %llu, ends @ %llu", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, " @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "", thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			} else {
-				fprintf(stdout, "%sAtom %s @ %llu of size: %llu, ends @ %llu", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
+				fprintf(stdout, "%sAtom %s @ %" PRIu64 " of size: %" PRIu64 ", ends @ %" PRIu64 "", tree_padding, twenty_byte_buffer, thisAtom->AtomicStart, thisAtom->AtomicLength, (thisAtom->AtomicStart + thisAtom->AtomicLength) );
 			}
 
 			if (thisAtom->AtomicContainerState == UNKNOWN_ATOM_TYPE) {
 	}
 	
 	fprintf(stdout, "------------------------------------------------------\n");
-	fprintf(stdout, "Total size: %llu bytes; ", (uint64_t)file_size);
+	fprintf(stdout, "Total size: %" PRIu64 " bytes; ", (uint64_t)file_size);
 	fprintf(stdout, "%i atoms total.\n", atom_number-1);
-	fprintf(stdout, "Media data: %llu bytes; %llu bytes all other atoms (%2.3lf%% atom overhead).\n", 
+	fprintf(stdout, "Media data: %" PRIu64 " bytes; %" PRIu64 " bytes all other atoms (%2.3lf%% atom overhead).\n", 
 		mdatData, file_size - mdatData,
 		(double)(file_size - mdatData)/(double)file_size * 100.0 );
 
 		//APar_DetermineDynamicUpdate(true); //gets the size of the padding
 		APar_Optimize(true); //just to know if 'free' atoms can be considered padding, or (in the case of say a faac file) it's *just* 'free'
 		if (!moov_atom_was_mooved) {
-			fprintf(stdout, " Padding available: %llu bytes.", dynUpd.padding_bytes);
+			fprintf(stdout, " Padding available: %" PRIu64 " bytes.", dynUpd.padding_bytes);
 		}
 	}
 	if (gapless_void_padding > 0) {
-		fprintf(stdout, "\nGapless playback null space at end of file: %llu bytes.", gapless_void_padding);
+		fprintf(stdout, "\nGapless playback null space at end of file: %" PRIu64 " bytes.", gapless_void_padding);
 	}
 	fprintf(stdout, "\n------------------------------------------------------\n");
 	ShowVersionInfo();

src/AtomicParsley.cpp

 			modified_atoms = true;
 			AtomicInfo* desiredAtom = APar_FindAtom(artwork_atom, true, SIMPLE_ATOM, 0);
 			AtomicInfo sample_data_atom = { 0 };
-			short parent_atom = desiredAtom->AtomicNumber; //used on Darwin adding a 2nd image (the original)
+
+#if defined (DARWIN_PLATFORM)			
+			// used on Darwin adding a 2nd image (the original)
+			short parent_atom = desiredAtom->AtomicNumber;
+#endif
+
 			APar_CreateSurrogateAtom(&sample_data_atom, "data", 6, VERSIONED_ATOM, 0, NULL, 0);
 			desiredAtom = APar_CreateSparseAtom(&sample_data_atom, desiredAtom, APar_FindLastChild_of_ParentAtom(desiredAtom->AtomicNumber) );
 
-	#if defined (DARWIN_PLATFORM)			
+#if defined (DARWIN_PLATFORM)			
 			//determine if any picture preferences will impact the picture file in any way
 			myPicturePrefs = APar_ExtractPicPrefs(env_PicOptions);
 
 			}
 			free(resized_filepath);
 			resized_filepath=NULL;
-	#else
+#else
 			//perhaps some libjpeg based resizing/modification for non-Mac OS X based platforms
 			APar_MetaData_atomArtwork_Init(desiredAtom->AtomicNumber, artworkPath);
-	#endif
+#endif
 		}
 		APar_FlagMovieHeader();
 	} ////end if (metadata_style == ITUNES_STYLE)
 			if (parsedAtoms[iter].AtomicData == NULL) {
 				fprintf(stderr, "AtomicParsley error: an atom was detected that presents as larger than filesize. Aborting. %c\n", '\a');
 #if defined (_MSC_VER) /* apparently, long long is forbidden there*/
-				fprintf(stderr, "atom %s is %u bytes long which is greater than the filesize of %llu\n", parsedAtoms[iter].AtomicName, parsedAtoms[iter].AtomicLength, (long unsigned int)file_size);
+				fprintf(stderr, "atom %s is %u bytes long which is greater than the filesize of %" PRIu64 "\n", parsedAtoms[iter].AtomicName, parsedAtoms[iter].AtomicLength, (long unsigned int)file_size);
 #else
-				fprintf(stderr, "atom %s is %llu bytes long which is greater than the filesize of %llu\n", parsedAtoms[iter].AtomicName, parsedAtoms[iter].AtomicLength, file_size);
+				fprintf(stderr, "atom %s is %" PRIu64 " bytes long which is greater than the filesize of %" PRIu64 "\n", parsedAtoms[iter].AtomicName, parsedAtoms[iter].AtomicLength, file_size);
 #endif
 				exit(1); //its conceivable to repair such an off length by the surrounding atoms constrained by file_size - just not anytime soon; probly would catch a foobar2000 0.9 tagged file
 			}
 	if (percentage_difference < 90 && file_size > 300000) { //only kick in when files are over 300k & 90% of the size
 		fprintf(stderr, "AtomicParsley error: total existing atoms present as larger than filesize. Aborting. %c\n", '\a');
 		//APar_PrintAtomicTree();
-		fprintf(stdout, "%i %llu\n", percentage_difference, simple_tally);
+		fprintf(stdout, "%i %" PRIu64 "\n", percentage_difference, simple_tally);
 		exit(1);
 	}
 	
 			fclose(temp_file);
 			remove(temp_file_name);
 			fprintf(stdout,
-				"AtomicParsley error: the insufficient space to retag the source file (%llu!=%llu).\nExiting.\n", metadata_len, dynUpd.first_mdat_atom->AtomicStart - dynUpd.initial_update_atom->AtomicStart);
+				"AtomicParsley error: the insufficient space to retag the source file (%" PRIu64 "!=%" PRIu64 ").\nExiting.\n", metadata_len, dynUpd.first_mdat_atom->AtomicStart - dynUpd.initial_update_atom->AtomicStart);
 			exit(1);		
 		}
 		

src/AtomicParsley.h

 
 #include "config.h"
 
+#define __STDC_LIMIT_MACROS
+#define __STDC_FORMAT_MACROS
+#define __STDC_CONSTANT_MACROS
+
+#include <sys/types.h>
+#ifdef __GLIBC__
+# define HAVE_LROUNDF 1
+#endif
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include <sys/types.h>
 #if HAVE_SYS_TIME_H
 # include <sys/time.h>
 #endif
 # include "extras/getopt.h"
 #endif
 
+#ifndef PRIu64
+# define PRIu64 "llu"
+#endif
+
 
 #if defined (_WIN32) || defined (_MSC_VER)
 #define MAXPATHLEN 255