/*************************************************************************** rlcutil.cpp - description ------------------- begin : Wed Dec 11 2002 copyright : (C) 2002 by R. Lehrig email : lehrig@t-online.de ***************************************************************************/ /*************************************************************************** * * * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as * * published by the Free Software Foundation * * * ***************************************************************************/ /*!
Some C functions.
*/ #ifndef _RL_CUTIL_H_ #define _RL_CUTIL_H_ #include #include #include #include #include "rldefine.h" /*!
  like printf for debugging 
*/ int rlSetDebugPrintf(int state); int rlDebugPrintf(const char *format, ...); /*!
  test if input line is available
  #include 
*/ int rlInputAvailable(); /*!
  like printf in the last line of a terminal
*/ int rlLastLinePrintf(const char *format, ...); #ifdef RLUNIX /*!
  call execvp(arg[0],arg) on unix
*/ #ifndef SWIG int rlexec(const char *command); #endif #endif /*!
  encode plain text password p
*/ const char *rlpass(const char *p); /*!
  strncpy + terminate with '\\0'
*/ char *rlstrncpy(char *dest, const char *source, int n); /*!
  strncpy + terminate with '\\0'
  terminates on '\\n' or '\\0'
  '\\n' is not copied
*/ char *rlstrlinecpy(char *dest, const char *source, int n); /*!
  like vsnprintf but portable
*/ #ifndef SWIG int rlvsnprintf(char *text, int len, const char *format, va_list ap); #endif /*!
  like snprintf but portable
*/ int rlsnprintf(char *text, int len, const char *format, ...); /*!
  set signal handler for signal SIGTERM
*/ void rlSetSigtermHandler(void (*handler)(void *arg), void *arg); /*!
  context = 0 must be 0 on first call
*/ const char *rlFindFile(const char *pattern, int *context); /**
returns:
~/.name               on Linux/Unix
sys$login:name        on OpenVMS
%USERPROFILE%\\name    on Windows
*/ const char *rlGetInifile(const char *name); /**
swaps bytes
*/ int rlSwapShort(int val); /**
Send command to a bus system
*/ int rlEib1 (int command); int rlEib2 (int command); int rlLon1 (int command); int rlLon2 (int command); int rlProfibus1(int command); int rlProfibus2(int command); int rlCan1 (int command); int rlCan2 (int command); /**
Call internet browser
*/ int rlBrowser(const char *htmlfile); /**
Call system(command)
*/ int rlsystem(const char *command); /**
Submit a pvserver
Example:
rlSubmitPvserver("HOME","/temp/murx","pvs","-exit_on_bind_error -exit_after_last_client_terminates");
*/ int rlSubmitPvserver(const char *env, const char *path, const char *pvs, const char *options=NULL); /**
Get option from string
return = 0 # not found
return = 1 # found
*/ int rlOption(const char *string, const char *option); /**
Get option from string
*/ int rlIntOption(const char *string, const char *option, int _default); /**
Get option from string
*/ float rlFloatOption(const char *string, const char *option, float _default); /**
Get option from string
*/ const char *rlTextOption(const char *string, const char *option, const char *_default); /**
Copy a Textfile (no binary file)
*/ int rlCopyTextfile(const char *source, const char *destination); /**
convert str to upper case
*/ int rlupper(char *str); /**
convert str to lower case
*/ int rllower(char *str); /**
test if str starts with startstr
*/ int rlStartsWith(const char *str, const char *startstr); /**
test if str ends with endstr
*/ int rlEndsWith(const char *str, const char *endstr); /**
test if str matches with wild
*/ int rlStrMatch(const char *str, const char *wild); /**
same as stat
*/ #ifndef SWIG int rlStat(const char *filepath, struct stat *buf); #endif /**
read data from file
return := number of bytes read | -1
*/ int rlFRead(FILE *fin, void *data, int len); /**
write data to file
return := number of bytes written | -1
*/ int rlFWrite(FILE *fout, void *data, int len); /**
write data to file
return := number of bytes written | -1
*/ int rlWriteFile(const char *filename, void *data, int len); /**
same as mkdir
*/ int rlMkdir(const char *dir, int mode=0744); /**
Set bit bitnumber in value
Return value
*/ int rlBitSet(int bitnumber, int *value); /**
Clear bit bitnumber in value
Return value
*/ int rlBitClear(int bitnumber, int *value); /**
XOR bit bitnumber in value
Return value
*/ int rlBitChange(int bitnumber, int *value); /**
Test bit bitnumber in value
Return 0 | 1
*/ int rlBitTest(int bitnumber, int *value); /**
Push value to front of buffer.
Shift all other values.
*/ void rlPushToDoubleBuffer(double val, double *buffer, int size); /**
Push value to front of buffer.
Shift all other values.
*/ void rlPushToFloatBuffer(float val, float *buffer, int size); #endif