static int DoPMake( pmake_data *data ) { pmake_list *curr; int res; char cmd[PMAKE_COMMAND_SIZE]; int rc = 0; for( curr = data->dir_list; curr != NULL; curr = curr->next ) { res = SysChdir( curr->dir_name ); if( res != 0 ) { if( !data->ignore_errors ) { return( res ); } Log( false, "'cd %s' non-zero return: %d\n", curr->dir_name, res ); rc = res; continue; } getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); if( data->display ) LogDir( IncludeStk->cwd ); PMakeCommand( data, cmd ); res = SysRunCommand( cmd ); if( res != 0 ) { if( !data->ignore_errors ) { return( res ); } Log( false, "'%s' non-zero return: %d\n", cmd, res ); rc = res; } } return( rc ); }
static unsigned DoPMake( pmake_data *data, bool ignore_errors ) { pmake_list *curr; unsigned res; char cmd[256]; for( curr = data->dir_list; curr != NULL; curr = curr->next ) { res = SysChdir( curr->dir_name ); if( res != 0 ) { if( ignore_errors ) { Log( FALSE, "non-zero return: %d\n", res ); continue; } else { return( res ); } } getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); if( data->display ) LogDir( IncludeStk->cwd ); PMakeCommand( data, cmd ); res = SysRunCommand( cmd ); if( res != 0 ) { if( ignore_errors ) { Log( FALSE, "non-zero return: %d\n", res ); } else { return( res ); } } } return( 0 ); }
int RunIt( char *cmd, bool ignore_errors, bool *res_nolog ) { int res; #define BUILTIN( b ) \ (strnicmp( cmd, b, sizeof( b ) - 1 ) == 0 && cmd[sizeof(b)-1] == ' ') *res_nolog = false; if( BUILTIN( "CD" ) ) { res = SysChdir( SkipBlanks( cmd + sizeof( "CD" ) ) ); if( res == 0 ) { getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); } } else if( BUILTIN( "CDSAY" ) ) { res = SysChdir( SkipBlanks( cmd + sizeof( "CDSAY" ) ) ); if( res == 0 ) { getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); LogDir( IncludeStk->cwd ); } } else if( BUILTIN( "SET" ) ) { res = ProcSet( SkipBlanks( cmd + sizeof( "SET" ) ) ); } else if( BUILTIN( "ECHO" ) ) { Log( Quiet, "%s\n", SkipBlanks( cmd + sizeof( "ECHO" ) ) ); res = 0; } else if( BUILTIN( "ERROR" ) ) { Log( Quiet, "%s\n", SkipBlanks( cmd + sizeof( "ERROR" ) ) ); res = 1; } else if( BUILTIN( "COPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "COPY" ) ), false, false, ignore_errors ); *res_nolog = true; } else if( BUILTIN( "ACOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "ACOPY" ) ), true, false, ignore_errors ); *res_nolog = true; } else if( BUILTIN( "CCOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "CCOPY" ) ), false, true, ignore_errors ); *res_nolog = true; } else if( BUILTIN( "ACCOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "ACCOPY" ) ), true, true, ignore_errors ); *res_nolog = true; } else if( BUILTIN( "MKDIR" ) ) { res = ProcMkdir( SkipBlanks( cmd + sizeof( "MKDIR" ) ) ); } else if( BUILTIN( "PMAKE" ) ) { res = ProcPMake( SkipBlanks( cmd + sizeof( "PMAKE" ) ), ignore_errors ); *res_nolog = ignore_errors; } else if( BUILTIN( "RM" ) ) { res = ProcRm( SkipBlanks( cmd + sizeof( "RM" ) ) ); } else if( cmd[0] == '!' ) { res = SysRunCommand( SkipBlanks( cmd + 1 ) ); } else { res = SysRunCommand( cmd ); } return( res ); }
unsigned RunIt( char *cmd, bool ignore_errors ) { unsigned res; #define BUILTIN( b ) \ (strnicmp( cmd, b, sizeof( b ) - 1 ) == 0 && cmd[sizeof(b)-1] == ' ') res = 0; if( BUILTIN( "CD" ) ) { res = SysChdir( SkipBlanks( cmd + sizeof( "CD" ) ) ); if( res == 0 ) { getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); } } else if( BUILTIN( "CDSAY" ) ) { res = SysChdir( SkipBlanks( cmd + sizeof( "CDSAY" ) ) ); if( res == 0 ) { getcwd( IncludeStk->cwd, sizeof( IncludeStk->cwd ) ); LogDir( IncludeStk->cwd ); } } else if( BUILTIN( "SET" ) ) { res = ProcSet( SkipBlanks( cmd + sizeof( "SET" ) ) ); } else if( BUILTIN( "ECHO" ) ) { Log( Quiet, "%s\n", SkipBlanks( cmd + sizeof( "ECHO" ) ) ); } else if( BUILTIN( "ERROR" ) ) { Log( Quiet, "%s\n", SkipBlanks( cmd + sizeof( "ERROR" ) ) ); res = 1; } else if( BUILTIN( "COPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "COPY" ) ), FALSE, FALSE ); } else if( BUILTIN( "ACOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "ACOPY" ) ), TRUE, FALSE ); } else if( BUILTIN( "CCOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "CCOPY" ) ), FALSE, TRUE ); } else if( BUILTIN( "ACCOPY" ) ) { res = ProcCopy( SkipBlanks( cmd + sizeof( "ACCOPY" ) ), TRUE, TRUE ); } else if( BUILTIN( "MKDIR" ) ) { res = ProcMkdir( SkipBlanks( cmd + sizeof( "MKDIR" ) ) ); } else if( BUILTIN( "PMAKE" ) ) { res = ProcPMake( SkipBlanks( cmd + sizeof( "PMAKE" ) ), ignore_errors ); } else { res = SysRunCommand( cmd ); } return( res ); }