Page MenuHomec4science

bibformat.in
No OneTemporary

File Metadata

Created
Sat, Nov 9, 23:11

bibformat.in

## $Id$
## Script that calls FlexElink on bibliographic data in XML MARC OAI.
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
## start PHP:
<protect>#!</protect><PHP> -f
#!/soft/bin/php -f
<?
<protect>## $Id$</protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
define( GLOBALCONFIG, "<LIBDIR>/php/cdsware/bibformat/common/global.inc.shtml");
### okay, config read, from now on the script can continue ###
<protect>
//======================================================================
function getTime()
{
list($sec, $usec)=explode(" ", microtime());
return (float)$sec+(float)$usec;
}
//======================================================================
//======================================================================
// Main
//======================================================================
require(GLOBALCONFIG);
include_once(MAIN);
define(DEFAULT_ITYPE, "DEFAULT");
define(DEFAULT_OTYPE, "DEFAULT");
$itype=DEFAULT_ITYPE;
$otype=explode(",", DEFAULT_OTYPE);
if(count($argv)>3)
{
print "Usage:\n\tbibformat [itype=<input type>] [otype=<output type>]\n";
exit;
}
foreach($argv as $value)
{
$par=explode("=", strtoupper(trim($value)));
if(count($par)>1)
{
if($par[0]=="ITYPE")
{
if(trim($par[1])!="")
{
$itype=$par[1];
}
}
elseif($par[0]=="OTYPE")
{
if(trim($par[1])!="")
{
$otype=explode(",", $par[1]);
}
}
}
}
$fxk=new FlexElink();
$error=$fxk->initialise("OAIMARC");
$err_fh=fopen("php://stderr", "w");
if($error)
{
fputs($err_fh, "Error initialising: $error");
exit;
}
$stime=getTime();
$code=0;
$count_rec=0;
while(1)
{
list($code, $res)=$fxk->getRecordResult($otype);
if($code<0) break;
if($code==0)
{
fputs($err_fh, "--------------------------------------------------------\n");
fputs($err_fh, "Errors processing record# $count_rec\n");
fputs($err_fh, "$res\n");
fputs($err_fh, "--------------------------------------------------------\n");
continue;
}
print eval("?>$res<?");
$count_rec++;
}
$etime=getTime();
$total_time=$etime-$stime;
fputs($err_fh, "--------------------------------------------------------\n");
fputs($err_fh, "Total processed records: $count_rec\n");
fputs($err_fh, "Total time: $total_time sec\n");
fputs($err_fh, "Avg. time per record: ".$total_time/$count_rec." sec\n");
fputs($err_fh, "--------------------------------------------------------\n");
fclose($err_fh);
?>
</protect>

Event Timeline