|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T U
Length: 4034 (0xfc2)
Types: TextFile
Notes: Uncompressed file
└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
└─⟦d3f3ae100⟧ »EurOpenD3/news/vms/fixrec.c.Z«
└─⟦this⟧
#include <stdio.h>
#include <descrip.h>
#include <rms.h>
#include <ssdef.h>
#include <fibdef.h>
#include <iodef.h>
#include <atrdef.h>
#include <fchdef.h>
#include "fatdef.h"
struct IOSB {
short iosb$w_value;
short iosb$w_count;
long iosb$l_info;
};
struct acp_d {
short acp$w_count;
short acp$w_notused;
long acp$a_pointer;
};
static struct fibdef fib;
static struct acp_d fib_desc;
struct NAM nam_blk;
struct FAB fab_blk;
char exp_str[NAM$C_MAXRSS];
char res_str[NAM$C_MAXRSS];
struct dsc$descriptor_s res_str_d;
main (argc, argv)
int argc;
char **argv;
{
long status;
char dvi[NAM$C_DVI];
struct dsc$descriptor_s dev_desc;
struct atrdef atr[2];
unsigned short chan = 0;
struct IOSB iosb;
struct FAT fat;
int nrecsize;
if (argc < 3)
{
fprintf (stderr, "Usage: fixrec filename recsize\n");
exit (1);
}
nrecsize = atoi(argv[2]);
nam_blk = cc$rms_nam;
nam_blk.nam$l_rsa = res_str;
nam_blk.nam$b_rss = NAM$C_MAXRSS;
nam_blk.nam$l_esa = exp_str;
nam_blk.nam$b_ess = NAM$C_MAXRSS;
fab_blk = cc$rms_fab;
fab_blk.fab$l_fop = FAB$M_NAM;
fab_blk.fab$l_nam = &nam_blk;
fab_blk.fab$l_fna = argv[1];
res_str_d.dsc$w_length = NAM$C_MAXRSS;
res_str_d.dsc$b_dtype = DSC$K_DTYPE_T;
res_str_d.dsc$b_class = DSC$K_CLASS_S;
res_str_d.dsc$a_pointer= res_str;
fab_blk.fab$b_fns = strlen(argv[1]);
status = sys$parse(&fab_blk);
if ((status & 0x1) != 1)
exit (status);
status = sys$search(&fab_blk);
if ((status & 0x1) != 1)
{
if (status == RMS$_NMF)
exit(1);
exit(status);
}
res_str_d.dsc$w_length = nam_blk.nam$b_rsl;
status = lib$put_output(&res_str_d);
if ((status & 0x1) != 1)
exit(status);
dev_desc.dsc$a_pointer = &(nam_blk.nam$t_dvi[1]);
dev_desc.dsc$w_length = nam_blk.nam$t_dvi[0];
dev_desc.dsc$b_dtype = DSC$K_DTYPE_T;
dev_desc.dsc$b_class = DSC$K_CLASS_S;
/*
* Open channel to disk
*/
status = sys$assign(&dev_desc, &chan, (long)0, (long)0);
if (status != SS$_NORMAL)
{
fprintf (stderr, "Unable to assign disk\n");
exit(status);
}
/*
* Setup File Information Block
*/
fib_desc.acp$a_pointer = &fib;
fib_desc.acp$w_count = 24;
/*
* Use File id and Directory id from NAM
*/
fib.fib$r_fid_overlay.fib$w_fid[0] = nam_blk.nam$w_fid[0];
fib.fib$r_fid_overlay.fib$w_fid[1] = nam_blk.nam$w_fid[1];
fib.fib$r_fid_overlay.fib$w_fid[2] = nam_blk.nam$w_fid[2];
fib.fib$r_did_overlay.fib$w_did[0] = nam_blk.nam$w_did[0];
fib.fib$r_did_overlay.fib$w_did[1] = nam_blk.nam$w_did[1];
fib.fib$r_did_overlay.fib$w_did[2] = nam_blk.nam$w_did[2];
fib.fib$r_acctl_overlay.fib$l_acctl = 0;
fib.fib$r_nmctl_overlay.fib$w_nmctl = FIB$M_FINDFID;
/*
* Read FAT
*/
atr[0].atr$w_type = ATR$C_RECATTR;
atr[0].atr$w_size = ATR$S_RECATTR;
atr[0].atr$l_addr = &fat;
atr[1].atr$w_size = 0;
atr[1].atr$w_type = 0;
status = sys$qiow((long)0, chan, (short)(IO$_ACCESS), &iosb,
(long)0, (long)0,
&fib_desc, (long)0, 0, 0,
atr, (long)0);
if ((status != SS$_NORMAL) ||
(iosb.iosb$w_value != SS$_NORMAL))
{
sys$dassgn (chan);
fprintf (stderr, "Unable to access file: %d\n", status);
exit(status);
}
#ifdef notdef
if (fat.fat$v_rtype != FAT$C_FIXED)
{
fprintf (stdout, "File record type must be FIXED\n");
exit(1);
}
#endif
fprintf (stdout, "Current record size : %d\n", (int)fat.fat$w_rsize);
fat.fat$w_rsize = nrecsize;
fprintf (stdout, "New record size : %d\n", (int)fat.fat$w_rsize);
status = sys$qiow((long)0, chan, (short)(IO$_MODIFY), &iosb,
(long)0, (long)0,
&fib_desc, (long)0, 0, 0,
atr, (long)0);
if ((status != SS$_NORMAL) ||
(iosb.iosb$w_value != SS$_NORMAL))
{
sys$dassgn (chan);
fprintf (stderr, "Unable to modify file: %d\n", status);
exit(status);
}
}