Accelerator Independent Data Access / PVAccess 2.0
AIDA-PVA is the latest version of the AIDA framework. Built on top of EPICS 7 it enables client applications to programmatically access and manage any device or database on the SLAC Network using simple channel names.
Loading...
Searching...
No Matches
aida_pva.h File Reference

The Header File for the AIDA-PVA Module functions. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <stsdef.h>
#include <stdbool.h>
#include <jni.h>
#include "slc_macros.h"
#include "msg_proto.h"
#include "errtranslate.h"
#include "ref.h"
#include "process_parm.h"
#include "aida_pva_json.h"
#include "aida_pva_types.h"
#include "aida_pva_exceptions.h"
#include "aida_pva_api.h"
#include "aida_pva_convert.h"
#include "aida_pva_memory.h"
#include "aida_pva_uri.h"

Go to the source code of this file.

Functions

void aidaThrow (JNIEnv *env, vmsstat_t status, char *exception, const char *message)
 Exception Handling. More...
 
void aidaThrowNonOsException (JNIEnv *env, char *exception, const char *message)
 To log any non-OS exceptions and throw back to java. More...
 
void * allocateMemory (JNIEnv *env, void *source, size_t size, bool nullTerminate, char *message)
 Memory Handling. More...
 
int ascanf (JNIEnv *env, Arguments *arguments, const char *formatString,...)
 Argument Processing. More...
 
int avscanf (JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
 ascanf(), avscanf() More...
 
int endsWith (const char *str, char *suffix)
 String Handling. More...
 
int groupNameFromUri (char groupName[], const char *uri)
 URI Handling for group, secn, pmu and slacName. More...
 
vmsstat_t init (const char *processName, bool initMessageServices)
 Initialisation. More...
 
int pmuFromDeviceName (JNIEnv *env, char *device, char *primary, char *micro, int4u *unit)
 Get primary, micro and unit from a device name. More...
 
void pmuStringFromUri (char *pmuString, const char *uri)
 Get the pmu part of a URI. More...
 
void releaseArray (Array array)
 Free up any memory allocated the given scalar array. More...
 
void releasePvAndArguments (JNIEnv *env, jstring uri, const char *pv, Arguments arguments)
 Free up any memory allocated for the given pv and arguments. More...
 
void releaseStringArray (StringArray array)
 Free up any memory allocated for string arrays. More...
 
void releaseTable (Table table)
 Free up any memory allocated for the given table. More...
 
void releaseValue (Value value)
 Release all allocated memory in the given value. More...
 
void secnFromUri (const char *uri, int4u *secn)
 Get secondary from pseudo secondary (containing a colon) number from URI. More...
 
const char * secondaryFromUri (const char *uri)
 Get secondary from URI. More...
 
int startsWith (const char *str, char *prefix)
 Check if a string starts with another string. More...
 
void tableAddColumn (JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
 Add a column of arbitrary type to a Table. More...
 
void tableAddField (JNIEnv *env, Table *table, char *fieldName)
 Add a dynamic field to a table. More...
 
void tableAddFixedWidthStringColumn (JNIEnv *env, Table *table, char *data, int width)
 Add fixed-width string data to a column in the given Table. More...
 
void tableAddLabel (JNIEnv *env, Table *table, char *labelName)
 Add a dynamic column to a table. More...
 
void tableAddSingleRowBooleanColumn (JNIEnv *env, Table *table, unsigned char data)
 Add a boolean column to a Table with only one row. More...
 
void tableAddSingleRowByteColumn (JNIEnv *env, Table *table, unsigned char data)
 Add a byte column to a Table with only one row. More...
 
void tableAddSingleRowDoubleColumn (JNIEnv *env, Table *table, double data, bool ieeeDouble)
 Add a double column to a Table with only one row. More...
 
void tableAddSingleRowFloatColumn (JNIEnv *env, Table *table, float data, bool ieeeFloat)
 Add a float column to a Table with only one row. More...
 
void tableAddSingleRowIntegerColumn (JNIEnv *env, Table *table, int data)
 Add a integer column to a Table with only one row. More...
 
void tableAddSingleRowLongColumn (JNIEnv *env, Table *table, long data)
 Add a long column to a Table with only one row. More...
 
void tableAddSingleRowShortColumn (JNIEnv *env, Table *table, short data)
 Add a short column to a Table with only one row. More...
 
void tableAddSingleRowStringColumn (JNIEnv *env, Table *table, char *data)
 Add a string column to a Table with only one row. More...
 
void tableAddStringColumn (JNIEnv *env, Table *table, char **data)
 Add a String column to the given Table. More...
 
Table tableCreate (JNIEnv *env, int rows, int columns)
 Table Handling. More...
 
Table tableCreateDynamic (JNIEnv *env, int rows, int columns)
 Make a Dynamic Table for return to client. More...
 
void uriLegacyName (char legacyName[MAX_URI_LEN], const char *uri)
 Convert the given URI to the legacy AIDA name for low level functions that still require it that way. More...
 
void uriToSlcName (char slcName[MAX_URI_LEN], const char *uri)
 Convert all URIs to slac names before making queries. More...
 

Detailed Description

The Header File for the AIDA-PVA Module functions.

CMS=C_INC

Definition in file aida_pva.h.

Function Documentation

◆ aidaThrow()

void aidaThrow ( JNIEnv *  env,
vmsstat_t  status,
char *  exception,
const char *  message 
)

Exception Handling.

To log any exceptions and throw back to java.

The #exception is formatted in a standard way using the VMS status code and its associated message and the optionally supplied #message. The #exception is always assumed to be from the edu.stanford.slac.except package

Parameters
envthe JNI environment. Used in all functions involving JNI
statusthe VMS status code to luck up and display text for.
exceptionthe string representation of the exception class to throw.
messagethe optional message to attach to the exception. If NULL it is ignored.

Exception Handling.

The #exception is formatted in a standard way using the VMS status code and its associated message and the optionally supplied #message. The #exception is always assumed to be from the edu.stanford.slac.except package

Parameters
envthe JNI environment. Used in all functions involving JNI
statusthe VMS status code to luck up and display text for.
exceptionthe string representation of the exception class to throw.
messagethe optional message to attach to the exception. If NULL it is ignored.

Definition at line 92 of file aida_pva_server_helper.c.

93{
94 // Clear any exception that may be in the process of being thrown (unlikely)
95 if ((*env)->ExceptionCheck(env)) {
96 (*env)->ExceptionClear(env);
97 }
98
99 char vmsErrorMessage[BUFSIZ] = { '\0' };
100 $DESCRIPTOR(MESSAGE, vmsErrorMessage);
101 struct dsc$descriptor errorMessageDescriptor = { BUFSIZ, DSC$K_DTYPE_T, DSC$K_CLASS_S, (char*)&vmsErrorMessage };
102
103 // Get the message text associated with the VMS message code. if the cause is an OS error
104 if (!SUCCESS(status)) {
105 ERRTRANSLATE(&status, &errorMessageDescriptor);
106 strncat(errorMessageDescriptor.dsc$a_pointer, "; ",
107 MIN(strlen("; "), BUFSIZ - strlen(errorMessageDescriptor.dsc$a_pointer)));
108 }
109
110 // Add exception
111 strncat(errorMessageDescriptor.dsc$a_pointer, exception,
112 MIN(strlen(exception), BUFSIZ - strlen(errorMessageDescriptor.dsc$a_pointer)));
113
114 // If a message is specified then append it to the vms message string
115 if (message) {
116 strncat(errorMessageDescriptor.dsc$a_pointer, "; ",
117 MIN(strlen("; "), BUFSIZ - strlen(errorMessageDescriptor.dsc$a_pointer)));
118 strncat(errorMessageDescriptor.dsc$a_pointer, message,
119 MIN(strlen(message), BUFSIZ - strlen(errorMessageDescriptor.dsc$a_pointer)));
120 }
121
122 fprintf(stderr, "AIDA Exception: %s: %s\n", exception, errorMessageDescriptor.dsc$a_pointer);
123
124 // Create the fully qualified java class name of the exception to throw
125 char classToCreate[BUFSIZ] = "edu/stanford/slac/except/";
126 strcat (classToCreate, exception);
127
128 // Create the java exception class
129 jclass exceptionClass;
130 exceptionClass = (*env)->FindClass(env, classToCreate);
131 if (!exceptionClass) {
132 fprintf(stderr, "FATAL: Failed to create object of class: %s\n", classToCreate);
133 exit((int)status);
134 }
135
136 // Throw the given exception to Java server code, giving the
137 // VMS error text and supplied message as the exception text.
138 (*env)->ThrowNew(env, exceptionClass, errorMessageDescriptor.dsc$a_pointer);
139}

Referenced by aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaRequestTable(), aidaServiceInit(), aidaSetValue(), aidaSetValueWithResponse(), and aidaThrowNonOsException().

◆ aidaThrowNonOsException()

void aidaThrowNonOsException ( JNIEnv *  env,
char *  exception,
const char *  message 
)

To log any non-OS exceptions and throw back to java.

The #exception is formatted in a standard way with the optionally supplied #message. The #exception is always assumed to be from the edu.stanford.slac.except package

Parameters
envthe JNI environment. Used in all functions involving JNI
exceptionthe string representation of the exception class to throw.
messagethe optional message to attach to the exception. If NULL it is ignored.

Definition at line 75 of file aida_pva_server_helper.c.

76{
77 aidaThrow(env, 1, exception, message);
78}
void aidaThrow(JNIEnv *env, vmsstat_t status, char *exception, const char *message)
To log any exceptions and throw back to java.

References aidaThrow().

Referenced by aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaRequestStringArray(), aidaRequestTable(), aidaSetValue(), aidaSetValueWithResponse(), allocateMemory(), getClassAndValueOfMethod(), newObject(), newObjectFromClass(), pmuFromDeviceName(), tableAddColumn(), tableAddField(), tableAddLabel(), tableCreate(), toBoolean(), toBooleanArray(), toByte(), toByteArray(), toDouble(), toDoubleArray(), toFloat(), toFloatArray(), toInteger(), toIntegerArray(), toLong(), toLongArray(), toShort(), toShortArray(), toStringArray(), and toTable().

◆ allocateMemory()

void * allocateMemory ( JNIEnv *  env,
void *  source,
size_t  size,
bool  nullTerminate,
char *  message 
)

Memory Handling.

Allocate memory and copy the source to it if specified. If the null terminate flag is set null terminate the allocate space, at the last position

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
sourcesource of data to copy to newly allocated space, NULL to not copy
sizethe amount of space to allocate
nullTerminatetrue to null terminate
messagethe message to display if anything goes wrong
Returns
the allocated memory

Memory Handling.

If the null terminate flag is set null terminate the allocate space, at the last position

Parameters
envto be used to throw exceptions using aidaThrow() and aidaThrowNonOsException()
sourcesource of data to copy to newly allocated space, NULL to not copy
sizethe amount of space to allocate
nullTerminatetrue to null terminate
messagethe message to display if anything goes wrong
Returns
the allocated memory

Definition at line 629 of file aida_pva_server_helper.c.

630{
631 void* data = malloc(size);
632 if (!data) {
634 return NULL;
635 }
636 if (source) {
637 memcpy(data, source, size - (nullTerminate ? 1 : 0));
638 if (nullTerminate) {
639 *(char*)((char*)data + size - 1) = 0x0;
640 }
641 }
642 return data;
643}
#define AIDA_INTERNAL_EXCEPTION
Use this string to signal Internal Exceptions in aidaThrow()
void aidaThrowNonOsException(JNIEnv *env, char *exception, const char *message)
To log any non-OS exceptions and throw back to java.

References AIDA_INTERNAL_EXCEPTION, and aidaThrowNonOsException().

◆ ascanf()

int ascanf ( JNIEnv *  env,
Arguments arguments,
const char *  formatString,
  ... 
)

Argument Processing.

ascanf(), avscanf()

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);
int ascanf(JNIEnv *env, Arguments *arguments, const char *formatString,...)
ascanf(), avscanf()
int avscanf(JNIEnv *env, Arguments *arguments, Value *value, const char *formatString,...)
ascanf(), avscanf()
An Arguments structure stores all of the arguments passed from the request to the Native Channel Prov...
This special type represents a Value.

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

See also
avscanf() for full details.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Argument Processing.

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

See also
avscanf() for full details.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Definition at line 86 of file aida_pva_types_helper.c.

87{
88 va_list argp;
89 va_start(argp, formatString);
90 int status = vavscanf(env, arguments, NULL, formatString, argp);
91 va_end (argp);
92 return status;
93}

Referenced by aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaRequestStringArray(), aidaRequestTable(), and aidaSetValue().

◆ avscanf()

int avscanf ( JNIEnv *  env,
Arguments arguments,
Value value,
const char *  formatString,
  ... 
)

ascanf(), avscanf()

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier. For strings and arrays only the pointer needs to be pre-allocated.

The only space allocated by this function is for the strings or arrays. So callers should only free strings and arrays. Even if you provide a default value for a string the pointer will be allocated memory on exit from the function, so even then you need to free it.

Note
Only the provided pointer needs to be freed as only one allocation is made e.g.
Arguments arguments;
int *intArray;
ascanf(arguments "%da, "fooArray", &intArray);
// Do stuff
free(intArray);

String space is allocated as follows:

+------------------------+----------+----------+----------+---------+
| pointers to strings | string 1 | string 2 | string 3 | ... |
+------------------------+----------+----------+----------+---------+

Differences to scanf()


There are a number of differences from scanf() which are best described by example:

General differences

  1. Scan into simple variable/
    int n;
    ascanf("%d", "NPOS", &n);
    You must always provide the name of the variable and the pointer to the place to put the value in pairs
  2. Optional arguments. Optional arguments are specified with the o character before the format character.
    short flag = 10; // 10 is the default value
    ascanf("%ohd", "flag", &flag);

By default all arguments referenced by format specifications are considered required unless the format specification character is preceded by o. For optional arguments the pointer provided must point to the default value. In the case of arrays and strings this will be copied into allocated storage that will need to be freed as normal.

Argument names

  1. You can specify simple argument names to search for. These will simply find the named argument and extract its value.
    int simpleInt;
    ascanf(&arguments "%d, "simple", &simpleInt);
  2. You can also use dot and square brace notation to refer to complex arguments that are either arrays or complex objects. Values that are buried deep inside the json structures can be referenced in this way. e.g., given a variable named json and presented as:
    json='{"foo": {"bar": 0}}}'
    You can specify the name as "json.foo.bar" to retrieve the 0 value.
  3. Also given a variable named jsonArray and presented as
    jsonArray='[{"foo": 10}, {"bar": 20}]'
    You can specify the #p name as "jsonArray[1].bar" to retrieve the 20 value.
  4. Finally if you use the name "value", then the avscanf() function will use the supplied value parameter to get the data for that parameter
    Arguments arguments;
    Value value;
    int *intArray;
    avscanf(&arguments &value, "%da, "fooArray", &intArray);
    // Do stuff
    free(intArray);

Format Specifiers


Type specifiers

  • b : unsigned char * - interpret the input as a boolean, then extract a single byte into the corresponding variable.
    • The following translate to true
      • not 0 - integer, short, long,
      • not 0.0 - float, double
      • “true” - char string
      • “t” - char string
      • “yes” - char string
      • “y” - char string
      • !0 - short, int, long, float, or double
    • The following translate to false
      • 0 - integer, short, long,
      • 0.0 - float, double
      • “false” - char string
      • “f”- char string
      • “no”- char string
      • “n”- char string
      • 0 - short, int, long, float, or double
  • c : char * - extract a single character into the corresponding variable.
  • d : int * - extract an integer into the corresponding variable (see l & h below).
  • f : float * - extract a floating point number (see l below).
  • s : char * - extract a string of characters into allocated space and point the corresponding variable to it.
  • u : unsigned int * - extract an unsigned integer into the corresponding variable (see l & h below).

Required flag

  • o - optional precede the format with this to indicate that the argument is optional.

Prefixes

  • h - short * - preceding d will retrieve a short e.g. "%hd".
  • l - long *, double * - preceding d will retrieve a long eg. "%ld"; preceding f will retrieve a double eg. "%lf".

Suffixes

  • a - extract an array of the preceding type into a block of allocated space and point the corresponding variable to it. The variable will have an extra level of indirection than the non-array version. e.g.,
    int i;
    ascanf(..., "%d", &i);
    becomes
    int *ia, n;
    ascanf(..., "%da", &ia, &n);
    Also, you need to provide an extra parameter for each format containing an a suffix to hold the count of array elements found. The pointer will point to an int.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
valueFor the avscanf() form this parameter holds the parsed Value given to the Channel Provider endpoint.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of references in the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Synopsis

int ascanf(Arguments *arguments, const char *format, ...);
int avscanf(Arguments *arguments, Value *value, const char *format, ...);

Details

Reads data from the given arguments and stores them according to parameter format into the locations given by the additional arguments, as if scanf() was used, but reading from arguments instead of the standard input (stdin).

The additional arguments should point to already allocated objects of the type specified by their corresponding format specifier. For strings and arrays only the pointer needs to be pre-allocated.

The only space allocated by this function is for the strings or arrays. So callers should only free strings and arrays. Even if you provide a default value for a string the pointer will be allocated memory on exit from the function, so even then you need to free it.

Note
Only the provided pointer needs to be freed as only one allocation is made e.g.
Arguments arguments;
int *intArray;
ascanf(arguments "%da, "fooArray", &intArray);
// Do stuff
free(intArray);

String space is allocated as follows:

+------------------------+----------+----------+----------+---------+
| pointers to strings | string 1 | string 2 | string 3 | ... |
+------------------------+----------+----------+----------+---------+

Differences to scanf()


There are a number of differences from scanf() which are best described by example:

General differences

  1. Scan into simple variable/
    int n;
    ascanf("%d", "NPOS", &n);
    You must always provide the name of the variable and the pointer to the place to put the value in pairs
  2. Optional arguments. Optional arguments are specified with the o character before the format character.
    short flag = 10; // 10 is the default value
    ascanf("%ohd", "flag", &flag);

By default all arguments referenced by format specifications are considered required unless the format specification character is preceded by o. For optional arguments the pointer provided must point to the default value. In the case of arrays and strings this will be copied into allocated storage that will need to be freed as normal.

Argument names

  1. You can specify simple argument names to search for. These will simply find the named argument and extract its value.
    int simpleInt;
    ascanf(&arguments "%d, "simple", &simpleInt);
  2. You can also use dot and square brace notation to refer to complex arguments that are either arrays or complex objects. Values that are buried deep inside the json structures can be referenced in this way. e.g., given a variable named json and presented as:
    json='{"foo": {"bar": 0}}}'
    You can specify the name as "json.foo.bar" to retrieve the 0 value.
  3. Also given a variable named jsonArray and presented as
    jsonArray='[{"foo": 10}, {"bar": 20}]'
    You can specify the #p name as "jsonArray[1].bar" to retrieve the 20 value.
  4. Finally if you use the name "value", then the avscanf() function will use the supplied value parameter to get the data for that parameter
    Arguments arguments;
    Value value;
    int *intArray;
    avscanf(&arguments &value, "%da, "fooArray", &intArray);
    // Do stuff
    free(intArray);

Format Specifiers


Type specifiers

  • b : unsigned char * - interpret the input as a boolean, then extract a single byte into the corresponding variable.
    • The following translate to true
      • not 0 - integer, short, long,
      • not 0.0 - float, double
      • “true” - char string
      • “t” - char string
      • “yes” - char string
      • “y” - char string
      • !0 - short, int, long, float, or double
    • The following translate to false
      • 0 - integer, short, long,
      • 0.0 - float, double
      • “false” - char string
      • “f”- char string
      • “no”- char string
      • “n”- char string
      • 0 - short, int, long, float, or double
  • c : char * - extract a single character into the corresponding variable.
  • d : int * - extract an integer into the corresponding variable (see l & h below).
  • f : float * - extract a floating point number (see l below).
  • s : char * - extract a string of characters into allocated space and point the corresponding variable to it.
  • u : unsigned int * - extract an unsigned integer into the corresponding variable (see l & h below).

Required flag

  • o - optional precede the format with this to indicate that the argument is optional.

Prefixes

  • h - short * - preceding d will retrieve a short e.g. "%hd".
  • l - long *, double * - preceding d will retrieve a long eg. "%ld"; preceding f will retrieve a double eg. "%lf".

Suffixes

  • a - extract an array of the preceding type into a block of allocated space and point the corresponding variable to it. The variable will have an extra level of indirection than the non-array version. e.g.,
    int i;
    ascanf(..., "%d", &i);
    becomes
    int *ia, n;
    ascanf(..., "%da", &ia, &n);
    Also, you need to provide an extra parameter for each format containing an a suffix to hold the count of array elements found. The pointer will point to an int.
Parameters
envThe JNI environment. Used in all functions involving JNI
argumentsArguments that the function processes as its source to retrieve the data.
valueFor the avscanf() form this parameter holds the parsed Value given to the Channel Provider endpoint.
formatStringC string that contains a format string as described above
...Depending on the format string, the function may expect a sequence of additional arguments, containing pairs of names and pointers to allocated storage (except as indicated above), where the interpretation of the extracted data is stored with the appropriate type. There should be at least as many pairs of these arguments as the number of references in the format specifiers. Additional arguments are ignored by the function
Returns
EXIT_SUCCESS if all required arguments were read and no errors occurred, otherwise EXIT_FAILURE
Exceptions
MissingRequiredArgumentExceptionif one of the required arguments are missing

Definition at line 250 of file aida_pva_types_helper.c.

251{
252 va_list argp;
253 va_start(argp, formatString);
254 int status = vavscanf(env, arguments, value, formatString, argp);
255 va_end (argp);
256 return status;
257}

Referenced by aidaSetValue(), and aidaSetValueWithResponse().

◆ endsWith()

int endsWith ( const char *  str,
char *  suffix 
)

String Handling.

Check if a string str, ends with another string suffix.

Parameters
strthe string to check.
suffixthe suffix to look for at the end of str
Returns
true if str ends with suffix. false

String Handling.

Parameters
strthe string to check.
suffixthe suffix to look for at the end of str
Returns
true if str ends with suffix. false

Definition at line 148 of file aida_pva_server_helper.c.

149{
150 if (!str || !suffix) {
151 return false;
152 }
153 size_t lenstr = strlen(str);
154 size_t lenSuffix = strlen(suffix);
155 if (lenSuffix > lenstr)
156 return false;
157 return !strncasecmp(str + lenstr - lenSuffix, suffix, lenSuffix);
158}

Referenced by aidaRequestBoolean(), aidaRequestBooleanArray(), aidaRequestByte(), aidaRequestByteArray(), aidaRequestDouble(), aidaRequestDoubleArray(), aidaRequestFloat(), aidaRequestFloatArray(), aidaRequestInteger(), aidaRequestIntegerArray(), aidaRequestLong(), aidaRequestLongArray(), aidaRequestShort(), aidaRequestShortArray(), aidaRequestString(), aidaRequestStringArray(), aidaRequestTable(), and aidaSetValueWithResponse().

◆ groupNameFromUri()

int groupNameFromUri ( char  groupName[],
const char *  uri 
)

URI Handling for group, secn, pmu and slacName.

Get the Display group name from a URI.

Parameters
groupNamepre-allocated space to store the group name
urithe new format AIDA PV name
Returns
EXIT_SUCCESS if all goes well EXIT_FAILURE otherwise

URI Handling for group, secn, pmu and slacName.

Parameters
groupNamepre-allocated space to store the group name
urithe new format AIDA PV name
Returns
EXIT_SUCCESS if all goes well EXIT_FAILURE otherwise

Definition at line 472 of file aida_pva_server_helper.c.

473{
474 strcpy(groupName, uri);
475 char* groupNameEnd = strrchr(groupName, ':');
476 if (groupNameEnd) {
477 *groupNameEnd = 0x0;
478 }
479 return EXIT_SUCCESS;
480}

◆ init()

vmsstat_t init ( const char *  processName,
bool  initMessageServices 
)

Initialisation.

Call standalone_init() and set development mode flag.

Parameters
processNamethe name of the process being initialised
initMessageServicesboolean to determine if the message service needs to be initialised
Returns
vms status code

Initialisation.

Parameters
processNamethe name of the process being initialised
initMessageServicesboolean to determine if the message service needs to be initialised
Returns
vms status code

Definition at line 50 of file aida_pva_server_helper.c.

51{
52 const struct msginit msg_init_s = { 1, /* init msg service */
53 1 }; /* init slcnet */
54
55 vmsstat_t status;
56 $DESCRIPTOR (PROCESS_NAME, processName); // Ignored in standalone_init() call
57
58 status = STANDALONE_INIT(&PROCESS_NAME, &((long)(TRUE)),
59 initMessageServices ? &msg_init_s : NULL,
60 &((long)(FALSE)), &((long)(FALSE)));
61
62 return status;
63}
unsigned long int STANDALONE_INIT(const struct dsc$descriptor_s *name, const long int *dbinit, const struct msginit *msginit, const long int *query, const long int *set)
standalone init is used to initialise standalone processes

References STANDALONE_INIT().

Referenced by aidaServiceInit().

◆ pmuFromDeviceName()

int pmuFromDeviceName ( JNIEnv *  env,
char *  device,
char *  primary,
char *  micro,
int4u *  unit 
)

Get primary, micro and unit from a device name.

Parameters
envthe JNI environment. Used in all functions involving JNI
devicepre-allocated space to store the device
primarypre-allocated space to store the primary
micropre-allocated space to store the micro
unitpre-allocated space to store the unit
Parameters
envthe JNI environment. Used in all functions involving JNI
devicepre-allocated space to store the device
primarypre-allocated space to store the primary
micropre-allocated space to store the micro
unitpre-allocated space to store the unit

Definition at line 542 of file aida_pva_server_helper.c.

543{
544 // Copy each part to the provided variables
545 char* nextPart = strtok(device, ":");
546 unsigned long len;
547 if (nextPart) {
548 len = strlen(nextPart);
549 if (len != 4) {
550 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "Device name is not valid");
551 return EXIT_FAILURE;
552 }
553 memcpy(primary, nextPart, PRIM_LEN);
554 nextPart = strtok(NULL, ":");
555 if (nextPart) {
556 len = strlen(nextPart);
557 if (len != 4 || !isdigit(nextPart[2]) || !isdigit(nextPart[3])) {
558 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "Device name is not valid");
559 return EXIT_FAILURE;
560 }
561 memcpy(micro, nextPart, MICRO_LEN);
562 nextPart = strtok(NULL, ":");
563 if (nextPart) {
564 len = strlen(nextPart);
565 if (len < 1 || len > 4 || !isdigit(nextPart[0]) || (len > 1 && !isdigit(nextPart[1]))
566 || (len > 2 && !isdigit(nextPart[2])) || (len > 3 && !isdigit(nextPart[3]))) {
567 aidaThrowNonOsException(env, UNABLE_TO_GET_DATA_EXCEPTION, "Device name is not valid");
568 return EXIT_FAILURE;
569 }
570 *unit = (int4u)atol(nextPart);
571 }
572 }
573 }
574 return EXIT_SUCCESS;
575}
#define UNABLE_TO_GET_DATA_EXCEPTION
Use this string to signal Exceptions when trying to Get Data in aidaThrow()
#define PRIM_LEN
The length of the primary part of a PMU string.
Definition: aida_pva_uri.h:24
#define MICRO_LEN
The length of the micro part of a PMU string.
Definition: aida_pva_uri.h:28

References aidaThrowNonOsException(), MICRO_LEN, PRIM_LEN, and UNABLE_TO_GET_DATA_EXCEPTION.

Referenced by aidaRequestTable().

◆ pmuStringFromUri()

void pmuStringFromUri ( char *  pmuString,
const char *  uri 
)

Get the pmu part of a URI.

Parameters
pmuStringthe pre-allocated space to store the pmu string
urithe new format AIDA PV name
Parameters
pmuStringthe pre-allocated space to store the pmu string
urithe new format AIDA PV name

Definition at line 523 of file aida_pva_server_helper.c.

524{
525 unsigned long pmuEnd = strrchr(uri, ':') - uri;
526 if (pmuEnd >= MAX_URI_LEN) {
527 pmuEnd = MAX_URI_LEN - 1;
528 }
529 strncpy(pmuString, uri, pmuEnd);
530 pmuString[pmuEnd] = 0x0;
531}
#define MAX_URI_LEN
The maximum length of a URI.
Definition: aida_pva_uri.h:20

References MAX_URI_LEN.

◆ releaseArray()

void releaseArray ( Array  array)

Free up any memory allocated the given scalar array.

Parameters
arraythe given scalar array
Parameters
arraythe given scalar array

Definition at line 893 of file aida_pva_jni_helper.c.

893 {
894 if (array.count && array.items) {
895 free(array.items);
896 array.count = 0;
897 array.items = NULL;
898 }
899}
void * items
The items in this array.
int count
The number of items in this array.

References Array::count, and Array::items.

Referenced by toBooleanArray(), toByteArray(), toDoubleArray(), toFloatArray(), toIntegerArray(), toLongArray(), and toShortArray().

◆ releasePvAndArguments()

void releasePvAndArguments ( JNIEnv *  env,
jstring  uri,
const char *  pv,
Arguments  arguments 
)

Free up any memory allocated for the given pv and arguments.

Parameters
argumentsthe given arguments
Parameters
argumentsthe given arguments

Definition at line 872 of file aida_pva_jni_helper.c.

872 {
873 if (pv) {
874 (*env)->ReleaseStringUTFChars(env, uri, pv);
875 }
876 if (arguments.floatingPointValues && arguments.floatingPointValuesCount) {
877 free(arguments.floatingPointValues);
878 arguments.floatingPointValuesCount = 0;
879 arguments.floatingPointValues = NULL;
880 }
881 if (arguments.argumentCount && arguments.arguments) {
882 free(arguments.arguments);
883 arguments.argumentCount = 0;
884 arguments.arguments = NULL;
885 }
886}
int argumentCount
The number of arguments sent with this request.
int floatingPointValuesCount
The number of floating point numbers in the arguments of this request.
Argument * arguments
The array of Arguments.
FloatingPointValue * floatingPointValues
The array of FloatingPointValue.

References Arguments::argumentCount, Arguments::arguments, Arguments::floatingPointValues, and Arguments::floatingPointValuesCount.

◆ releaseStringArray()

void releaseStringArray ( StringArray  array)

Free up any memory allocated for string arrays.

Parameters
array

Definition at line 905 of file aida_pva_jni_helper.c.

905 {
906 if (array.count && array.items) {
907 free(array.items);
908 array.count = 0;
909 array.items = NULL;
910 }
911}
int count
The number of items in this array.
char ** items
The items in this array - pointers to the strings you allocate.

References StringArray::count, and StringArray::items.

Referenced by toStringArray().

◆ releaseTable()

void releaseTable ( Table  table)

Free up any memory allocated for the given table.

Parameters
tablethe given tables
Parameters
tablethe given tables

Definition at line 918 of file aida_pva_jni_helper.c.

918 {
919 if (table.columnCount) {
920 if (table.ppData) {
921 for (int column = 0; column < table._currentColumn; column++) {
922 if (table.ppData[column]) {
923 free(table.ppData[column]);
924 table.ppData[column] = NULL;
925 }
926 }
927 free(table.ppData);
928 table.ppData = NULL;
929
930 if (table.types) {
931 free(table.types);
932 table.types = NULL;
933 }
934 table._currentColumn = 0;
935 }
936
937 // Free field names
938 if (table.ppFields) {
939 for (int column = 0; column < table._currentField; column++) {
940 if (table.ppFields[column]) {
941 free(table.ppFields[column]);
942 table.ppFields[column] = NULL;
943 }
944 }
945 free(table.ppFields);
946 table._currentField = 0;
947 table.ppFields = NULL;
948 }
949
950 // Free label names
951 if (table.ppLabels) {
952 for (int column = 0; column < table._currentLabel; column++) {
953 if (table.ppLabels[column]) {
954 free(table.ppLabels[column]);
955 table.ppLabels[column] = NULL;
956 }
957 }
958 free(table.ppLabels);
959 table._currentLabel = 0;
960 table.ppLabels = NULL;
961 }
962
963 table.columnCount = 0;
964 }
965}
int columnCount
number of columns in table
char ** ppLabels
the overridden label names. if null, not overridden. If not null then array of pointers to allocated ...
int _currentLabel
For internal use by addLabel() etc.
char ** ppFields
the overridden field names. if null, not overridden. If not null then array of pointers to allocated ...
Type * types
the scalar type of each column, one of BOOLEAN, BYTE, SHORT, INTEGER, LONG, FLOAT,...
void ** ppData
the data. an array of [rows][columns]
int _currentField
For internal use by addField() etc.
int _currentColumn
For internal use by addColumn() etc.

References Table::_currentColumn, Table::_currentField, Table::_currentLabel, Table::columnCount, Table::ppData, Table::ppFields, Table::ppLabels, and Table::types.

Referenced by toTable().

◆ releaseValue()

void releaseValue ( Value  value)

Release all allocated memory in the given value.

Parameters
valuethe given value'
Parameters
valuethe given value'

Definition at line 432 of file aida_pva_jni_helper.c.

432 {
433 // Only free json values because the string values will be freed with the arguments directly
434 if (value.type == AIDA_JSON_TYPE) {
435 json_value_free(value.value.jsonValue);
436 value.type = AIDA_NO_TYPE;
437 }
438}
@ AIDA_JSON_TYPE
Argument was provided as JSON text.
@ AIDA_NO_TYPE
Used to indicate that no type was provided as an argument.
ValueContents value
The value's contents, either a string or parsed json.
Type type
AIDA_STRING_TYPE or AIDA_JSON_TYPE.
json_value * jsonValue
The parsed json_value of this Value if the type is AIDA_JSON_TYPE.

References AIDA_JSON_TYPE, AIDA_NO_TYPE, ValueContents::jsonValue, Value::type, and Value::value.

◆ secnFromUri()

void secnFromUri ( const char *  uri,
int4u *  secn 
)

Get secondary from pseudo secondary (containing a colon) number from URI.

e.g. BD01:BEND:BDES => BEND as int4u

Parameters
urithe new format AIDA PV name
secnpointer to an int to store the secondary as a number

Get secondary from pseudo secondary (containing a colon) number from URI.

BD01:BEND:BDES => BEND as int4u

Parameters
urithe new format AIDA PV name
secnpointer to an int to store the secondary as a number

Definition at line 489 of file aida_pva_server_helper.c.

490{
491 char uriCopy[strlen(uri) + 1];
492 strcpy(uriCopy, uri);
493 char* secondary = strrchr(uriCopy, ':');
494 if (secondary) {
495 memcpy(secn, secondary + 1, sizeof(int4u));
496 return;
497 }
498 fprintf(stderr, "Warning: Found corrupt URI when trying to extract secn: %s\n", uri);
499 *secn = 0;
500}

◆ secondaryFromUri()

const char * secondaryFromUri ( const char *  uri)

Get secondary from URI.

Just points into the URI so don't go messing with it.

Parameters
urithe new format AIDA PV name

Just points into the URI so don't go messing with it

Parameters
urithe new format AIDA PV name

Definition at line 507 of file aida_pva_server_helper.c.

508{
509 char* secondary = strrchr(uri, ':');
510 if (!secondary) {
511 fprintf(stderr, "Warning: Secondary not found in uri: %s\n", uri);
512 return uri;
513 }
514 return secondary + 1;
515}

Referenced by aidaRequestStringArray().

◆ startsWith()

int startsWith ( const char *  str,
char *  prefix 
)

Check if a string starts with another string.

Parameters
str
prefix
Returns
true if string starts with prefix

Definition at line 166 of file aida_pva_server_helper.c.

167{
168 if (!str || !prefix) {
169 return false;
170 }
171 size_t lenstr = strlen(str);
172 size_t lenPrefix = strlen(prefix);
173 if (lenPrefix > lenstr)
174 return false;
175 return !strncasecmp(str, prefix, lenPrefix);
176}

Referenced by aidaRequestLong(), aidaRequestShort(), aidaRequestString(), aidaRequestStringArray(), and aidaSetValue().

◆ tableAddColumn()

void tableAddColumn ( JNIEnv *  env,
Table table,
Type  type,
void *  data,
bool  ieeeFormat 
)

Add a column of arbitrary type to a Table.

Add the given data to the column assuming that the data has a number of rows that corresponds to the Table's rowCount. Memory will be allocated for the data of the column so the data buffer presented can be freed up after calling this function.

Note
Don't call this to add strings to the Table. Use tableAddStringColumn() for that.

The framework will release all memory associated with a Table when you return from your API implementation.

Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
typethe type of this Table column.
datathe data to add to this column, a buffer of sizeof(type) * table->rowCount size.
ieeeFormattrue if the data provided is already in ieee format. If the data is not in ieee format, usually because it has been retrieved from some backend system, this function will convert it to ieee format unless this parameter is set to true.
See also
tableCreate(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
Table table = tableCreate(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
return table;
#define ON_EXCEPTION_RETURN_(_r)
Check to see if an exception has been raised, and return the given return value.
@ AIDA_FLOAT_TYPE
Represents a float.
Table tableCreate(JNIEnv *env, int rows, int columns)
Make a Table for return to client.
void tableAddColumn(JNIEnv *env, Table *table, Type type, void *data, bool ieeeFormat)
Add a column of arbitrary type to a Table.
Table structure.
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 755 of file aida_pva_types_helper.c.

756{
757 // Table full?
758 if (table->_currentColumn >= table->columnCount) {
760 "Internal Error: more columns added than table size");
761 return;
762 }
763
764 // No Data supplied ?
765 if (!data) {
767 "Internal Error: Attempt to add column with no data");
768 return;
769 }
770
771 // Correct type for tables
772 type = tableArrayTypeOf(type);
773
774 // Set column type, and allocate space
775 allocateTableColumn(env, table, type, tableElementSizeOfOf(type));
777
778 // Rest of processing for strings is done in addStringColumn
779 if (type == AIDA_STRING_ARRAY_TYPE) {
780 return;
781 }
782
783 if (!ieeeFormat) {
784 // Convert float values if float array
785 if (type == AIDA_FLOAT_ARRAY_TYPE) {
786 CONVERT_FROM_VMS_FLOAT(((float*)data), (int2u)table->rowCount)
787 }
788
789 // Convert double values if double array
790 if (type == AIDA_DOUBLE_ARRAY_TYPE) {
791 CONVERT_FROM_VMS_DOUBLE((double*)data, (int2u)table->rowCount)
792 }
793 }
794
795 // Add data to column
796 for (int row = 0; row < table->rowCount; row++) {
797 // add data and increment pointer based on type
798 switch (type) {
801 ((unsigned char*)(table->ppData[table->_currentColumn]))[row] = ((unsigned char*)data)[row];
802 break;
804 ((short*)(table->ppData[table->_currentColumn]))[row] = ((short*)data)[row];
805 break;
807 ((int*)(table->ppData[table->_currentColumn]))[row] = ((int*)data)[row];
808 break;
810 ((long*)(table->ppData[table->_currentColumn]))[row] = ((long*)data)[row];
811 break;
813 ((float*)(table->ppData[table->_currentColumn]))[row] = ((float*)data)[row];
814 break;
816 ((double*)(table->ppData[table->_currentColumn]))[row] = ((double*)data)[row];
817 break;
818 default:
820 "Internal Error: Call to tableAddColumn() un-supported type");
821 return;
822 }
823 }
824
825 table->_currentColumn++;
826}
#define CONVERT_FROM_VMS_FLOAT(_float, _count)
Convert in-place, floating point numbers from VMS to ieee format.
#define CONVERT_FROM_VMS_DOUBLE(_double, _count)
Convert in-place, doubles from VMS to ieee format.
#define ON_EXCEPTION_RETURN_VOID
Check to see if an exception has been raised, and return void,.
@ AIDA_SHORT_ARRAY_TYPE
Represents a short array.
@ AIDA_FLOAT_ARRAY_TYPE
Represents a float array.
@ AIDA_BOOLEAN_ARRAY_TYPE
Represents a boolean array.
@ AIDA_INTEGER_ARRAY_TYPE
Represents an integer array.
@ AIDA_BYTE_ARRAY_TYPE
Represents a byte array.
@ AIDA_LONG_ARRAY_TYPE
Represents a long array.
@ AIDA_STRING_ARRAY_TYPE
Represents a string array.
@ AIDA_DOUBLE_ARRAY_TYPE
Represents a double array.
int rowCount
number of rows in table

References Table::_currentColumn, AIDA_BOOLEAN_ARRAY_TYPE, AIDA_BYTE_ARRAY_TYPE, AIDA_DOUBLE_ARRAY_TYPE, AIDA_FLOAT_ARRAY_TYPE, AIDA_INTEGER_ARRAY_TYPE, AIDA_LONG_ARRAY_TYPE, AIDA_SHORT_ARRAY_TYPE, AIDA_STRING_ARRAY_TYPE, aidaThrowNonOsException(), Table::columnCount, CONVERT_FROM_VMS_DOUBLE, CONVERT_FROM_VMS_FLOAT, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and UNABLE_TO_GET_DATA_EXCEPTION.

Referenced by aidaRequestTable(), aidaSetValueWithResponse(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowShortColumn(), and tableAddStringColumn().

◆ tableAddField()

void tableAddField ( JNIEnv *  env,
Table table,
char *  fieldName 
)

Add a dynamic field to a table.

See also
tableCreateDynamic
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
fieldNameThe name of the field to add

Definition at line 828 of file aida_pva_types_helper.c.

828 {
829 // Table full?
830 if (table->_currentField >= table->columnCount) {
832 "Internal Error: more fields added than table size");
833 return;
834 }
835
836 // No Data supplied ?
837 if (!fieldName || !*fieldName) {
839 "Internal Error: Attempt to add empty field name");
840 return;
841 }
842
843 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, table->ppFields[table->_currentField], fieldName, "table field names")
844 table->_currentField++;
845}
#define ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(_env, _var, _string, _purpose)
Allocate memory for a string and copy the given string into this allocated space The specified variab...

References Table::_currentField, aidaThrowNonOsException(), ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, Table::columnCount, Table::ppFields, and UNABLE_TO_GET_DATA_EXCEPTION.

◆ tableAddFixedWidthStringColumn()

void tableAddFixedWidthStringColumn ( JNIEnv *  env,
Table table,
char *  data,
int  width 
)

Add fixed-width string data to a column in the given Table.

This reads data from an allocated space that is rows * width with each string occupying width characters Though the strings are null terminated if there is space, there is no guarantee so an exact number of bytes is copied. Each string in the Table is allocated maximally.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a pointer to char buffer containing the fixed length strings. The strings are arranged in contiguous blocks width long.
widththe width of the strings
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Add fixed-width string data to a column in the given Table.

Each string in the Table is allocated maximally.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a pointer to char buffer containing the fixed length strings. The strings are arranged in contiguous blocks width long.
widththe width of the strings
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 955 of file aida_pva_types_helper.c.

956{
957 tableAddColumn(env, table, AIDA_STRING_ARRAY_TYPE, data, false);
959
960 // allocate data for each string too
961 char** stringArray = table->ppData[table->_currentColumn];
962 char* dataPointer = (char*)data;
963 for (int row = 0; row < table->rowCount; row++, dataPointer += width) {
964 ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID(env, stringArray[row], dataPointer, width + 1, "table strings")
965 stringArray[row][width] = 0x0;
966 }
967
968 table->_currentColumn++;
969}
#define ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID(_env, _var, _string, _size, _purpose)
Allocate space for a fixed length string and copy date from the given string into the newly allocated...

References Table::_currentColumn, AIDA_STRING_ARRAY_TYPE, ALLOCATE_FIXED_LENGTH_STRING_AND_ON_ERROR_RETURN_VOID, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddLabel()

void tableAddLabel ( JNIEnv *  env,
Table table,
char *  labelName 
)

Add a dynamic column to a table.

See also
tableCreateDynamic
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
labelNamethe label name to add

Definition at line 847 of file aida_pva_types_helper.c.

847 {
848 // Table full?
849 if (table->_currentLabel >= table->columnCount) {
851 "Internal Error: more labels added than table size");
852 return;
853 }
854
855 // No Data supplied ?
856 if (!labelName || !*labelName) {
858 "Internal Error: Attempt to add empty label name");
859 return;
860 }
861
862 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, table->ppLabels[table->_currentLabel], labelName, "table label names")
863 table->_currentLabel++;
864}

References Table::_currentLabel, aidaThrowNonOsException(), ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, Table::columnCount, Table::ppLabels, and UNABLE_TO_GET_DATA_EXCEPTION.

◆ tableAddSingleRowBooleanColumn()

void tableAddSingleRowBooleanColumn ( JNIEnv *  env,
Table table,
unsigned char  data 
)

Add a boolean column to a Table with only one row.

This function will allocate the required memory for the single unsigned char that is required.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a pointer to an unsigned char.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 996 of file aida_pva_types_helper.c.

997{
998 tableAddColumn(env, table, AIDA_BOOLEAN_TYPE, &data, false);
999}
@ AIDA_BOOLEAN_TYPE
Represents a boolean.

References AIDA_BOOLEAN_TYPE, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddSingleRowByteColumn()

void tableAddSingleRowByteColumn ( JNIEnv *  env,
Table table,
unsigned char  data 
)

Add a byte column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, an unsigned char.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),
Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, an unsigned char.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1025 of file aida_pva_types_helper.c.

1026{
1027 tableAddColumn(env, table, AIDA_BYTE_TYPE, &data, false);
1028}
@ AIDA_BYTE_TYPE
Represents a byte.

References AIDA_BYTE_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowDoubleColumn()

void tableAddSingleRowDoubleColumn ( JNIEnv *  env,
Table table,
double  data,
bool  ieeeDouble 
)

Add a double column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a double.
ieeeDoubleTrue if the data is in ieee format, otherwise the double precision floating point number is converted from VMS to ieee format.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowStringColumn(),

Definition at line 1175 of file aida_pva_types_helper.c.

1176{
1177 tableAddColumn(env, table, AIDA_DOUBLE_TYPE, &data, ieeeDouble);
1178}
@ AIDA_DOUBLE_TYPE
Represents a double.

References AIDA_DOUBLE_TYPE, and tableAddColumn().

Referenced by aidaRequestTable(), and aidaSetValueWithResponse().

◆ tableAddSingleRowFloatColumn()

void tableAddSingleRowFloatColumn ( JNIEnv *  env,
Table table,
float  data,
bool  ieeeFloat 
)

Add a float column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a float.
ieeeFloatTrue if the data is in ieee format, otherwise the given floating point number is converted from VMS to ieee format.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),
Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a float.
ieeeFloatTrue if the data is in ieee format, otherwise the given floating point number is converted from VMS to ieee format.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1144 of file aida_pva_types_helper.c.

1145{
1146 tableAddColumn(env, table, AIDA_FLOAT_TYPE, &data, ieeeFloat);
1147}

References AIDA_FLOAT_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowIntegerColumn()

void tableAddSingleRowIntegerColumn ( JNIEnv *  env,
Table table,
int  data 
)

Add a integer column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column, an int
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1083 of file aida_pva_types_helper.c.

1084{
1085 tableAddColumn(env, table, AIDA_INTEGER_TYPE, &data, false);
1086}
@ AIDA_INTEGER_TYPE
Represents an integer.

References AIDA_INTEGER_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowLongColumn()

void tableAddSingleRowLongColumn ( JNIEnv *  env,
Table table,
long  data 
)

Add a long column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column. A long value
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),
Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column. A long value
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1113 of file aida_pva_types_helper.c.

1114{
1115 tableAddColumn(env, table, AIDA_LONG_TYPE, &data, false);
1116}
@ AIDA_LONG_TYPE
Represents a long.

References AIDA_LONG_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowShortColumn()

void tableAddSingleRowShortColumn ( JNIEnv *  env,
Table table,
short  data 
)

Add a short column to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tableThe Table to add the column to.
dataThe data to add to this column, a short.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Definition at line 1054 of file aida_pva_types_helper.c.

1055{
1056 tableAddColumn(env, table, AIDA_SHORT_TYPE, &data, false);
1057}
@ AIDA_SHORT_TYPE
Represents a short.

References AIDA_SHORT_TYPE, and tableAddColumn().

Referenced by aidaRequestTable().

◆ tableAddSingleRowStringColumn()

void tableAddSingleRowStringColumn ( JNIEnv *  env,
Table table,
char *  data 
)

Add a string column to a Table with only one row.

This is a shortcut Table function that simplifies adding a string to a Table with only one row.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the column to.
datathe data to add to this column. A single string.
See also
tableCreate(), tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(),

Definition at line 1205 of file aida_pva_types_helper.c.

1206{
1207 tableAddStringColumn(env, table, &data);
1208}
void tableAddStringColumn(JNIEnv *env, Table *table, char **data)
Add a String column to the given Table.

References tableAddStringColumn().

Referenced by aidaRequestTable().

◆ tableAddStringColumn()

void tableAddStringColumn ( JNIEnv *  env,
Table table,
char **  data 
)

Add a String column to the given Table.

This reads data from a buffer that is itself a list of pointers to strings. We allocate just enough space to store the strings in our Table. This is allocated in one buffer so there is only one pointer to release.

Note
The framework will release all memory associated with a Table when you return from your API implementation.
Parameters
envThe JNI environment. Used in all functions involving JNI.
tablethe Table to add the string column to.
datathe data to add to this column, a buffer of sizeof(char *) * table->rowCount size. This will contain the strings to be added to the Table.
See also
tableCreate(), tableAddColumn(), tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a single column, one row Table, add data, and return.

int rows = 1, columns = 1;
char* namesData[rows];
namesData[0] = "NAME";
Table table = tableCreate(env, rows, columns);
tableAddStringColumn(env, &table, namesData);
return table;
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 912 of file aida_pva_types_helper.c.

913{
914 tableAddColumn(env, table, AIDA_STRING_ARRAY_TYPE, data, false);
916
917 // allocate data for each string too
918 char** stringArray = table->ppData[table->_currentColumn];
919 for (int row = 0; row < table->rowCount; row++, data++) {
920 ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID(env, stringArray[row], *data, "table strings")
921 }
922
923 table->_currentColumn++;
924}

References Table::_currentColumn, AIDA_STRING_ARRAY_TYPE, ALLOCATE_STRING_AND_ON_ERROR_RETURN_VOID, ON_EXCEPTION_RETURN_VOID, Table::ppData, Table::rowCount, and tableAddColumn().

Referenced by aidaRequestTable(), and tableAddSingleRowStringColumn().

◆ tableCreate()

Table tableCreate ( JNIEnv *  env,
int  rows,
int  columns 
)

Table Handling.

Make a Table for return to client. This is the first call that needs to be made to return a Table. This will create a Table with the specified the number of rows and columns. You need to call tableAddColumn(), tableAddStringColumn(), or any of the other special tableAdd functions to add columns to the Table before returning it.

Parameters
envThe JNI environment. Used in all functions involving JNI.
rowsthe number of rows to create the Table with.
columnsthe number of columns to create the Table with,
Returns
the newly created Table
See also
tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
Table table = tableCreate(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
return table;
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Table Handling.

This is the first call that needs to be made to return a Table. This will create a Table with the specified the number of rows and columns. You need to call tableAddColumn(), tableAddStringColumn(), or any of the other special tableAdd functions to add columns to the Table before returning it.

Parameters
envThe JNI environment. Used in all functions involving JNI.
rowsthe number of rows to create the Table with.
columnsthe number of columns to create the Table with,
Returns
the newly created Table
See also
tableAddColumn(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
Table table = tableCreate(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
return table;
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 672 of file aida_pva_types_helper.c.

673{
674 Table table;
675 memset(&table, 0, sizeof(table));
676 table._currentColumn = 0; // Reset current column so that any addColumn() calls are correct
677 table.columnCount = 0;
678
679 if (rows <= 0) {
680 aidaThrowNonOsException(env, AIDA_INTERNAL_EXCEPTION, "Attempt to allocate a zero length table");
681 return table;
682 }
683
684 // Allocate space for the table columns and column types
685 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppData, columns * sizeof(void*), "table columns", table)
686 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.types, columns * sizeof(Type*), "table column types", table)
687 table.rowCount = rows;
688 table.columnCount = columns;
689 return table;
690}
#define ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(_env, _var, _size, _purpose, _r)
Allocate memory and on error return the given value.
Type
The definition of Aida Types.

References Table::_currentColumn, AIDA_INTERNAL_EXCEPTION, aidaThrowNonOsException(), ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, Table::columnCount, Table::ppData, Table::rowCount, and Table::types.

Referenced by aidaRequestTable(), aidaSetValueWithResponse(), and tableCreateDynamic().

◆ tableCreateDynamic()

Table tableCreateDynamic ( JNIEnv *  env,
int  rows,
int  columns 
)

Make a Dynamic Table for return to client.

This is the first call that needs to be made to return a Dynamic Table. This will create a Table with the specified the number of rows and columns. You need to call tableAddColumn(), tableAddStringColumn(), tableAddField(), tableAddLabel(), or any of the other special tableAdd functions to add columns to the Table before returning it. Calling tableAddField(), and tableAddLabel() are mandatory

Parameters
envThe JNI environment. Used in all functions involving JNI.
rowsthe number of rows to create the Table with.
columnsthe number of columns to create the Table with,
Returns
the newly created Table
See also
tableAddColumn(), tableAddField(), tableAddLabel(), tableAddStringColumn() tableAddFixedWidthStringColumn(), tableAddSingleRowBooleanColumn(), tableAddSingleRowByteColumn(), tableAddSingleRowShortColumn(), tableAddSingleRowIntegerColumn(), tableAddSingleRowLongColumn(), tableAddSingleRowFloatColumn(), tableAddSingleRowDoubleColumn(), tableAddSingleRowStringColumn(),

Example

Create a two column, two row Table, Set Field names, and labels, add data, and return.

int rows = 2, columns = 2;
float xData[rows] = { 1.0f, 2.0f }, yData[rows] = { 7.0f, 8.0f };
char *fields[columns] = { "field1", "field2" };
char *labels[columns] = { "label1", "label2" };
Table table = tableCreateDynamic(env, rows, columns);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, xData, true);
tableAddField(env, &table, fields[0]);
tableAddLabel(env, &table, labels[0]);
tableAddColumn(env, &table, AIDA_FLOAT_TYPE, yData, true);
tableAddField(env, &table, fields[1]);
tableAddLabel(env, &table, labels[1]);
return table;
void tableAddField(JNIEnv *env, Table *table, char *fieldName)
Add a dynamic field to a table.
void tableAddLabel(JNIEnv *env, Table *table, char *labelName)
Add a dynamic column to a table.
Table tableCreateDynamic(JNIEnv *env, int rows, int columns)
Make a Dynamic Table for return to client.
Note
You need to call ON_EXCEPTION_RETURN_(table) after each call to make sure that no exception was raised.

Definition at line 692 of file aida_pva_types_helper.c.

692 {
693 Table table = tableCreate(env, rows, columns);
695
696 table._currentField = 0; // Reset current field so that any addField() calls are correct
697 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppFields, columns * sizeof(char*), "table fields", table)
698 table._currentLabel = 0; // Reset current label so that any addLabel() calls are correct
699 ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_(env, table.ppLabels, columns * sizeof(char*), "table fields", table)
700 return table;
701}

References Table::_currentField, Table::_currentLabel, ALLOCATE_MEMORY_AND_ON_ERROR_RETURN_, ON_EXCEPTION_RETURN_, Table::ppFields, Table::ppLabels, and tableCreate().

Referenced by aidaRequestTable().

◆ uriLegacyName()

void uriLegacyName ( char  legacyName[MAX_URI_LEN],
const char *  uri 
)

Convert the given URI to the legacy AIDA name for low level functions that still require it that way.

Parameters
legacyNamepointer to space to store the legacy AIDA name
urithe new format AIDA PV name
Parameters
legacyNamepointer to space to store the legacy AIDA name
urithe new format AIDA PV name

Definition at line 599 of file aida_pva_server_helper.c.

600{
601 char* firstSeparator = strchr(uri, ':');
602 char* secondSeparator = strchr(firstSeparator + 1, ':');
603 char* lastSeparator = strrchr(uri, ':');
604 // See how many colons. If only three then this is a pseudo and we need to separate after first
605 if (lastSeparator == secondSeparator) {
606 // This has only three parts so separate at first colon
607 memcpy(legacyName, uri, firstSeparator - uri);
608 memcpy(legacyName + (firstSeparator - uri), "//", 2);
609 strcpy(legacyName + (firstSeparator - uri) + 2, firstSeparator + 1);
610 } else {
611 // Normal URI separate at last colon
612 memcpy(legacyName, uri, lastSeparator - uri);
613 memcpy(legacyName + (lastSeparator - uri), "//", 2);
614 strcpy(legacyName + (lastSeparator - uri) + 2, lastSeparator + 1);
615 }
616}

◆ uriToSlcName()

void uriToSlcName ( char  slcName[MAX_URI_LEN],
const char *  uri 
)

Convert all URIs to slac names before making queries.

Parameters
slcNamepointer to space to store the SLC name
urithe new format AIDA PV name
Parameters
slcNamepointer to space to store the SLC name
urithe new format AIDA PV name

Definition at line 583 of file aida_pva_server_helper.c.

584{
585 char* separator = strrchr(uri, ':');
586 if (separator) {
587 memcpy(slcName, uri, separator - uri);
588 memcpy(slcName + (separator - uri), ".", 1);
589 strcpy(slcName + (separator - uri) + 1, separator + 1);
590 }
591}