+++ /dev/null
-/*\r
- ---------------------------------------------------------------------------\r
- Copyright (c) 1998-2007, Brian Gladman, Worcester, UK. All rights reserved.\r
-\r
- LICENSE TERMS\r
-\r
- The free distribution and use of this software is allowed (with or without\r
- changes) provided that:\r
-\r
- 1. source code distributions include the above copyright notice, this\r
- list of conditions and the following disclaimer;\r
-\r
- 2. binary distributions include the above copyright notice, this list\r
- of conditions and the following disclaimer in their documentation;\r
-\r
- 3. the name of the copyright holder is not used to endorse products\r
- built using this software without specific written permission.\r
-\r
- DISCLAIMER\r
-\r
- This software is provided 'as is' with no explicit or implied warranties\r
- in respect of its properties, including, but not limited to, correctness\r
- and/or fitness for purpose.\r
- ---------------------------------------------------------------------------\r
-\r
- This program converts Visual Studio 2008 C/C++ version 9 build projects \r
- into build projects for Visual Studio 2005 C/C++ version 8. It will \r
- also convert files that have been converted in this way back into their\r
- original form. It does this conversion by looking for *.vcproj files \r
- in the current working directory and its sub-directories and changing \r
- the following line in each of them:\r
-\r
- Version="9.00"\r
-\r
- to:\r
-\r
- Version="8.00"\r
-\r
- or vice versa.\r
- \r
- It is used by compiling it, placing it in a root build directory and \r
- running it from there. It acts recursively on all sub-directories of\r
- this directory it is important not to run it at a directory level in\r
- which not all projects are to be converted.\r
-*/\r
-\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <io.h>\r
-\r
-void process_file(char *fn)\r
-{ FILE *f;\r
- fpos_t pos;\r
- char iobuf[1024], *p;\r
-\r
- if((f = fopen(fn, "r+")) == 0) /* open for read and write */\r
- {\r
- printf("File open error on: %s\n", fn); return;\r
- }\r
-\r
- for( ; ; )\r
- {\r
- if(feof(f)) /* version line not found */\r
- break;\r
-\r
- if(fgetpos(f, &pos)) /* save position of line */\r
- {\r
- printf("File getpos error on: %s\n", fn); break;\r
- }\r
-\r
- if(!fgets(iobuf, 1024, f)) /* read the line in */\r
- {\r
- printf("File read error on: %s\n", fn); break;\r
- }\r
-\r
- if(p = strchr(iobuf, 'V')) /* look for 'version' line */\r
- {\r
- if(!strncmp(p, "Version=\"8.00\"", 14) \r
- || !strncmp(p, "Version=\"9.00\"", 14))\r
- {\r
- *(p + 9) ^= 1; /* switch versions */\r
- /* reset back to start of line in the file and */\r
- /* write the changed line to the file */\r
- if(fsetpos(f, &pos))\r
- printf("File setpos error on: %s\n", fn);\r
- else if(fputs(iobuf, f) == EOF)\r
- printf("File write error on: %s\n", fn);\r
- break; /* this file is now fixed */ \r
- }\r
- }\r
- }\r
- fclose(f);\r
-}\r
-\r
-void find_vcproj_files(char *dir)\r
-{ struct _finddata_t cfile;\r
- intptr_t hfile;\r
- char nbuf[_MAX_PATH], *p;\r
-\r
- strcpy(nbuf, dir); /* find directories and files */\r
- strcat(nbuf, "\\*.*");\r
- if((hfile = _findfirst( nbuf, &cfile )) == -1L )\r
- return; /* if directory is empty */\r
-\r
- do\r
- {\r
- strcpy(nbuf, dir); /* compile path to the current */\r
- strcat(nbuf, "\\"); /* file or directory */\r
- strcat(nbuf, cfile.name);\r
-\r
- if((cfile.attrib & _A_SUBDIR) == _A_SUBDIR)\r
- { /* if it is a sub-direcory */\r
- if(strcmp(cfile.name, ".") && strcmp(cfile.name, ".."))\r
- find_vcproj_files(nbuf); /* recursive search */\r
- }\r
- else if((cfile.attrib & 0x1f) == _A_NORMAL && (p = strrchr(cfile.name, '.'))\r
- && !strcmp(p, ".vcproj"))\r
- process_file(nbuf); /* if it is a *.vcproj file */\r
- }\r
- while\r
- ( _findnext( hfile, &cfile ) == 0 );\r
-\r
- _findclose( hfile );\r
-}\r
-\r
-int main(void)\r
-{ char *dir;\r
-\r
- if(!(dir = _getcwd( NULL, 0 )))\r
- printf("Cannot obtain current working directory\n");\r
- else\r
- find_vcproj_files(dir);\r
-}\r