VMS-IndexedFile
view release on metacpan or search on metacpan
IndexedFile/IndexedFile.xs view on Meta::CPAN
/* VMS::IndexedFile
VERSION 0.02
Copyright (c) 1996 Kent A. Covert and Toni L. Harbaugh-Blackford.
All rights reserved. This program is free software; you can
redistribute it and/or modify it under the same terms as Perl itself.
History:
0.02 04/29/99 BH Repackaged as VMS::IndexedFile
Dan's patch from 3/99 applied
0.01 04/01/96 KAC Initial beta program version (covertka@muohio.edu)
-adapted from Toni L. Harbaugh-Blackford's
VDBM application.
*/
#include <file.h>
#include <rms.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ssdef.h>
#include <starlet.h>
#include <libdef.h>
#include <fdl$routines.h>
#include <fdldef.h>
#include <lib$routines.h>
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
int vmdbm_debug = 0;
/* For some strange reason, DEC created these nice macros and then completely messed them up in XABKEYDEF.H */
#undef xab$w_pos
#undef xab$b_siz
/* The following lines are copied from the XABKEYDEF.H file, BEFORE they're "corrupted" */
#define xab$w_pos xab$r_pos_overlay.xab$w_pos
#define xab$b_siz xab$r_siz_overlay.xab$b_siz
typedef struct _VMSMDBM_STRUCT_
{
struct FAB fab;
struct NAM nam;
struct RAB rab;
struct XABKEY xabkey;
char * key;
char es[256];
int replace;
} VMSMDBM;
/* a VMSMDBM ptr is returned by vmsdbm_TIEHASH() */
typedef VMSMDBM * VMDBM;
static double
constant(name, arg)
char *name;
int arg;
{
errno = 0;
if (vmdbm_debug) printf("in constant - name: %s\n",name);
switch (*name) {
case 'O': if (strEQ(name, "O_RDONLY")) return O_RDONLY;
if (strEQ(name, "O_WRONLY")) return O_WRONLY;
if (strEQ(name, "O_RDWR")) return O_RDWR;
if (strEQ(name, "O_CREAT")) return O_CREAT;
if (strEQ(name, "O_TRUNC")) return O_TRUNC;
if (strEQ(name, "O_EXCL")) return O_EXCL;
break;
}
errno = EINVAL;
return 0;
}
int
vmdbm_store(VMDBM vms_db,SV *record)
{
unsigned long int retsts;
char * recval;
STRLEN reclen;
int tmpbool;
int retval;
SETERRNO(0,SS$_NORMAL);
retval = 0;
if (vmdbm_debug) printf("vmdbm_store\n");
recval = SvPV(record,reclen);
if (vmdbm_debug) printf(" record to be stored: %s\n",recval);
vms_db->rab.rab$b_rac = RAB$C_KEY;
vms_db->rab.rab$l_rbf = recval;
vms_db->rab.rab$w_rsz = reclen;
vms_db->rab.rab$l_rop = RAB$M_RLK | RAB$M_RRL | (RAB$M_UIF * vms_db->replace);
( run in 0.536 second using v1.01-cache-2.11-cpan-39bf76dae61 )