|
King of Portal
Join Date: Sep 2005
Posts: 403
Rep Power: 3 
|
Backup Search
My LCD laptop screen messed up again, and this prompted me to find a solution to keeping track of the backups I've made of my computer. I'm a habitual reformatter and start over from scratch. Needless to say, I have quite a few backup CDs and DVDs of my data. So I've created a search engine for the files I have archived.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ENTRIES 1
int main (void)
{
int i;
int n;
int perform;
char search[80];
char ***database;
database = (char ***) calloc(ENTRIES, sizeof(char **));
for(i = 0; i < ENTRIES; i++)
{
database[i] = (char **) calloc(ENTRIES * 3, sizeof(char*));
}
n = 0;
// database[n][0] = (char *) calloc(strlen("\0"), sizeof(char));
// strcpy(database[n][0], "\0");
// database[n][1] = (char *) calloc(strlen("\0"), sizeof(char));
// strcpy(database[n][1], "\0");
// database[n][2] = (char *) calloc(strlen("\0"), sizeof(char));
// strcpy(database[n][2], "\0");
// n++;
/////////////////
// DATABASE //
////////////////
database[n][0] = (char *) calloc(strlen("Backup 01\0"), sizeof(char));
strcpy(database[n][0], "Backup01\0");
database[n][1] = (char *) calloc(strlen("Contains a backup of various things.\0"), sizeof(char));
strcpy(database[n][1], "Contains a backup of various things.\0");
database[n][2] = (char *) calloc(strlen("backup, applications, games, etc.\0"), sizeof(char));
strcpy(database[n][2], "backup, applications, games, etc.\0");
n++;
////////////////////////////////////////////////////////////////////////////////////////////
printf("Grim Pirate's Backup Archive Search Engine\n\n");
printf("COMMANDS");
printf("\n !quit - terminate program");
printf("\n !about - program info\n\n");
while(1)
{
perform = 1;
printf("Please enter your search terms\n-> ");
gets(search);
if(strstr(search, "!quit"))
{
break;
}
if(strstr(search, "!about"))
{
printf("\nAuthor: The Grim Pirate");
printf("\nHomepage: http://grimpirate.t35.com/");
printf("\nVersion: 2006.06.02\n\n");
perform = 0;
}
if(perform)
{
printf("\n--------------------------------------------------------------------------------");
printf(" RESULTS\n");
printf("--------------------------------------------------------------------------------");
for(i = 0; i < ENTRIES; i++)
{
if(strstr(database[i][2], search))
{
printf("Location: ");
puts(database[i][0]);
printf("Description: ");
puts(database[i][1]);
}
else
{
printf("NONE\n");
}
}
printf("--------------------------------------------------------------------------------\n");
}
}
return (0);
} Eventually I plan it to work with text files. That way anybody can create the backups by following a standard text file format. For the time being though this is what I came up with and it works well enough for my needs. The database array stores three key things: location of the file, a description of the file, and some keywords relevant to the file. It only displays the location and description on the screen. To add more entries to the database, copy the commented database code, paste it in the database section, input the relevant info, and update the ENTRIES constant to the number of entries in your database. Of course, it's better to use this program sooner rather than later, 'cause then like myself you have to go back through all your backups and start indexing them. Which is gonna suck, but better late than never. I hope someone can find a use for the app.
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
|