th105_repex.zip/th105_repex.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
int version = 0x6A;
void SetAppDir(void){
char str[256];
int i;
GetModuleFileName(NULL,str,256);
i = strlen(str)-1;
while(str[i] != '\\' && str[i] != '/' && i > 0)i--;
str[i] = '\0';
SetCurrentDirectory(str);
}
void loadini(void){
FILE *fp;
char str[256],*s;
int i;
fp = fopen("setting.ini","r");
if(fp == NULL)return;
while(NULL != fgets(str,256,fp)){
i = 0;
while(str[i] == ' ' || str[i] == '\t')i++;
if(str[i] == '/' || str[i] == ';' || str[i] == ':' || str[i] == '\n')continue;
if(!strncmp(&str[i],"version",7)){
i+=7;
while(str[i] == ' ' || str[i] == '\t')i++;
if(str[i] != '=')continue;
i++;
while(str[i] == ' ' || str[i] == '\t')i++;
s = &str[i];
while(*s >= '0' && *s <= '9')s++;
*s = '\0';
version = atoi(&str[i]);
}
}
fclose(fp);
}
main(int argc,char *argv[]){
int loop,ver,count;
FILE *fp;
SetAppDir();
loadini();
loop = 1;
count = 0;
while(loop < argc){
fp = fopen(argv[loop],"rb+");
fread(&ver,4,1,fp);
if(version != ver){
fseek(fp,0,SEEK_SET);
fwrite(&version,4,1,fp);
count++;
}
fclose(fp);
loop++;
}
printf("%d個中%d個変換しました\n",argc-1,count);
getchar();
return 0;
}