void read_exif_header(FILE *fp, unsigned char *buffer, bool *is_valid, bool *is_little_endian) { // SOI vread(buffer, 2, fp, is_valid); vcmp(SOI, buffer, 2, is_valid); // APP1 Marker vread(buffer, 2, fp, is_valid); vcmp(APP1_MARKER, buffer, 2, is_valid); // EXIF Identifier Code vseek(fp, 2, SEEK_CUR, is_valid); // Skip (APP1 Length) vread(buffer, 6, fp, is_valid); vcmp(EXIF_IDENT_CODE, buffer, 6, is_valid); // Byte Order vread(buffer, 2, fp, is_valid); if(*is_valid && memcmp(TIFF_LITTLE_ENDIAN, buffer, 2) == 0) *is_little_endian = true; else if(*is_valid && memcmp(TIFF_BIG_ENDIAN, buffer, 2) == 0) *is_little_endian = false; else *is_valid = false; // EXIF Fixed Code vread(buffer, 2, fp, is_valid); vrev(buffer, 2, is_valid, is_little_endian); vcmp(EXIF_FIXED_CODE, buffer, 2, is_valid); // 0th IFD Offset vread(buffer, 4, fp, is_valid); vrev(buffer, 4, is_valid, is_little_endian); // 0th IFD vseek(fp, todecimal(buffer, 4) - 8, SEEK_CUR, is_valid); // 0th IFD Entry Count vread(buffer, 2, fp, is_valid); vrev(buffer, 2, is_valid, is_little_endian); }
int main(int argc, char * argv[]){ //open and validate file. . . . . . . // // FILE *fp; char filename[25]; char line[LINE_SIZE]; int x=0, y=0; //zero out filename array // for(x=0;x<25;x++){ filename[x]=0; } //if no arguments taken at command line, print error // if ( argc != 2 ){ printf( "error\n"); return 0; } //copy filename in argv 1 to filename while((argv[1][y])!=0){ filename[y]=argv[1][y]; y++; } //start validation of file. . . . . // // //make sure valid filename. if not, print empty and return. if((fp = fopen(filename, "r"))==NULL){ printf("error\n"); return 0; } //check if file empty. if it is, print 0 and return. // if(fgets(line, LINE_SIZE, fp)==NULL){ printf("0\n"); return 0; } //end of opening and validation of file. . . . . . . //validation complete, open file fp = fopen(filename, "r"); int hexnum[16];//array where hex chars converted to individual int values are stored int i, j, k;//just for loops and stuf unsigned long long dec;//will store the decimal equivalent that will be passed2table //allocate array of pointers and set all to null // // hashTable = (struct hash *) calloc(ARR_SIZE, sizeof(struct hash)); for(i=0;i<ARR_SIZE;i++){ hashTable[i].head = NULL; } //start reading. . . . . // // while(fgets(line, LINE_SIZE, fp)!=NULL) { if(valid(line)==-1){ //printf("error\n"); ; }else{ //remove the 0x and pad with 000's to get 64-bit form stripandpad(line, valid(line)); //take each character in line and convert to hex equivalent // // for(k=0;k<16;k++){ hexnum[k]=convert(line[k]); } dec = todecimal(hexnum); insert(dec); }//end else }//end while loop printf("%li\n", finalCount); //cleanup. . . . . // // struct node *ptr; for(i=0;i<ARR_SIZE;i++){ while(hashTable[i].head!=NULL){ ptr=hashTable[i].head; hashTable[i].head=hashTable[i].head->next; free(ptr); } } free(hashTable); //end cleanup return 0; }
int main() { std::string sb_number; while (std::cin >> sb_number && sb_number != "0") { std::cout << todecimal(sb_number) << std::endl; } }