00001
00002
00003
00004
00005
00006
00007
00008 #include "giis.h"
00009
00010
00011
00012
00013
00014 int main(int argc,char *argv[])
00015 {
00016 int i=0,ans=-1,fp,line=1;
00017 char a,x;
00018 char sumkey[]="Enter Any key to Continue :-)";
00019
00020 do{
00021 if(argc>2){
00022 printf("giis : invalid option \n");
00023 printf("Type 'giis -h' for help \n");
00024 return 1;
00025 }
00026
00027
00028
00029 if(argc==2){
00030 if(strcmp(argv[1],"-m")==0)
00031 ans=444;
00032 if(strcmp(argv[1],"-i")==0)
00033 ans=0;
00034 if(strcmp(argv[1],"-u")==0)
00035 ans=1;
00036 if(strcmp(argv[1],"-g")==0)
00037 ans=2;
00038 if(strcmp(argv[1],"-d")==0)
00039 ans=3;
00040 if(strcmp(argv[1],"-f")==0)
00041 ans=4;
00042 if(strcmp(argv[1],"-U")==0)
00043 ans=5;
00044 if(strcmp(argv[1],"-a")==0)
00045 ans=6;
00046 if(strcmp(argv[1],"-t")==0)
00047 ans=7;
00048 if(strcmp(argv[1],"-q")==0)
00049 ans=8;
00050
00051 if(strcmp(argv[1],"-h")==0){
00052 printf("\nUsage: giis [OPTION]\n");
00053 printf("\nPossible options available with giis :");
00054 printf("\n -a\t\t Info. about the author.");
00055 printf("\n -d\t\t Displays your file system informations.");
00056 printf("\n -f\t\t Displays giis system files.");
00057 printf("\n -g\t\t Recovers the Given or all deleted files.");
00058 printf("\n -h\t\t Prints this menu.");
00059 printf("\n -i\t\t Will perform installation of giis.");
00060 printf("\n -m\t\t Menu based user interaction.");
00061 printf("\n -q\t\t Exit giis");
00062 printf("\n -t\t\t Some quotes and thoughts.");
00063 printf("\n -u\t\t Updates giis to reflect current status.");
00064 printf("\n -U\t\t Uninstalls giis.\n");
00065 printf("\nReport bugs to <lakshmipathi.g@gmail.com>\n");
00066 return 1;
00067 }
00068 if((ans!=444) && (ans<0 || ans>8)){
00069 printf("giis : invalid option \n");
00070 printf("Type 'giis -h' for help.\n");
00071 return 1;
00072 }
00073
00074
00075 }
00076 if(argc==1)
00077 ans=444;
00078
00079 if(ans==444){
00080 system("clear");
00081 printf("\n\t\t ===================================================");
00082 printf("\n\t\t gET iT i sAY. giis - Ext3/Ext2 File Undelete Tool ");
00083 printf("\n\t\t ===================================================\n");
00084 printf("\n\tPress 0 : Install \n\tPress 1 : Update Now\n\tPress 2 : File Recovery");
00085 printf("\n\tPress 3 : Your File System Details");
00086 printf("\n\tPress 4 : giis File Details \n\tPress 5 : Uninstall");
00087 printf("\n\tPress 6 : About giis ");
00088 printf("\n\tPress 7 : Quotes \n\tPress 8 : Exit");
00089 printf("\n\n\t\tEnter Your choice : ");
00090 scanf("%d",&ans);
00091 }
00092
00093 if(ans==4){
00094 fp=open(INSTALL_DIR1,0);
00095 if(errno==ENOENT){
00096 printf("\n\t\tgiis Not installed...\n");
00097 printf("\t\t\t...So install giis and then try this..\n\n ");
00098 close(fp);
00099 return 1;
00100 }
00101 close(fp);
00102
00103 i=read_dir_info_file();
00104 CHECK
00105 printf("\n File Info File");
00106 i=read_file_info_file();
00107 CHECK
00108
00109 return 1;
00110 }
00111
00112
00113 if(ans==8){
00114 printf("\n\t Quiting giis....");
00115 printf("\n\n\t Bye...Bye...!!!\n\n");
00116 return 1;
00117 }
00118
00119 if(ans==5){
00120 i=remove_giis();
00121 CHECK
00122 return 1;
00123 }
00124
00125 if(ans==6){
00126
00127 system("clear");
00128 fp=open("/giis/hai",0);
00129 CHECK
00130 i=read(fp,&a,1);
00131 CHECK
00132 while(i>0){
00133 write(1,&a,1);
00134 i=read(fp,&a,1);
00135 }
00136 close(fp);
00137 return 1;
00138 }
00139 if(ans==7){
00140
00141 system("clear");
00142 fp=open("/giis/quotes",0);
00143 CHECK
00144 i=read(fp,&a,1);
00145 CHECK
00146 while(i>0){
00147 if(a=='\n')
00148 line++;
00149 write(1,&a,1);
00150 i=read(fp,&a,1);
00151 if((line%24)==0){
00152 line++;
00153 write(1,sumkey,strlen(sumkey));
00154 read(0,&x,1);
00155 }
00156 }
00157 close(fp);
00158 return 1;
00159 }
00160
00161
00162
00163
00164 }while(!(ans>=0 && ans<=8));
00165
00166
00167 if(ans==0){
00168 install=1;
00169 fp=open(INSTALL_DIR1,0);
00170 if(fp!=-1){
00171 printf("\n\t\tgiis already installed in your system...\n");
00172 printf("\t\tTry giis -U or manually delete /giis to install freshly...\n ");
00173 close(fp);
00174 return 2;
00175 }
00176 }
00177
00178 if(ans==1 || ans==2 || ans==3){
00179 fp=open(INSTALL_DIR1,0);
00180 if(errno==ENOENT){
00181 printf("\n\t\tgiis Not installed...\n");
00182 printf("\t\t\t...So install giis and then try this ;)\n ");
00183 close(fp);
00184 return 1;
00185 }
00186 close(fp);
00187 }
00188
00189 printf("\nSearching for file system....");
00190 if(init()==-1){
00191 printf("\n\nFile System not is Initialized....Aborting....\n");
00192 exit(1);
00193 }
00194
00195 if(ans==0)
00196 {
00197 install=1;update_file=0;
00198 update_dir=0;
00199 fs.inode_number=ROOT_INODE;
00200 i=find_inode_offset();
00201 CHECK
00202
00203 i=read_inode();
00204 CHECK
00205
00206 i=set_content_offset();
00207 CHECK
00208 if(dir){
00209 i=read_dir();
00210 CHECK
00211 i=show_dir();
00212 CHECK
00213 }
00214 }
00215
00216
00217
00218 if(ans==3){
00219 fs.inode_number=ROOT_INODE;
00220 i=find_inode_offset();
00221 CHECK
00222 i=fs_display();
00223 CHECK
00224 return 1;
00225 }
00226
00227
00228 if(ans==0 || ans==1){
00229 if(ans==1){
00230 install=0;
00231 update_file=1;update_dir=1;
00232 }
00233
00234 i=search4dir();
00235 CHECK
00236 if(ans==0){
00237 get_sample_data();
00238 printf("\n\n\t\tgiis - Installtion completed...");
00239 }
00240 }
00241
00242
00243 if(ans==2){
00244
00245
00246 printf("\n\nHow do you want to recover files?");
00247 printf("\n\t Press 0 : Get All User files ");
00248 printf("\n\t Press 1 : Get Specific User files");
00249 printf("\n\t Press 2 : force giis - giis dump");
00250 printf("\n\t Press 3 : Get By File Format\n");
00251 printf("\n\t\tEnter Your Choice : ");
00252 scanf("%d",&ans);
00253
00254 if(ans>=0 && ans <=3)
00255 use_uid=ans;
00256 else{
00257 printf("\n\n\t\tPlease Enter correct Choice");
00258 return 1;
00259 }
00260
00261 install=0;
00262 get_it();
00263 }
00264 return 1;
00265 }