Well, I'm so proud of my baby. It's still in testing. If you see any bugs let me know. It's a simple encryption program for Windows. I had dome some work with .so in Linux, so I figured I'd give .dll files a shot. Here is all the code, ans a Makefile. I compliled it with MinGW (a GCC port for WIndows) with no warnings other than about a def file.
main.c:
main.h:
fexist.h:
fexist.c:
main.c:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "main.h"
#include "xordll.h"
int main(int argc, char *argv[])
{
int choice = -9;
choice = menu();
switch (choice)
{
case 1:
{
xordlle();
main(argc, argv);
break;
}
case 2:
{
xordlld();
main(argc, argv);
break;
}
case 3:
{
puts("Not yet implemented");
exit(EXIT_FAILURE);
break;
}
case 4:
{
puts("Good-bye");
puts("www.kgivler.com/KGD");
puts("Coded by PunkCow");
exit(EXIT_SUCCESS);
break;
}
default:
{
fprintf(stderr, "This line should never be seen! Quitting\n");
exit(EXIT_FAILURE);
break;
}
}
exit(EXIT_SUCCESS);
}
int menu(void)
{
int choice = -2;
while(choice < 1 || choice > 4)
{
printf("\nKGDenc version %s\n", VER);
puts("\n1.) XOR encrypt");
puts("2.) XOR decrypt");
puts("3.) About");
puts("4.) Exit");
printf("\nPlease make a selection: ");
scanf("%d", &choice);
}
return choice;
}
main.h:
Code:
#if defined( MAIN_H_ )
/* included */
#else
#define MAIN_H_
#define VER "0.2b (unstable beta)"
int menu(void);
const char about[] = "KGDEnc coded by PunkCow";
#endif
fexist.h:
Code:
#if defined( FEXIST_H )
/* already included */
#else
#define FEXIST_H
int file_exists(char *filename);
#endif
fexist.c:
Code:
#include <stdio.h>
#include <stdlib.h>
#include "fexist.h"
int file_exists(char *filename)
{
/* Returns TRUE if exists, FALSE if not */
FILE *fp;
if ((fp = fopen(filename, "r")) == NULL)
return 0;
else
{
fclose(fp);
return 1;
}
}