File: make-dbhelper.pl

package info (click to toggle)
phpwiki 1.3.14-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 15,716 kB
  • ctags: 23,548
  • sloc: php: 88,295; sql: 1,476; sh: 1,378; perl: 765; makefile: 602; awk: 28
file content (27 lines) | stat: -rwxr-xr-x 806 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/perl -sn
# makefile helper to extract various settings from config/config.ini
# $Id: make-dbhelper.pl,v 1.2 2004/07/01 08:15:10 rurban Exp $

#if ($v eq 'DATABASE_TYPE' and /^\s*DATABASE_TYPE\s*=\s*(\w+)/) {
#    print "$1\n";
#    exit;
#}

# word split
if ($v eq 'DATABASE_DSN' and /^\s*DATABASE_DSN\s*=\s*"?([\w:\/@]+)/) {
    my $result = '';
    my $dsn = $1;
    $dsn =~ /^(.+?):\/\// 	and $result .= "$1 "; # backend
    $dsn =~ /.+\/(.+?)$/ 	and $result .= "$1 "; # database: everything after the last slash
    $dsn =~ /:\/\/(\w+):/ 	and $result .= "$1 "; # username (optional)
    $dsn =~ /:\/\/\w+:(\w+)@/ 	and $result .= "$1 "; # password (optional)
    print "$result\n";
    exit;
}

if ($v ne 'DATABASE_DSN') {
  if (/^\s*$v\s*=\s*"?([^;]+)$/) {
    print "$1\n";
    exit;
  }
}