#ifndef _SYS_UTIL_H_
#define _SYS_UTIL_H_

/* 

   fortran interface stuff

     declare fortran character arguments as F_CHAR(arg)
     and at at the end for each character argument <arg> add
     int <arg>_len to the argument list

     Use macros STR_TO_C and STR_TO_F to convert from Fortran character strings
     to C character arrays and vice versa.

   sys_adr_len  (argument of accept and gethostbyadr, system dependent)
   
   sys_ctrl_init() (needed in VMS only)

*/


#if defined __VMS

typedef struct { short size, dummy; char *text; } SysVmsChar;

#define F_CHAR(VAR) SysVmsChar *VAR##_desc
#define STR_TO_C(DST,SRC) str_ntrim(DST, SRC##_desc->text, sizeof(DST), SRC##_desc->size)
#define STR_TO_F(DST,SRC) str_npad(DST##_desc->text, SRC, DST##_desc->size)
#define F_FUN(A) A

typedef size_t sys_adr_len; /* argument of accept and gethostbyadr */

void sys_ctrl_init(void);


#elif defined __alpha || defined __unix

#define F_CHAR(VAR) char *VAR
#define STR_TO_C(DST,SRC) str_ntrim(DST, SRC, sizeof(DST), SRC##_len)
#define STR_TO_F(DST,SRC) str_npad(DST, SRC, DST##_len)

#ifdef __alpha
#define F_FUN(A) A##_
#else
#define F_FUN(A) A##__
#endif

typedef int sys_adr_len; /* argument of accept and gethostbyadr */

#define sys_ctrl_init() 0


#else

/* other machines are not supported */

#endif

#endif /* _SYS_UTIL_H_ */
