Operating System - OpenVMS
1753860 Members
7833 Online
108809 Solutions
New Discussion юеВ

regarding system functions in ovms

 
Not applicable

regarding system functions in ovms

Hi
I have below two queries:


q-1) I want to change file format from "Variable type" to "stream_lf" format using C code in OVMS platform.
Please let me know how can I change the file format and what system function should I use?

q-2) I want to execute a portion of the code depending on which process calls that function. How do I make know the function, foo that process, "test" has called it?
code snippet:

void function foo(int a, int b)
{
a = a *b;
if (process_test has callled) /* "test" is a process running in the system */
{
a =a/b;
}
}


regards
ajaydec
4 REPLIES 4
Ian Miller.
Honored Contributor

Re: regarding system functions in ovms

The CONV routines do what the CONVERT command does and are callable from C

http://h71000.www7.hp.com/doc/83final/4493/4493pro_006.html#4493_conv_chap

You can obtain the current process name using LIB$GETJPI

____________________
Purely Personal Opinion
Steven Schweda
Honored Contributor

Re: regarding system functions in ovms

> Please let me know how can I change the
> file format [...]

Are you trying to do something like:

CONVERT file1 file2 /FDL = SYS$INPUT
RECORD
FORMAT stream_lf

or something like:

SET FILE /ATTRIBUTES = RFM: STMLF file

???

Or are you trying to create a file in C with
the right attributes in the first place?

> [...] depending on which process calls that
> function.

A process doesn't call a function, a program
does. Exactly what are you trying to test
here?
Hein van den Heuvel
Honored Contributor

Re: regarding system functions in ovms

q-1) I want to change file format from "Variable type" to "stream_lf" format using C code in OVMS platform.

As Ian indicates, calleable convert is the right way to go. You would have to pass convert an FDL file reading: "RECORD; FORMAT STREAM_LF;" no more, no less.
If this happens less than a few times per hour, then it is tempting to spawn a process to convert the file using something like:
sprintf (cmd, "convert/fdl=stream_lf %s %s", old, new);
system(cmd);

q-2) I want to execute a portion of the code depending on which process calls that function.

First, you would have to decide what makes a particular process unique so you can identify it.If that is based on the process name, then you can use SYS$GETJPI or LIB$GETJPI output to get the process name as Ina indicates.
Or maybe a c rtl call like 'getuid', or get the image name from getjpi or the 0 program argument.

More likely you want to use an environment variable, or a command line argument to indicate what to do next.

Finally, if you have mroe questions about this, then please clarify the statement "which process calls that function"
Processess do not call functions.
Processess run images which call functions.
The function can be linked with the image, or in a static library or in a dynamically actived dynamic shareable library. The exact method used may offer further opportunities for solutions.

Hope this helps some,
Hein van den Heuvel (at gmail dot com)
HvdH Performance Consulting
Hein van den Heuvel
Honored Contributor

Re: regarding system functions in ovms

On q-2, I meant to add... the program can probably also just open the variable length record type input file, and create a new file with different name (C rtl can inherit file attributes). The loop to read from old and write to new.

Steven wrote "A process doesn't call a function, a program does. Exactly what are you trying to test here?"

Greate minds...

Hein.