- Adapted indenation to new agreed upon system
This commit is contained in:
@@ -69,28 +69,31 @@
|
||||
/*--------------------------------------------------------------------------
|
||||
** Global Variables
|
||||
*/
|
||||
extern int C_gbl_status = 0;
|
||||
extern struct dsc$descriptor_s C_name_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
extern int C_gbl_status = 0;
|
||||
extern struct dsc$descriptor_s C_name_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
** Old-style prototypes of routines which we are
|
||||
** bridging to.
|
||||
*/
|
||||
int log_arr_get ();
|
||||
int log_int_get ();
|
||||
int log_flt_get ();
|
||||
int log_str_get ();
|
||||
int log_arr_get();
|
||||
int log_int_get();
|
||||
int log_flt_get();
|
||||
int log_str_get();
|
||||
|
||||
int str_edit ();
|
||||
int str_edit();
|
||||
|
||||
int tt_port_connect ();
|
||||
int tt_port_disconnect ();
|
||||
int tt_port_io ();
|
||||
int tt_port_config ();
|
||||
int tt_port_connect();
|
||||
int tt_port_disconnect();
|
||||
int tt_port_io();
|
||||
int tt_port_config();
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_log_arr_get (char *name, int arr_size, int *value, int indx) {
|
||||
int C_log_arr_get(char *name, int arr_size, int *value, int indx)
|
||||
{
|
||||
/* =============
|
||||
**
|
||||
** This routine is useful for calling LOG_ARR_GET from a C program.
|
||||
@@ -110,15 +113,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** be used to generate an error message if return status == 0.
|
||||
*/
|
||||
C_name_desc.dsc$w_length = strlen (name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
C_name_desc.dsc$w_length = strlen(name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
|
||||
C_gbl_status = log_arr_get (&C_name_desc, &arr_size, value, &indx);
|
||||
C_gbl_status = log_arr_get(&C_name_desc, &arr_size, value, &indx);
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_log_int_get (char *name, long int *value, int indx) {
|
||||
int C_log_int_get(char *name, long int *value, int indx)
|
||||
{
|
||||
/* =============
|
||||
**
|
||||
** This routine is useful for calling LOG_INT_GET from a C program.
|
||||
@@ -136,15 +141,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** be used to generate an error message if return status == 0.
|
||||
*/
|
||||
C_name_desc.dsc$w_length = strlen (name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
C_name_desc.dsc$w_length = strlen(name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
|
||||
C_gbl_status = log_int_get (&C_name_desc, value, &indx);
|
||||
C_gbl_status = log_int_get(&C_name_desc, value, &indx);
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_log_flt_get (char *name, float *value, int indx) {
|
||||
int C_log_flt_get(char *name, float *value, int indx)
|
||||
{
|
||||
/* =============
|
||||
**
|
||||
** This routine is useful for calling LOG_FLT_GET from a C program.
|
||||
@@ -162,15 +169,17 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** be used to generate an error message if return status == 0.
|
||||
*/
|
||||
C_name_desc.dsc$w_length = strlen (name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
C_name_desc.dsc$w_length = strlen(name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
|
||||
C_gbl_status = log_flt_get (&C_name_desc, value, &indx);
|
||||
C_gbl_status = log_flt_get(&C_name_desc, value, &indx);
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_log_str_get (char *name, char *value, int val_size, int indx) {
|
||||
int C_log_str_get(char *name, char *value, int val_size, int indx)
|
||||
{
|
||||
/* =============
|
||||
**
|
||||
** This routine is useful for calling LOG_STR_GET from a C program.
|
||||
@@ -190,29 +199,32 @@
|
||||
** C_name_desc - set up as a string descriptor for name. It can
|
||||
** be used to generate an error message if return status == 0.
|
||||
*/
|
||||
struct dsc$descriptor_s my_val_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s my_val_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
|
||||
C_name_desc.dsc$w_length = strlen (name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
C_name_desc.dsc$w_length = strlen(name);
|
||||
C_name_desc.dsc$a_pointer = name;
|
||||
|
||||
my_val_desc.dsc$w_length = val_size - 1;
|
||||
my_val_desc.dsc$a_pointer = value;
|
||||
my_val_desc.dsc$w_length = val_size - 1;
|
||||
my_val_desc.dsc$a_pointer = value;
|
||||
|
||||
C_gbl_status = log_str_get (&C_name_desc, &my_val_desc, &indx);
|
||||
value[val_size - 1] = 0; /* Zero-terminate the string */
|
||||
C_gbl_status = log_str_get(&C_name_desc, &my_val_desc, &indx);
|
||||
value[val_size - 1] = 0; /* Zero-terminate the string */
|
||||
|
||||
if (C_gbl_status & 1) { /* If success, strip trailing spaces */
|
||||
while ((strlen (value) > 0) && (value[strlen (value) - 1] == ' ')) {
|
||||
value[strlen (value) - 1] = 0;
|
||||
}
|
||||
if (C_gbl_status & 1) { /* If success, strip trailing spaces */
|
||||
while ((strlen(value) > 0) && (value[strlen(value) - 1] == ' ')) {
|
||||
value[strlen(value) - 1] = 0;
|
||||
}
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_str_edit (char *out, char *in, char *ctrl, int *length) {
|
||||
int C_str_edit(char *out, char *in, char *ctrl, int *length)
|
||||
{
|
||||
/* ==========
|
||||
**
|
||||
** This routine is useful for calling STR_EDIT from a C program.
|
||||
@@ -235,39 +247,44 @@
|
||||
** Global variables:
|
||||
** C_gbl_status - set to the VAX/VMS return status of STR_EDIT.
|
||||
*/
|
||||
struct dsc$descriptor_s out_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s in_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s ctrl_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s out_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s in_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s ctrl_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
|
||||
out_desc.dsc$w_length = *length - 1;
|
||||
out_desc.dsc$a_pointer = out;
|
||||
out_desc.dsc$w_length = *length - 1;
|
||||
out_desc.dsc$a_pointer = out;
|
||||
|
||||
in_desc.dsc$w_length = strlen (in);
|
||||
in_desc.dsc$a_pointer = in;
|
||||
in_desc.dsc$w_length = strlen(in);
|
||||
in_desc.dsc$a_pointer = in;
|
||||
|
||||
ctrl_desc.dsc$w_length = strlen (ctrl);
|
||||
ctrl_desc.dsc$a_pointer = ctrl;
|
||||
ctrl_desc.dsc$w_length = strlen(ctrl);
|
||||
ctrl_desc.dsc$a_pointer = ctrl;
|
||||
|
||||
C_gbl_status = str_edit (&out_desc, &in_desc, &ctrl_desc, length);
|
||||
if (*length >= 0) { /* zero-terminate the output string */
|
||||
out[*length] = '\0';
|
||||
}else {
|
||||
out[0] = '\0';
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
C_gbl_status = str_edit(&out_desc, &in_desc, &ctrl_desc, length);
|
||||
if (*length >= 0) { /* zero-terminate the output string */
|
||||
out[*length] = '\0';
|
||||
} else {
|
||||
out[0] = '\0';
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_tt_port_connect (int *hndl, int *chan, char *lognam, char *pwd) {
|
||||
int C_tt_port_connect(int *hndl, int *chan, char *lognam, char *pwd)
|
||||
{
|
||||
/* =================
|
||||
**
|
||||
** This routine is useful for calling TT_PORT_CONNECT from a C program.
|
||||
@@ -292,30 +309,33 @@
|
||||
** Global variables:
|
||||
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONNECT.
|
||||
*/
|
||||
struct dsc$descriptor_s lognam_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s pwd_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
lognam_desc.dsc$w_length = strlen (lognam);
|
||||
lognam_desc.dsc$a_pointer = lognam;
|
||||
struct dsc$descriptor_s lognam_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s pwd_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
lognam_desc.dsc$w_length = strlen(lognam);
|
||||
lognam_desc.dsc$a_pointer = lognam;
|
||||
|
||||
if (pwd != NULL) {
|
||||
pwd_desc.dsc$w_length = strlen (pwd);
|
||||
pwd_desc.dsc$a_pointer = pwd;
|
||||
C_gbl_status = tt_port_connect (
|
||||
hndl, chan, &lognam_desc, &pwd_desc);
|
||||
}else {
|
||||
C_gbl_status = tt_port_connect (hndl, chan, &lognam_desc, NULL);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
if (pwd != NULL) {
|
||||
pwd_desc.dsc$w_length = strlen(pwd);
|
||||
pwd_desc.dsc$a_pointer = pwd;
|
||||
C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, &pwd_desc);
|
||||
} else {
|
||||
C_gbl_status = tt_port_connect(hndl, chan, &lognam_desc, NULL);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_tt_port_disconnect (int *hndl) {
|
||||
int C_tt_port_disconnect(int *hndl)
|
||||
{
|
||||
/* ====================
|
||||
**
|
||||
** This routine is useful for calling TT_PORT_DISCONNECT from a C program.
|
||||
@@ -331,20 +351,18 @@
|
||||
** Global variables:
|
||||
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_DISCONNECT.
|
||||
*/
|
||||
C_gbl_status = tt_port_disconnect (hndl);
|
||||
C_gbl_status = tt_port_disconnect(hndl);
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_tt_port_io (
|
||||
int C_tt_port_io(
|
||||
/* ============
|
||||
*/ int *hndl,
|
||||
char *rqst,
|
||||
char *term,
|
||||
char *answ,
|
||||
int *answ_len, /* Attention -- Read/Write argument!! */
|
||||
int flush,
|
||||
int tmo) {
|
||||
*/ int *hndl,
|
||||
char *rqst, char *term, char *answ, int *answ_len, /* Attention -- Read/Write argument!! */
|
||||
int flush, int tmo)
|
||||
{
|
||||
/*
|
||||
** This routine is useful for calling TT_PORT_IO from a C program.
|
||||
** Refer to the DELTAT.OLB description of TT_PORT_IO to clarify any
|
||||
@@ -386,66 +404,73 @@
|
||||
** Global variables:
|
||||
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_IO.
|
||||
*/
|
||||
struct dsc$descriptor_s rqst_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s term_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
struct dsc$descriptor_s answ_desc = {0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0};
|
||||
char *my_rqst = NULL;
|
||||
char *my_term = NULL;
|
||||
char *my_answ = NULL;
|
||||
struct dsc$descriptor_s rqst_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s term_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
struct dsc$descriptor_s answ_desc = { 0,
|
||||
DSC$K_DTYPE_T,
|
||||
DSC$K_CLASS_S,
|
||||
0
|
||||
};
|
||||
char *my_rqst = NULL;
|
||||
char *my_term = NULL;
|
||||
char *my_answ = NULL;
|
||||
|
||||
int my_answ_len = 0;
|
||||
int my_flush = 1;
|
||||
int my_tmo = 2;
|
||||
int my_answ_len = 0;
|
||||
int my_flush = 1;
|
||||
int my_tmo = 2;
|
||||
|
||||
my_tmo = tmo;
|
||||
if (my_tmo < 0) my_tmo = 0;
|
||||
my_flush = flush;
|
||||
if (my_flush != 0) my_flush = 1;
|
||||
if (answ != NULL) {
|
||||
if (answ_len == 0) {
|
||||
printf ("C_tt_port_io -- argument error.\n");
|
||||
printf (" %s\n",
|
||||
"answ_len must be present if answ is present.");
|
||||
C_gbl_status = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
answ_desc.dsc$w_length = *answ_len - 1;
|
||||
answ_desc.dsc$a_pointer = answ;
|
||||
my_tmo = tmo;
|
||||
if (my_tmo < 0)
|
||||
my_tmo = 0;
|
||||
my_flush = flush;
|
||||
if (my_flush != 0)
|
||||
my_flush = 1;
|
||||
if (answ != NULL) {
|
||||
if (answ_len == 0) {
|
||||
printf("C_tt_port_io -- argument error.\n");
|
||||
printf(" %s\n",
|
||||
"answ_len must be present if answ is present.");
|
||||
C_gbl_status = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
if (term != NULL) {
|
||||
term_desc.dsc$w_length = strlen (term);
|
||||
term_desc.dsc$a_pointer = term;
|
||||
}
|
||||
if (rqst != NULL) {
|
||||
rqst_desc.dsc$w_length = strlen (rqst);
|
||||
rqst_desc.dsc$a_pointer = rqst;
|
||||
}
|
||||
C_gbl_status = tt_port_io (hndl, &rqst_desc, &term_desc,
|
||||
&answ_desc, &my_answ_len, &my_flush, &my_tmo);
|
||||
if (answ_desc.dsc$w_length > 0) { /* Process any input string */
|
||||
if (answ_desc.dsc$w_length > my_answ_len) { /* Room for terminator? */
|
||||
answ[my_answ_len+1] = answ[my_answ_len]; /* Yes, so move it. */
|
||||
}
|
||||
answ[my_answ_len] = '\0'; /* Put in null terminator */
|
||||
*answ_len = my_answ_len; /* Return value to caller */
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
answ_desc.dsc$w_length = *answ_len - 1;
|
||||
answ_desc.dsc$a_pointer = answ;
|
||||
}
|
||||
if (term != NULL) {
|
||||
term_desc.dsc$w_length = strlen(term);
|
||||
term_desc.dsc$a_pointer = term;
|
||||
}
|
||||
if (rqst != NULL) {
|
||||
rqst_desc.dsc$w_length = strlen(rqst);
|
||||
rqst_desc.dsc$a_pointer = rqst;
|
||||
}
|
||||
C_gbl_status = tt_port_io(hndl, &rqst_desc, &term_desc,
|
||||
&answ_desc, &my_answ_len, &my_flush, &my_tmo);
|
||||
if (answ_desc.dsc$w_length > 0) { /* Process any input string */
|
||||
if (answ_desc.dsc$w_length > my_answ_len) { /* Room for terminator? */
|
||||
answ[my_answ_len + 1] = answ[my_answ_len]; /* Yes, so move it. */
|
||||
}
|
||||
answ[my_answ_len] = '\0'; /* Put in null terminator */
|
||||
*answ_len = my_answ_len; /* Return value to caller */
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
int C_tt_port_config (
|
||||
int C_tt_port_config(
|
||||
/* ================
|
||||
*/ int *hndl,
|
||||
int mask) {
|
||||
*/ int *hndl,
|
||||
int mask)
|
||||
{
|
||||
/*
|
||||
** This routine is useful for calling TT_PORT_CONFIG from a C program.
|
||||
** Refer to the DELTAT.OLB description of TT_PORT_CONFIG to clarify any
|
||||
@@ -465,8 +490,9 @@
|
||||
** Global variables:
|
||||
** C_gbl_status - set to the VAX/VMS return status of TT_PORT_CONFIG.
|
||||
*/
|
||||
C_gbl_status = tt_port_config (hndl, &mask);
|
||||
C_gbl_status = tt_port_config(hndl, &mask);
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
|
||||
return (C_gbl_status & 1);
|
||||
}
|
||||
/*=========================================== End of C_INTERFACES.C ========*/
|
||||
|
||||
Reference in New Issue
Block a user