#!/usr/bin/perl

use lib 'd:/Programs/Perl/lib';
use lib 'd:/MyWebs/cgi-bin';
#use lib './lib';
#use lib '../../bin';

use strict;
#use warnings;
use Jcode;
use File::Path;
use File::Basename;
use File::Find;
use DBI;
use CGI;

use MyApplication;
use SQLDB;
use Utils;
use GetArg;
use SearchPaperDB;

BEGIN {
#	$| = 1;
	open (STDERR, ">&STDOUT");
}

#===============================================
# スクリプト大域変数
#===============================================

#===============================================
# 文字コード関係変数
#===============================================
# sjis, euc, jis, noconv
my $FileSystemCharCode = "sjis";
my $SQLiteCharCode     = "sjis";
my $WebCharSet         = "x-sjis";
my $WebCharCode        = "sjis";

#===============================================
# SQL関係変数
#===============================================
my $DBServer   = "localhost";
my $DBUser     = "";
my $DBPassword = "";
my $DBName     = "d:/temp/a.sqlite3";
my $TableName  = "a_tbl";

#===============================================
# Applicationクラス作製
#===============================================
my $App = new MyApplication;
exit if($App->Initialize() < 0);
$App->SetDebug(0);
# 実行プログラム名（デフォルトでは$0から取得）
	my $Program = $App->Program();
# アプリケーション名
	$App->SetAppName($Program);
# バージョン
	$App->SetVersion("Ver 0.1");
# プログラムパスの設定
	my $BaseDir = '';
	my $ProgramPath = $App->SpeculateProgramPath($0, $BaseDir);

#==========================================
# データベースオブジェクト作成
#==========================================
my $DB = new SQLDB("SQLite");
$DB->SetApplication($App);

#==========================================
# コマンドラインオプション読み込み
#==========================================
$App->AddArgument("--Action",    "--Action: Set Action",       '');
$App->AddArgument("--DebugMode", "--DebugMode: Set DebugMode", '');
exit 1 if($App->ReadArgs(0) != 1);
my $Args = $App->Args();
my $form = new CGI;

#==========================================
# メイン関数スタート
#==========================================
my $NowTime   = time();
my $Today     = Utils::BuildDateString($NowTime);
my $IPAddress = Utils::GetIPAddress();

my $Action = $Args->GetGetArg('Action');
my $Debug  = $Args->GetGetArg('DebugMode');
$App->SetDebug($Debug);

$App->print("東京工業大学\n");

my ($dbh, $dbsth) = $DB->Open($DBServer, "$DBUser", $DBPassword, $DBName, "sjis", 0, 1);
if(!$DB->dbh()) {
	$App->print("Error: Can not open [$DBName].\n");
	exit;
}


$DB->Close();

exit;

#===============================================
# スクリプト終了
#===============================================

#==========================================
# &Subroutines
#==========================================

