SMREmulator 1.0
ShingledMagneticRecordingEmulator

edidump.c

Go to the documentation of this file.
00001 
00009 #include <stdio.h>
00010 #include <stdint.h>
00011 #include <limits.h>
00012 #include <unistd.h>
00013 #include <string.h>
00014 #include <stdlib.h>
00015 #include <errno.h>
00016 
00017 #include <emudiskimg.h>
00018 #include <emudebug.h>
00019 #include <emulator.h>
00020 #include <ediversion.h>
00021 
00022 
00023 
00024 /* -- Constants -- */
00025 const char* usage = "edidump <EDI filename>";
00026 
00027 
00028 
00029 /* -- Function Implementations -- */
00030 
00031 int main(int argc, char** argv) {
00032         int fd;
00033 
00034 
00035         /* Ensure that the EDI file path was passed as an argument */
00036         if (argc < 2) {
00037                 fprintf(stderr, "%s\n\n", usage);
00038                 exit(EXIT_FAILURE);
00039         }
00040         dbg("Parsed arguments:\n\tFile: %s\n", argv[1]);
00041 
00042 
00043         /* Initialize the EDI Versioning module */
00044         if (ediv_init() < 0) {
00045                 printf("Failed to initialize Versioning Module!\n");
00046                 exit(EXIT_FAILURE);
00047         }
00048 
00049 
00050         /* Open the EDI file */
00051         if ((fd = edi_open(argv[1])) < 0) {
00052                 printf("Unable to open EDI file: %s\n", strerror(errno));
00053                 exit(EXIT_FAILURE);
00054         }
00055 
00056 
00057         /* Dump the EDI meta data */
00058         if (edi_dump(fd) < 0)
00059                 printf("Unable to dump EDI file metadata: %s\n", strerror(errno));
00060 
00061         /* Close the open edi file */
00062         edi_close(fd);
00063         return EXIT_SUCCESS;
00064 }
00065