Back to index

php5  5.3.10
get_error_codes.php
Go to the documentation of this file.
00001 <?php
00002        $codes = array();
00003        $maxlen = 0;
00004 
00005        while (!feof(STDIN)) {
00006               $line = fgets(STDIN);
00007 
00008               if (ereg('^\{[[:space:]]+(ER_.*)[[:space:]]+,[[:space:]]*"(.*)",[[:space:]]*"(.*)"', $line, $matches)) {
00009                      $codes[$matches[1]] = $matches[2];
00010                      $maxlen = max($maxlen, strlen($matches[1]));
00011               }
00012        }
00013 
00014        if (empty($codes)) {
00015               fputs(STDERR, "input doesn't look like a MySQL sql_state.h file\n");
00016               exit(3);
00017        }
00018        
00019        echo "/* DO NOT EDIT THIS FILE!!! It is auto generated by get_error_codes.php */\n";
00020        foreach ($codes as $code => $state) {
00021               echo "#ifdef $code\n";
00022               printf("  case %-{$maxlen}s: return \"%s\";\n", $code, $state);
00023               echo "#endif\n";
00024        }
00025 
00026        
00027 ?>