rllib  1
Functions
rlcutil.h File Reference
#include <stdarg.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "rldefine.h"
Include dependency graph for rlcutil.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int rlSetDebugPrintf (int state)
 
int rlDebugPrintf (const char *format,...)
 
int rlInputAvailable ()
 
int rlLastLinePrintf (const char *format,...)
 
int rlexec (const char *command)
 
const char * rlpass (const char *p)
 
char * rlstrncpy (char *dest, const char *source, int n)
 
char * rlstrlinecpy (char *dest, const char *source, int n)
 
int rlvsnprintf (char *text, int len, const char *format, va_list ap)
 
int rlsnprintf (char *text, int len, const char *format,...)
 
void rlSetSigtermHandler (void(*handler)(void *arg), void *arg)
 
const char * rlFindFile (const char *pattern, int *context)
 
const char * rlGetInifile (const char *name)
 
int rlSwapShort (int val)
 
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)
 
int rlBrowser (const char *htmlfile)
 
int rlsystem (const char *command)
 
int rlSubmitPvserver (const char *env, const char *path, const char *pvs, const char *options=NULL)
 
int rlOption (const char *string, const char *option)
 
int rlIntOption (const char *string, const char *option, int _default)
 
float rlFloatOption (const char *string, const char *option, float _default)
 
const char * rlTextOption (const char *string, const char *option, const char *_default)
 
int rlCopyTextfile (const char *source, const char *destination)
 
int rlupper (char *str)
 
int rllower (char *str)
 
int rlStartsWith (const char *str, const char *startstr)
 
int rlEndsWith (const char *str, const char *endstr)
 
int rlStrMatch (const char *str, const char *wild)
 
int rlStat (const char *filepath, struct stat *buf)
 
int rlFRead (FILE *fin, void *data, int len)
 
int rlFWrite (FILE *fout, void *data, int len)
 
int rlWriteFile (const char *filename, void *data, int len)
 
int rlMkdir (const char *dir, int mode=0744)
 
int rlBitSet (int bitnumber, int *value)
 
int rlBitClear (int bitnumber, int *value)
 
int rlBitChange (int bitnumber, int *value)
 
int rlBitTest (int bitnumber, int *value)
 
void rlPushToDoubleBuffer (double val, double *buffer, int size)
 
void rlPushToFloatBuffer (float val, float *buffer, int size)
 

Function Documentation

◆ rlBitChange()

int rlBitChange ( int  bitnumber,
int *  value 
)
XOR bit bitnumber in value
Return value

Definition at line 861 of file rlcutil.cpp.

862 {
863  int bit = 1 << bitnumber;
864  *value = *value ^ bit;
865  return *value;
866 }

◆ rlBitClear()

int rlBitClear ( int  bitnumber,
int *  value 
)
Clear bit bitnumber in value
Return value

Definition at line 853 of file rlcutil.cpp.

854 {
855  int bit = 1 << bitnumber;
856  bit = ~bit;
857  *value = *value & bit;
858  return *value;
859 }

◆ rlBitSet()

int rlBitSet ( int  bitnumber,
int *  value 
)
Set bit bitnumber in value
Return value

Definition at line 846 of file rlcutil.cpp.

847 {
848  int bit = 1 << bitnumber;
849  *value = *value | bit;
850  return *value;
851 }

◆ rlBitTest()

int rlBitTest ( int  bitnumber,
int *  value 
)
Test bit bitnumber in value
Return 0 | 1

Definition at line 868 of file rlcutil.cpp.

869 {
870  int bit = 1 << bitnumber;
871  if(*value & bit) return 1;
872  return 0;
873 }

◆ rlBrowser()

int rlBrowser ( const char *  htmlfile)
Call internet browser

Definition at line 613 of file rlcutil.cpp.

614 {
615  char buf[4096];
616  int ret = 0;
617 
618 #ifdef RLUNIX
619  sprintf(buf,"konqueror %s &", htmlfile);
620  ret = system(buf);
621 #endif
622 #ifdef RLWIN32
623  if(get_iexplore(buf) < 0) return -1;
624  strcat(buf," ");
625  strcat(buf,htmlfile);
626  ret = mysystem(buf);
627 #endif
628  return ret;
629 }//------------------------------------------------------------------------
static int get_iexplore(char *buf)
Definition: rlcutil.cpp:446
static int mysystem(const char *command)
Definition: rlcutil.cpp:538

◆ rlCan1()

int rlCan1 ( int  command)

Definition at line 429 of file rlcutil.cpp.

430 {
431  char buf[80];
432 
433  sprintf(buf,"buscommand -can1 %d",command);
434  return system(buf);
435 }

◆ rlCan2()

int rlCan2 ( int  command)

Definition at line 437 of file rlcutil.cpp.

438 {
439  char buf[80];
440 
441  sprintf(buf,"buscommand -can2 %d",command);
442  return system(buf);
443 }

◆ rlCopyTextfile()

int rlCopyTextfile ( const char *  source,
const char *  destination 
)
Copy a Textfile (no binary file)

Definition at line 696 of file rlcutil.cpp.

697 {
698  FILE *fin, *fout;
699 
700  if(source == NULL || destination == NULL) return -1;
701  fin = fopen(source,"r");
702  if(fin == NULL)
703  {
704  printf("rlCopyTextfile: could not read %s\n",source);
705  return -1;
706  }
707  fout = fopen(destination,"w");
708  if(fout == NULL)
709  {
710  fclose(fin);
711  printf("rlCopyTextfile: could not write %s\n",destination);
712  return -1;
713  }
714 
715  char *line = new char[256*256];
716  while(fgets(line,sizeof(line)-1,fin) != NULL)
717  {
718  fprintf(fout,"%s",line);
719  }
720  delete [] line;
721 
722  fclose(fin);
723  fclose(fout);
724  return 0;
725 }

◆ rlDebugPrintf()

int rlDebugPrintf ( const char *  format,
  ... 
)

Definition at line 61 of file rlcutil.cpp.

62 {
63  int ret;
64  char message[rl_PRINTF_LENGTH]; // should be big enough
65 
66  if(rlDebugPrintfState == 0) return 0;
67  va_list ap;
68  va_start(ap,format);
69  ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap);
70  va_end(ap);
71  if(ret < 0) return ret;
72  return printf("%s",message);
73 }
#define rl_PRINTF_LENGTH
Definition: rldefine.h:71
int rlDebugPrintfState
Definition: rlcutil.cpp:52
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
Definition: rlcutil.cpp:197

◆ rlEib1()

int rlEib1 ( int  command)
Send command to a bus system

Definition at line 381 of file rlcutil.cpp.

382 {
383  char buf[80];
384 
385  sprintf(buf,"buscommand -eib1 %d",command);
386  return system(buf);
387 }

◆ rlEib2()

int rlEib2 ( int  command)

Definition at line 389 of file rlcutil.cpp.

390 {
391  char buf[80];
392 
393  sprintf(buf,"buscommand -eib2 %d",command);
394  return system(buf);
395 }

◆ rlEndsWith()

int rlEndsWith ( const char *  str,
const char *  endstr 
)
test if str ends with endstr

Definition at line 758 of file rlcutil.cpp.

759 {
760  int ret;
761  if(str == NULL || endstr == NULL) return 0;
762  int index = strlen(str) - strlen(endstr);
763  if(index < 0) return 0;
764  ret = strcmp(&str[index],endstr);
765  if(ret == 0) return 1;
766  return 0;
767 }

◆ rlexec()

int rlexec ( const char *  command)
  call execvp(arg[0],arg) on unix

Definition at line 113 of file rlcutil.cpp.

114 {
115  char *buf;
116  char *arg[512];
117  int i,iarg,ret;
118 
119  buf = new char [strlen(command)+1];
120  strcpy(buf,command);
121  iarg = 0;
122  i = 0;
123  while(buf[i] != '\0')
124  {
125  if(buf[i] == '\"')
126  {
127  i++;
128  arg[iarg++] = &buf[i];
129  while(buf[i] != '\"' && buf[i] != '\0') i++;
130  if(buf[i] == '\0') break;
131  buf[i] = '\0';
132  }
133  else if(buf[i] != ' ' || i == 0)
134  {
135  arg[iarg++] = &buf[i];
136  while(buf[i] != ' ' && buf[i] != '\0') i++;
137  if(buf[i] == '\0') break;
138  buf[i] = '\0';
139  }
140  i++;
141  }
142  arg[iarg] = NULL;
143 
144  ret = execvp(arg[0],arg);
145  delete [] buf;
146  return ret;
147 }

◆ rlFindFile()

const char* rlFindFile ( const char *  pattern,
int *  context 
)
  context = 0 must be 0 on first call

Definition at line 275 of file rlcutil.cpp.

276 {
277  static char freturn[512];
278 
279 #ifdef RLUNIX
280  static DIR *dirp;
281  static struct dirent *dp;
282 
283  if(*context == 0) dirp = opendir(".");
284  *context = 1;
285 
286  while((dp = readdir(dirp)) != NULL)
287  {
288  if(dp->d_name[0] == '.') ;
289  else if(strstr(dp->d_name,pattern) != NULL)
290  {
291  strcpy(freturn,dp->d_name);
292  return freturn;
293  }
294  else if(rlStrMatch(dp->d_name, pattern))
295  {
296  strcpy(freturn,dp->d_name);
297  return freturn;
298  }
299  }
300  closedir(dirp);
301  return NULL;
302 #endif
303 
304 #ifdef __VMS
305  int i,ret;
306  static char file[512] = "";
307  static char wildcard[80];
308  struct dsc$descriptor_s dwildcard;
309  struct dsc$descriptor_s dfreturn;
310 
311  strcpy(wildcard,pattern);
312 
313  dwildcard.dsc$w_length = strlen(wildcard);
314  dwildcard.dsc$a_pointer = wildcard;
315  dwildcard.dsc$b_dtype = DSC$K_DTYPE_T;
316  dwildcard.dsc$b_class = DSC$K_CLASS_S;
317 
318  dfreturn.dsc$w_length = sizeof(freturn);
319  dfreturn.dsc$a_pointer = &freturn[0];
320  dfreturn.dsc$b_dtype = DSC$K_DTYPE_T;
321  dfreturn.dsc$b_class = DSC$K_CLASS_S;
322 
323  ret = LIB$FIND_FILE(&dwildcard,&dfreturn,context,0,0,0,0);
324  if (ret == RMS$_NMF) return NULL; // no more files found
325  else if(ret != RMS$_NORMAL) return NULL;
326  else if(strcmp(freturn,file) == 0) { file[0] = '\0'; return NULL; }
327  i=0;
328  while(freturn[i] > ' ')i++;
329  freturn[i] = '\0';
330  return freturn;
331 #endif
332 
333 #ifdef RLWIN32
334  static WIN32_FIND_DATAA wfd;
335  static HANDLE hFindFile;
336 
337  if(*context == 0) // find first
338  {
339  *context = 1;
340  hFindFile = FindFirstFileA(pattern,&wfd);
341  if(hFindFile == INVALID_HANDLE_VALUE) return NULL;
342  else strcpy(freturn,(const char *) &wfd.cFileName);
343  }
344  else // subsequent find
345  {
346  if(FindNextFileA(hFindFile,&wfd) == TRUE) strcpy(freturn,(const char *) &wfd.cFileName);
347  else { FindClose(hFindFile); return NULL; }
348  }
349  return freturn;
350 #endif
351 }
int rlStrMatch(const char *str, const char *wild)
Definition: rlcutil.cpp:769

◆ rlFloatOption()

float rlFloatOption ( const char *  string,
const char *  option,
float  _default 
)
Get option from string

Definition at line 655 of file rlcutil.cpp.

656 {
657  const char *cptr;
658  float ret;
659 
660  cptr = strstr(string,option);
661  if(cptr == NULL) return def;
662 
663  cptr = strstr(cptr,"=");
664  if(cptr == NULL) return def;
665 
666  sscanf(cptr,"=%f",&ret);
667  return ret;
668 }

◆ rlFRead()

int rlFRead ( FILE *  fin,
void *  data,
int  len 
)
read data from file
return := number of bytes read | -1

Definition at line 809 of file rlcutil.cpp.

810 {
811  if(fin == NULL) return -1;
812  return fread(data,1,len,fin);
813 }

◆ rlFWrite()

int rlFWrite ( FILE *  fout,
void *  data,
int  len 
)
write data to file
return := number of bytes written | -1

Definition at line 815 of file rlcutil.cpp.

816 {
817  if(fout == NULL) return -1;
818  return fwrite(data,1,len,fout);
819 }

◆ rlGetInifile()

const char* rlGetInifile ( const char *  name)
returns:
~/.name               on Linux/Unix
sys$login:name        on OpenVMS
USERPROFILE%\name    on Windows

Definition at line 354 of file rlcutil.cpp.

355 {
356  static char buf[1024];
357 
358 #ifdef RLUNIX
359  strcpy(buf,getenv("HOME"));
360  strcat(buf,"/.");
361 #endif
362 #ifdef __VMS
363  strcpy(buf,"sys$login:");
364 #endif
365 #ifdef RLWIN32
366  ExpandEnvironmentStringsA("%USERPROFILE%",buf,sizeof(buf)-1);
367  if(strcmp(buf,"%USERPROFILE%") == 0) strcpy(buf,"C:");
368  strcat(buf,"\\");;
369 #endif
370 
371  strcat(buf,name);
372  return buf;
373 }

◆ rlInputAvailable()

int rlInputAvailable ( )
  test if input line is available
  #include <sys/select.h>

Definition at line 75 of file rlcutil.cpp.

76 {
77  struct timeval timout;
78  fd_set wset,rset,eset;
79  int ret,maxfdp1;
80  int s = 0;
81  /* setup sockets to read */
82  maxfdp1 = s+1;
83  FD_ZERO(&rset);
84  FD_SET (s,&rset);
85  FD_ZERO(&wset);
86  FD_ZERO(&eset);
87  timout.tv_sec = 0;
88  timout.tv_usec = 0;
89  ret = ::select(maxfdp1,&rset,&wset,&eset,&timout);
90  if(ret == 0) return 0; /* timeout */
91  return 1;
92 }

◆ rlIntOption()

int rlIntOption ( const char *  string,
const char *  option,
int  _default 
)
Get option from string

Definition at line 640 of file rlcutil.cpp.

641 {
642  const char *cptr;
643  int ret;
644 
645  cptr = strstr(string,option);
646  if(cptr == NULL) return def;
647 
648  cptr = strstr(cptr,"=");
649  if(cptr == NULL) return def;
650 
651  sscanf(cptr,"=%d",&ret);
652  return ret;
653 }

◆ rlLastLinePrintf()

int rlLastLinePrintf ( const char *  format,
  ... 
)
  like printf in the last line of a terminal

Definition at line 94 of file rlcutil.cpp.

95 {
96  int ret,i;
97  char message[rl_PRINTF_LENGTH]; // should be big enough
98 
99  va_list ap;
100  va_start(ap,format);
101  ret = rlvsnprintf(message, rl_PRINTF_LENGTH - 1, format, ap);
102  va_end(ap);
103  if(ret < 0) return ret;
104  message[79] = '\0';
105  printf("%c[80D",27); // move 80 columns left
106  printf("%s",message);
107  for(i=strlen(message); i<80; i++) printf(" ");
108  return 80;
109 }
#define rl_PRINTF_LENGTH
Definition: rldefine.h:71
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
Definition: rlcutil.cpp:197

◆ rlLon1()

int rlLon1 ( int  command)

Definition at line 397 of file rlcutil.cpp.

398 {
399  char buf[80];
400 
401  sprintf(buf,"buscommand -lon1 %d",command);
402  return system(buf);
403 }

◆ rlLon2()

int rlLon2 ( int  command)

Definition at line 405 of file rlcutil.cpp.

406 {
407  char buf[80];
408 
409  sprintf(buf,"buscommand -lon2 %d",command);
410  return system(buf);
411 }

◆ rllower()

int rllower ( char *  str)
convert str to lower case

Definition at line 738 of file rlcutil.cpp.

739 {
740  if(str == NULL) return -1;
741  while(*str != '\0')
742  {
743  *str = tolower(*str);
744  str++;
745  }
746  return 0;
747 }

◆ rlMkdir()

int rlMkdir ( const char *  dir,
int  mode = 0744 
)
same as mkdir

Definition at line 834 of file rlcutil.cpp.

835 {
836 #ifdef RLWIN32
837  int ret = CreateDirectoryA(dir,NULL);
838  if(ret) return 0;
839  if(mode) return -1;
840  return -1;
841 #else
842  return mkdir(dir, mode);
843 #endif
844 }

◆ rlOption()

int rlOption ( const char *  string,
const char *  option 
)
Get option from string
return = 0 # not found
return = 1 # found

Definition at line 631 of file rlcutil.cpp.

632 {
633  const char *cptr;
634 
635  cptr = strstr(string,option);
636  if(cptr == NULL) return 0;
637  return 1;
638 }

◆ rlpass()

const char* rlpass ( const char *  p)
  encode plain text password p

Definition at line 151 of file rlcutil.cpp.

152 {
153  static char ret[4*16+8];
154  char buf[80];
155  int i,val;
156 
157  ret[0] = '\0';
158  for(i=0; p[i] != '\0' && i<=16; i++)
159  {
160  val = p[i] * 16;
161  sprintf(buf,"%04X",val);
162  strcat(ret,buf);
163  }
164 
165  return ret;
166 }

◆ rlProfibus1()

int rlProfibus1 ( int  command)

Definition at line 413 of file rlcutil.cpp.

414 {
415  char buf[80];
416 
417  sprintf(buf,"buscommand -profibus1 %d",command);
418  return system(buf);
419 }

◆ rlProfibus2()

int rlProfibus2 ( int  command)

Definition at line 421 of file rlcutil.cpp.

422 {
423  char buf[80];
424 
425  sprintf(buf,"buscommand -profibus2 %d",command);
426  return system(buf);
427 }

◆ rlPushToDoubleBuffer()

void rlPushToDoubleBuffer ( double  val,
double *  buffer,
int  size 
)
Push value to front of buffer.
Shift all other values.

Definition at line 875 of file rlcutil.cpp.

876 {
877  if(size <= 0) return;
878  for(int i=size; i>=2; i--) buffer[i-1] = buffer[i-2];
879  buffer[0] = val;
880 }

◆ rlPushToFloatBuffer()

void rlPushToFloatBuffer ( float  val,
float *  buffer,
int  size 
)
Push value to front of buffer.
Shift all other values.

Definition at line 882 of file rlcutil.cpp.

883 {
884  if(size <= 0) return;
885  for(int i=size; i>=2; i--) buffer[i-1] = buffer[i-2];
886  buffer[0] = val;
887 }

◆ rlSetDebugPrintf()

int rlSetDebugPrintf ( int  state)
Some C functions.
  like printf for debugging 

Definition at line 54 of file rlcutil.cpp.

55 {
56  if(state == 0) rlDebugPrintfState = 0;
57  else rlDebugPrintfState = 1;
58  return 0;
59 }
int rlDebugPrintfState
Definition: rlcutil.cpp:52

◆ rlSetSigtermHandler()

void rlSetSigtermHandler ( void(*)(void *arg)  handler,
void *  arg 
)
  set signal handler for signal SIGTERM

Definition at line 267 of file rlcutil.cpp.

268 {
269  rlsigtermarg = arg;
270  rlUserSigtermHandler = handler;
271  signal(SIGTERM,rlSigtermHandler);
272 }
static void(* rlUserSigtermHandler)(void *arg)
Definition: rlcutil.cpp:254
static void * rlsigtermarg
Definition: rlcutil.cpp:253
static void rlSigtermHandler(int sig)
Definition: rlcutil.cpp:256

◆ rlsnprintf()

int rlsnprintf ( char *  text,
int  len,
const char *  format,
  ... 
)
  like snprintf but portable

Definition at line 231 of file rlcutil.cpp.

232 {
233  int ret;
234 
235  va_list ap;
236  va_start(ap,format);
237 #ifdef RLWIN32
238  ret = _vsnprintf(text, len, format, ap);
239 #endif
240 #ifdef __VMS
241  static char vms_is_deprecated[rl_PRINTF_LENGTH];
242  ret = vsprintf(vms_is_deprecated, format, ap);
243  rlstrncpy(text,vms_is_deprecated,len);
244 #endif
245 #ifdef RLUNIX
246  ret = vsnprintf(text, len, format, ap);
247 #endif
248  va_end(ap);
249  return ret;
250 }
#define rl_PRINTF_LENGTH
Definition: rldefine.h:71
char * rlstrncpy(char *dest, const char *source, int n)
Definition: rlcutil.cpp:169

◆ rlStartsWith()

int rlStartsWith ( const char *  str,
const char *  startstr 
)
test if str starts with startstr

Definition at line 749 of file rlcutil.cpp.

750 {
751  int ret;
752  if(str == NULL || startstr == NULL) return 0;
753  ret = strncmp(str,startstr,strlen(startstr));
754  if(ret == 0) return 1;
755  return 0;
756 }

◆ rlStat()

int rlStat ( const char *  filepath,
struct stat *  buf 
)
same as stat

Definition at line 804 of file rlcutil.cpp.

805 {
806  return stat(filepath, buf);
807 }

◆ rlstrlinecpy()

char* rlstrlinecpy ( char *  dest,
const char *  source,
int  n 
)
  strncpy + terminate with '\0'
  terminates on '\n' or '\0'
  '\n' is not copied

Definition at line 182 of file rlcutil.cpp.

183 {
184  int i;
185 
186  for(i=0; i<n; i++)
187  {
188  if(source[i] == '\0') break;
189  if(source[i] == '\n') break;
190  dest[i] = source[i];
191  }
192  dest[i] = '\0';
193  return dest;
194 }

◆ rlStrMatch()

int rlStrMatch ( const char *  str,
const char *  wild 
)
test if str matches with wild

Definition at line 769 of file rlcutil.cpp.

770 {
771  if(strstr(str,wild) != NULL) return 1;
772  int i,w;
773 
774  w = 0;
775  for(i=0; str[i] != '\0'; i++)
776  {
777  if(wild[w] == '*')
778  {
779  while(wild[w] == '*') w++;
780  if(wild[w] == '\0') return 1;
781 try_next:
782  if(wild[w] == '\0') return 0;
783  while(str[i] != wild[w] && str[i] != '\0') i++;
784  if(str[i] == '\0') return 0;
785  while(str[i] != '\0')
786  {
787  if(str[i] != wild[w]) goto try_next;
788  i++;
789  w++;
790  if(str[i] == '\0' && wild[w] == '\0') return 1;
791  }
792  if(wild[w] != '\0') return 0;
793  return 1;
794  }
795  else
796  {
797  if(str[i] != wild[w]) return 0;
798  }
799  w++;
800  }
801  return 1;
802 }

◆ rlstrncpy()

char* rlstrncpy ( char *  dest,
const char *  source,
int  n 
)
  strncpy + terminate with '\0'

Definition at line 169 of file rlcutil.cpp.

170 {
171  int i;
172 
173  for(i=0; i<n; i++)
174  {
175  if(source[i] == '\0') break;
176  dest[i] = source[i];
177  }
178  dest[i] = '\0';
179  return dest;
180 }

◆ rlSubmitPvserver()

int rlSubmitPvserver ( const char *  env,
const char *  path,
const char *  pvs,
const char *  options = NULL 
)
Submit a pvserver
Example:
rlSubmitPvserver("HOME","/temp/murx","pvs","-exit_on_bind_error -exit_after_last_client_terminates");

Definition at line 567 of file rlcutil.cpp.

568 {
569  if(env == NULL || path == NULL || pvs == NULL) return -1;
570  rlString command,cd;
571  const char *cptr;
572 
573 #ifdef __VMS
574  cptr = env;
575  cd = cptr;
576  cd += path;
577  command = "spawn/nowait ";
578  command += cd;
579  command += pvs;
580  command += " ";
581  if(options != NULL) command += options;
582  command += " -cd=";
583  command += cd;
584 #else
585  cptr = getenv(env);
586  if(cptr == NULL) { printf("rlSubmitPvserver:ERROR env=%s is not set\n", env); return -2; }
587  cd += cptr;
588  cd += path;
589  command = "\"";
590  command += cd;
591 #ifdef RLWIN32
592  command += "\\";
593 #else
594  command += "/";
595 #endif
596  command += pvs;
597  command += "\" ";
598  if(options != NULL) command += options;
599  command += " \"-cd=";
600  command += cd;
601  command += "\"";
602 #endif
603 
604 #ifdef RLUNIX
605  command += " &";
606 #endif
607 
608  //printf("command=%s\n", command.text());
609  return rlsystem(command.text());
610  //example: rlSubmitPvserver("HOME","/temp/murx","pvs","-exit_on_bind_error -exit_after_last_client_terminates");
611 }
char * text()
Definition: rlstring.cpp:126
int rlsystem(const char *command)
Definition: rlcutil.cpp:558

◆ rlSwapShort()

int rlSwapShort ( int  val)
swaps bytes

Definition at line 375 of file rlcutil.cpp.

376 {
377  return (val & 0x0ff)*256 + val/256;
378 }

◆ rlsystem()

int rlsystem ( const char *  command)
Call system(command)

Definition at line 558 of file rlcutil.cpp.

559 {
560 #ifdef RLWIN32
561  return mysystem(command);
562 #else
563  return system(command);
564 #endif
565 }
static int mysystem(const char *command)
Definition: rlcutil.cpp:538

◆ rlTextOption()

const char* rlTextOption ( const char *  string,
const char *  option,
const char *  _default 
)
Get option from string

Definition at line 670 of file rlcutil.cpp.

671 {
672  int i = 0;
673  const char *cptr;
674  char quote;
675  static char ret[rl_PRINTF_LENGTH];
676 
677  cptr = strstr(string,option);
678  if(cptr == NULL) return def;
679 
680  cptr = strstr(cptr,"=");
681  if(cptr == NULL) return def;
682 
683  cptr++;
684  quote = *cptr;
685  cptr++;
686  while(i < ((int) sizeof(ret)-1))
687  {
688  if(cptr[i] == quote || cptr[i] == '\0') break;
689  ret[i] = cptr[i];
690  i++;
691  }
692  ret[i] = '\0';
693  return ret;
694 }
#define rl_PRINTF_LENGTH
Definition: rldefine.h:71

◆ rlupper()

int rlupper ( char *  str)
convert str to upper case

Definition at line 727 of file rlcutil.cpp.

728 {
729  if(str == NULL) return -1;
730  while(*str != '\0')
731  {
732  *str = toupper(*str);
733  str++;
734  }
735  return 0;
736 }

◆ rlvsnprintf()

int rlvsnprintf ( char *  text,
int  len,
const char *  format,
va_list  ap 
)
  like vsnprintf but portable

Definition at line 197 of file rlcutil.cpp.

198 {
199  int ret;
200 
201 #ifdef RLWIN32
202  if(format == NULL || format[0] == '\0')
203  {
204  text[0] = '\0';
205  return 1;
206  }
207  ret = _vsnprintf(text, len, format, ap);
208 #endif
209 #ifdef __VMS
210  static char vms_is_deprecated[rl_PRINTF_LENGTH];
211  if(format == NULL || format[0] == '\0')
212  {
213  text[0] = '\0';
214  return 1;
215  }
216  ret = vsprintf(vms_is_deprecated, format, ap);
217  rlstrncpy(text,vms_is_deprecated,len);
218 #endif
219 #ifdef RLUNIX
220  if(format == NULL || format[0] == '\0')
221  {
222  text[0] = '\0';
223  return 1;
224  }
225  ret = vsnprintf(text, len, format, ap);
226 #endif
227  return ret;
228 }
#define rl_PRINTF_LENGTH
Definition: rldefine.h:71
char * rlstrncpy(char *dest, const char *source, int n)
Definition: rlcutil.cpp:169

◆ rlWriteFile()

int rlWriteFile ( const char *  filename,
void *  data,
int  len 
)
write data to file
return := number of bytes written | -1

Definition at line 821 of file rlcutil.cpp.

822 {
823  FILE *fout = fopen(filename,"w");
824  if(fout == NULL)
825  {
826  printf("ERROR: rlWriteFile() could not write to %s\n", filename);
827  return -1;
828  }
829  int ret = fwrite(data,1,len,fout);
830  fclose(fout);
831  return ret;
832 }