Mercurial > msvpvf
view src/common.c @ 48:652343b56a60
Remove the need for <inttypes.h> and <stdbool.h>
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Sun, 22 May 2022 00:08:10 -0400 |
parents | 7cb4ca7cf257 |
children | fcd4b9fe957b |
line wrap: on
line source
#include <stdio.h> #include <stdint.h> void set_data(unsigned char magic[], uint16_t version, FILE* target) { int i; fseek(target, 0x46, SEEK_SET); fputc(version, target); for (i=0; i<=sizeof(*magic); ++i) { fseek(target, 0x18+i, SEEK_SET); fputc(magic[i], target); } } int copy_file(char* source_file, char* target_file) { char ch[4096]; FILE *source, *target; source = fopen(source_file, "rb"); if (source == NULL) return 1; target = fopen(target_file, "wb"); if (target == NULL) { fclose(source); return 1; } while (!feof(source)) { size_t b = fread(ch, 1, sizeof(ch), source); if (b) fwrite(ch, 1, b, target); } fclose(target); fclose(source); return 0; }