[Info-vax] RMS and SSIO (again)
Greg Tinkler
tinklerg at gmail.com
Tue Jan 11 20:50:11 EST 2022
Hi Arne
You seem quite emphatic that is does not work, well
[12:37:29,12:37:00]
[12:37:31,12:37:32]
[12:37:33,12:37:34]
[12:37:35,12:37:36]
[12:37:37,12:37:38]
[12:37:39,12:37:40]
[12:37:41,12:37:42]
This may not seem much but the first timestamp is from 1 process and the other from another process.
If you use CRTL, SAME CODE it does not work and shows the problem described.
[12:37:53,12:37:48]
[12:41:09,12:37:48]
[12:41:11,12:37:48]
[12:41:13,12:37:48]
As you can see the second process details are not being updated, even though this is what is being updated.
[12:37:48,]
[12:41:19,]
[12:41:21,]
[12:41:23,]
[12:41:25,]
However using my approach, and doing the correct coding, you get the results above.
IT BL**DLY WORKS!!!
If VSI want to approach me about the code, that is fine, but here is a short code snippet to help you understand it
TSS$SETRFA (fdptr->rab, offset);
fdptr->rab->rab$b_rac = RAB$C_RFA;
// get the data so RMS is happy, nb may only needs some at the start of the data
sts = sys$get (fdptr->rab);
fdptr->rab->rab$l_rbf = (void *) buf;
fdptr->rab->rab$w_rsz = buflen;
sts = sys$update (fdptr->rab);
Oh and the test code
/*
* File: rms_unixio_test1.c
* Author: greg
* copyright 2021, 2022 TS Solutions Pty Ltd
*
*/
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <time.h>
//#define TSS$UNIXIO_ENABLE
#include "rms_unixio.h"
#define MAX_REC_LEN 40
/*
*
*/
int main (int argc, char** argv)
{
char fn[] = "rms_unixio.bin";
char *recbuff1, *recbuff2;
time_t rawtime;
struct tm *tm0;
char inbuf[50], ts[20];
int i, fd, sts, rno;
long rec_len1, rec_len2;
long long rec_offset1, rec_offset2;
char *sptr;
recbuff1 = (char *)malloc (MAX_REC_LEN);
recbuff2 = (char *)malloc (MAX_REC_LEN);
rec_len1=20;
rec_len2=20;
fd = open(fn, O_RDWR, 0777); /*,"ctx=bin","rfm=udf"); */
if (fd < 0)
{
perror("*** Unable to open file");
exit (0);
}
rno = 1;
printf ("record number, 0 to finish: ");
sptr = fgets (inbuf, sizeof (inbuf), stdin);
rno = atoi (inbuf);
if(rno==0) exit(0);
rec_offset1=(rno-1) * rec_len1;
rec_offset2=(rno) * rec_len2;
while (rno > 0)
{
/* get record number to change */
if (rno > 0)
{
sts = pread(fd, recbuff1, rec_len1, rec_offset1);
sts = pread (fd, recbuff2, rec_len2, rec_offset2);
/* show what we got */
printf ("[%.8s,%.8s]\n", recbuff1, recbuff2);
/* get current time */
time (&rawtime);
tm0 = localtime (&rawtime);
strftime (ts, sizeof (ts), "%H:%M:%S", tm0);
/* format output */
snprintf (recbuff1, 9, "%.8s\0", ts);
sts = pwrite (fd, recbuff1, rec_len1, rec_offset1);
sleep(2); /* sleep for 2 seconds */
}
}
/* don't close until requested */
sts = close (fd);
return (EXIT_SUCCESS);
}
So drop SSIO, fix CRTL, and yes someone after 20 years has been able to easily and quickly solve the problem.
gt
More information about the Info-vax
mailing list