4 error_reporting(E_ALL);
6 $origen = isset( $argv[1] ) ? $argv[1] : '.';
7 $destino = isset( $argv[2] ) ? $argv[2] : '.';
8 $libdir = isset( $argv[3] ) ? $argv[3] : getcwd();
10 require_once "$libdir/corregir_lib.php";
12 $fi = fopen( "$origen/webgen", 'r' );
13 $fo = fopen( "$destino/estado", 'w' );
14 $fe = fopen( 'php://stderr', 'w' );
16 $s = fgets( $fi ); // Saca la descripciĆ³n.
17 fputs( $fo, "nrodoc,dependencia,estado,funcion\n" );
19 while ( ( $s = fgets( $fi ) ) !== false ) {
20 if ( preg_match( '/^(\d{10}),(SCA|SAS|CAS),(AD|CA|SG|SE|ME|MA|MY|PL),(\d{10}),$/', $s, $m ) ) {
21 #if ( preg_match( '/^(\d{10}),([^,]+),(\d{8}),([:\d]*),([:\d]*),$/', $s, $m ) ) {
22 list( $todo, $doc, $est, $func, $dep ) = $m;
23 $doc = sacar_ceros( $doc );
24 fputs( $fo, "$doc,$dep,$est,$func\n" );
26 fputs( $fe, "ERROR: No se pudo interpretar la fila $c: $s.\n" );