mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-12 17:32:30 -04:00
game folder "just" compiles (not link)
This commit is contained in:
parent
13d3908273
commit
1b0f7fe0c2
135 changed files with 2161 additions and 2336 deletions
66
game/encrypt.c
Normal file
66
game/encrypt.c
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <mem.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
FILE *source,*target;
|
||||
|
||||
void encrypt_file(FILE *sr,FILE *tg)
|
||||
{
|
||||
int i,j,last=0;
|
||||
|
||||
i=getc(sr);
|
||||
while (i!=EOF)
|
||||
{
|
||||
j=i-last;
|
||||
last=i;
|
||||
putc(j,tg);
|
||||
i=getc(sr);
|
||||
}
|
||||
}
|
||||
|
||||
void open_files(char *src,char *tgr)
|
||||
{
|
||||
if (tgr==NULL)
|
||||
{
|
||||
char *c,*d;
|
||||
tgr=alloca(strlen(src)+5);
|
||||
strcpy(tgr,src);
|
||||
c=strrchr(tgr,'\\');
|
||||
d=strrchr(tgr,'.');
|
||||
if (c>d) d=strchr(tgr,0);
|
||||
strcpy(d,".ENC");
|
||||
}
|
||||
source=fopen(src,"rb");
|
||||
target=fopen(tgr,"wb");
|
||||
}
|
||||
|
||||
void close_files()
|
||||
{
|
||||
fclose(source);
|
||||
fclose(target);
|
||||
}
|
||||
|
||||
|
||||
char main(int argc,char **argv)
|
||||
{
|
||||
if (argc<2)
|
||||
{
|
||||
puts("Pouziti: ENCRYPT zdroj.ext [cil.ext] \n"
|
||||
"\n"
|
||||
"Pokud nezadas cil, doplni se zdroj s koncovkou .enc\n"
|
||||
"Nikdy nezadavej pouze cestu jako cil. Vzdycky uved jmeno!");
|
||||
return 0;
|
||||
}
|
||||
if (argc==2) open_files(argv[1],NULL);
|
||||
else open_files(argv[1],argv[2]);
|
||||
if (source==NULL)
|
||||
{puts("Nemuzu najit zdrojovy soubor\n");return 1;};
|
||||
if (target==NULL)
|
||||
{puts("Nemuzu otevrit cil pro zapis\n");return 1;};
|
||||
encrypt_file(source,target);
|
||||
close_files();
|
||||
puts("Ok.");
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue