Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

lcnames.cpp

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2004  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #include <stdio.h>
00024 #include <dirent.h>
00025 #include <string.h>
00026 #include <unistd.h>
00027 #include <sys/stat.h>
00028 
00029 
00030 void strlwr(char *s)
00031 {
00032         for (size_t i = 0; i < strlen(s); i++)
00033         {
00034                 if (s[i] >= 'A' && s[i] <= 'Z')
00035                         s[i] = s[i] | 32;
00036         }
00037 }
00038 
00039 
00040 void zz(char *fn)
00041 {
00042         FILE *fil;
00043         FILE *fil2;
00044         size_t i;
00045         char fn_lc[256];
00046         char fntmp[256];
00047 
00048         printf("%s\n",fn);
00049 
00050         for (i = 0; i < strlen(fn); i++)
00051         {
00052                 if (fn[i] >= 'A' && fn[i] <= 'Z')
00053                         fn_lc[i] = fn[i] | 32;
00054                 else
00055                         fn_lc[i] = fn[i];
00056         }
00057         fn_lc[i] = 0;
00058         if (strcmp(fn,fn_lc))
00059         {
00060                 rename(fn,fn_lc);
00061         }
00062         sprintf(fntmp,"%s.tmp",fn_lc);
00063         if ((fil = fopen(fn_lc,"rt")) != NULL)
00064         {
00065                 char slask[1000];
00066                 fil2 = fopen(fntmp,"wt");
00067                 fgets(slask,1000,fil);
00068                 while (!feof(fil))
00069                 {
00070                         while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
00071                         {
00072                                 slask[strlen(slask) - 1] = 0;
00073                         }
00074                         if (!strncmp(slask,"#include",8))
00075                         {
00076                                 strlwr(slask);
00077                         }
00078                         fprintf(fil2,"%s\n",slask);
00079                         //
00080                         fgets(slask,1000,fil);
00081                 }
00082                 fclose(fil);
00083                 fclose(fil2);
00084                 unlink(fn_lc);
00085                 rename(fntmp,fn_lc);
00086         }
00087 }
00088 
00089 
00090 int main(int argc,char *argv[])
00091 {
00092         DIR *dir;
00093         bool ok = false;
00094         struct stat st;
00095 
00096         for (int i = 1; i < argc; i++)
00097                 if (!strcmp(argv[i],"-ok"))
00098                         ok = true;
00099         if ((dir = opendir(".")) != NULL)
00100         {
00101                 struct dirent *p = readdir(dir);
00102                 while (p)
00103                 {
00104                         stat(p -> d_name, &st);
00105 //                      printf(" type: %08x  name: %s\n",st.st_mode,filename); //p -> d_name);
00106                         if (S_ISDIR(st.st_mode))
00107                         {
00108                         }
00109                         else
00110                         {
00111                                 printf("%s\n",p -> d_name);
00112                                 if (ok && p -> d_name[0] != '.')
00113                                 {
00114                                         zz(p -> d_name);
00115                                 }
00116                         }
00117                         //
00118                         p = readdir(dir);
00119                 }
00120                 closedir(dir);
00121         }
00122 }
00123 
00124 

Generated for My SDL C++ Gui by doxygen 1.3.6