crabs_makefile-5.2 ©2003-2008 - Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com)
1 /* 2 **============================================================================= 3 ** crabs_makefile-5.2 : Makefile pour developpement multi-OS, multi-variants 4 ** Copyright (C) 2003-2008 : Christophe Cazajus (crabs-mettre_le_signe_at-crabs-world.com) 5 ** 6 ** Ce source fait partie d'un projet logiciel libre. Vous pouvez le distribuer 7 ** et/ou le modifier en respectant les termes de la GNU General Public License 8 ** version 2 ou (suite a votre propre choix) une version ulterieure. 9 ** 10 ** Ce programme est distribue dans l'espoir qu'il puisse etre utile, mais 11 ** sans aucune garantie, meme si il est associe a un produit qui vous en 12 ** propose une. Conformez-vous a la GNU General Public License pour avoir 13 ** plus de precisions. 14 ** 15 ** L'auteur ne peut etre tenu responsable de l'utilisation faite des 16 ** composantes associees a ce projet (en partie ou dans leur totalite). 17 ** 18 ** Une copie du fichier de la GNU GPL est fournie dans le repertoire DOC 19 ** de ce projet sous le nom gnu_gpl.txt 20 ** 21 **============================================================================= 22 */ 23 #include <sys/types.h> 24 #include <stdio.h> 25 #include <stdlib.h> 26 #include <string.h> 27 #include <sys/stat.h> 28 #include <unistd.h> 29 #include <libintl.h> 30 #include <locale.h> 31 #include <errno.h> 32 /* 33 ** Pdepend file file.dep file_to_unlink 34 */ 35 36 int main( int argc, char **argv ) 37 { 38 time_t tfile ; 39 struct stat st ; 40 FILE* in ; 41 char path [1024] ; 42 char rpath [1024] ; 43 char rfile [1024] ; 44 char** pt ; 45 int i ; 46 int pass ; 47 48 setlocale( LC_ALL, "" ) ; textdomain( "libc" ) ; 49 if ( getenv( "CRABS_LOCALE" ) ) 50 { 51 bindtextdomain( "crabs_makefile", getenv( "CRABS_LOCALE" ) ) ; 52 textdomain( "crabs_makefile" ) ; 53 } 54 if ( argc != 4 ) 55 { 56 fprintf( stderr, gettext( 57 "%s time_reference_file dependance_file file_unlinked\n" 58 ), argv[0] ) ; 59 exit(1) ; 60 } 61 if ( stat( argv[3], &st ) == -1 ) return 0 ; 62 tfile = st.st_mtime ; 63 64 realpath( argv[1], rfile ) ; 65 66 in = fopen( argv[2], "r" ) ; 67 if ( !in ) return 0 ; 68 fscanf( in, "%s", path ) ; fscanf( in, "%s", path ) ; 69 while( fscanf( in, "%s", path ) > 0 ) 70 { 71 if ( path[strlen(path)-1] == '\\' ) path[strlen(path)-1] = 0 ; 72 if ( ! *path ) continue ; 73 realpath( path, rpath ) ; 74 if ( strcmp( rpath, rfile ) == 0 ) continue ; 75 if ( stat( rpath, &st ) == -1 ) continue ; 76 if ( tfile > st.st_mtime ) continue ; 77 fclose( in ) ; 78 unlink( argv[3] ) ; 79 return 0 ; 80 } 81 fclose( in ) ; 82 return 0 ; 83 } 84
Date de génération : 22/09/2011 21:47