utility-functions  
More...
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/stat.h>
#include "../gui/gui_ut.h"
#include "../ut/ut_cast.h"
#include "../ut/ut_umem.h"
 | 
| #define  | ON   0 | 
|   | 
| #define  | OFF   1 | 
|   | 
 | 
| void  | UTX_str_file (char *txbuf, long *fSiz, char *fnam) | 
|   | 
| int  | UTX_ck_num_i (char *s1) | 
|   | 
| int  | CSV_read__ (CSV_struct *fTyp, char *sb, int sSiz, FILE *fpi) | 
|   | 
| int  | UTX_wrf_str (char *fnam, char *txt) | 
|   | 
| long  | OS_FilSiz (char *filnam) | 
|   | 
| int  | MSG_Tip (char *key) | 
|   | 
| int  | UTI_round_i2b (int i1) | 
|   | 
| int  | UTI_round_b2i (int i1) | 
|   | 
| char *  | OS_get_tmp_dir () | 
|   | 
| char *  | OS_get_ico_dir () | 
|   | 
| void  | OS_Wait (int millisecs) | 
|   | 
| int  | OS_checkFilExist (char *filnam, int mode) | 
|   | 
| int  | OS_file_delete (char *fNam) | 
|   | 
| int  | OS_get_dialog () | 
|   | 
| void  | OS_get_curDir (char *sd, int sSiz) | 
|   | 
| int  | UTX_cnr_chr (char *txt, char c1) | 
|   | 
| char *  | UTX_CleanCR (char *string) | 
|   | 
| int  | UTX_endDelChar (char *txtbuf, char chr) | 
|   | 
| int  | MSG_get_1 (char *msg, int msgSiz, char *key, char *fmt,...) | 
|   | 
| int  | MSG_err_1 (char *key, char *fmt,...) | 
|   | 
| int  | MSG_pri_1 (char *key, char *fmt,...) | 
|   | 
| char *  | MSG_get_str (char *key) | 
|   | 
| int  | gCad_fini () | 
|   | 
| void  | TX_Print (char *txt,...) | 
|   | ==========================================================  More...
  | 
|   | 
| void  | TX_Error (char *txt,...) | 
|   | ==========================================================  More...
  | 
|   | 
| void  | TX_Write (char *txt) | 
|   | ==========================================================  More...
  | 
|   | 
| int  | UTX_fgetLine (char *cbuf, int sizBuf, char *filNam, int lNr) | 
|   | 
| int  | OS_file_sig_wait (int mode, void *data) | 
|   | 
| int  | OS_file_sig_cre (int mode, void *data) | 
|   | 
| int  | UTX_tmp_file (char *fBuf, long *fSiz, char *fNam) | 
|   | 
      
        
          | void UTX_str_file  | 
          ( | 
          char *  | 
          txbuf,  | 
        
        
           | 
           | 
          long *  | 
          fSiz,  | 
        
        
           | 
           | 
          char *  | 
          fnam  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
UTX_str_file read file -> string Used by UTX_tmp_file() fSiz must have filesize; see OS_FilSiz. 
 
 
      
        
          | int UTX_ck_num_i  | 
          ( | 
          char *  | 
          s1 | ) | 
           | 
        
      
 
RetCod:  -1   s1 does NOT start with an integer
         else nr of characters (including sign)
  
 
 
      
        
          | int CSV_read__  | 
          ( | 
          CSV_struct *  | 
          fTyp,  | 
        
        
           | 
           | 
          char *  | 
          sb,  | 
        
        
           | 
           | 
          int  | 
          sSiz,  | 
        
        
           | 
           | 
          FILE *  | 
          fpi  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
      
        
          | int UTX_wrf_str  | 
          ( | 
          char *  | 
          fnam,  | 
        
        
           | 
           | 
          char *  | 
          txt  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
      
        
          | long OS_FilSiz  | 
          ( | 
          char *  | 
          filnam | ) | 
           | 
        
      
 
OS_FilSiz returns filesize in bytes 
 
 
      
        
          | int MSG_Tip  | 
          ( | 
          char *  | 
          key | ) | 
           | 
        
      
 
MSG_Tip         add tooltip to last created GUI-widget
 
msg out of files  msg_de.txt  msg_en.txt ..
  
 
 
      
        
          | int UTI_round_i2b  | 
          ( | 
          int  | 
          i1 | ) | 
           | 
        
      
 
  Purpose: save Integers in a single byte.
  
 
 
      
        
          | int UTI_round_b2i  | 
          ( | 
          int  | 
          i1 | ) | 
           | 
        
      
 
UTI_round_b2i make integer from byte (back from UTI_round_i2b) 
 
 
returns tempDir (with closing '/') <gcad_dir_local>tmp/ 
 
 
returns directory for icons (with closing '/') <gcad_dir_bin>icons/ 
 
 
      
        
          | void OS_Wait  | 
          ( | 
          int  | 
          millisecs | ) | 
           | 
        
      
 
wait - milli-seconds (<millisecs> * 0.001 seconds) 
 
 
      
        
          | int OS_checkFilExist  | 
          ( | 
          char *  | 
          filnam,  | 
        
        
           | 
           | 
          int  | 
          mode  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
mode = 0: display message sofort;
mode = 1: just fix returncode, no message
mode = 2: make Errormessage (
TX_Error) if File does not exist
 
rc = 0 = Fehler; datei existiert NICHT.
rc = 1 = OK, Datei existiert.
  
 
 
      
        
          | int OS_file_delete  | 
          ( | 
          char *  | 
          fNam | ) | 
           | 
        
      
 
delete File; NO Wildcards ! 
 
 
check if zenity is installed. 1=yes, -1=no. 
 
 
      
        
          | void OS_get_curDir  | 
          ( | 
          char *  | 
          sd,  | 
        
        
           | 
           | 
          int  | 
          sSiz  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
OS_get_curDir get current directory 
 
 
      
        
          | int UTX_cnr_chr  | 
          ( | 
          char *  | 
          txt,  | 
        
        
           | 
           | 
          char  | 
          c1  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
returns nr of char c1 in string txt 
 
 
      
        
          | char* UTX_CleanCR  | 
          ( | 
          char *  | 
          string | ) | 
           | 
        
      
 
UTX_CleanCR              Delete Blanks, CR
's and LF's at end of 
string 
returns positon of stringterminator \0
 
see also UTX_del_follBl UTX_CleanSC
  
 
 
      
        
          | int UTX_endDelChar  | 
          ( | 
          char *  | 
          txtbuf,  | 
        
        
           | 
           | 
          char  | 
          chr  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
UTX_endDelChar if last char of string == chr: remove it. 
 
 
      
        
          | int MSG_get_1  | 
          ( | 
          char *  | 
          msg,  | 
        
        
           | 
           | 
          int  | 
          msgSiz,  | 
        
        
           | 
           | 
          char *  | 
          key,  | 
        
        
           | 
           | 
          char *  | 
          fmt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
      
        
          | int MSG_err_1  | 
          ( | 
          char *  | 
          key,  | 
        
        
           | 
           | 
          char *  | 
          fmt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
      
        
          | int MSG_pri_1  | 
          ( | 
          char *  | 
          key,  | 
        
        
           | 
           | 
          char *  | 
          fmt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
      
        
          | char* MSG_get_str  | 
          ( | 
          char *  | 
          key | ) | 
           | 
        
      
 
 
      
        
          | void TX_Print  | 
          ( | 
          char *  | 
          txt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
========================================================== 
========================================================== formatiertes Rausschreiben; wie bei printf; mehr als 4 Parm's Problem? 
 
 
      
        
          | void TX_Error  | 
          ( | 
          char *  | 
          txt,  | 
        
        
           | 
           | 
            | 
          ...  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
========================================================== 
========================================================== 
 
 
      
        
          | void TX_Write  | 
          ( | 
          char *  | 
          txt | ) | 
           | 
        
      
 
========================================================== 
========================================================== direkt rausschreiben. 
 
 
      
        
          | int UTX_fgetLine  | 
          ( | 
          char *  | 
          cbuf,  | 
        
        
           | 
           | 
          int  | 
          sizBuf,  | 
        
        
           | 
           | 
          char *  | 
          filNam,  | 
        
        
           | 
           | 
          int  | 
          lNr  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
            first line has lineNr 1
sizBuf      size of cbuf
rc -1   File does not exist
rc -2   Line does not exist
rc  0   OK
  
 
 
      
        
          | int OS_file_sig_wait  | 
          ( | 
          int  | 
          mode,  | 
        
        
           | 
           | 
          void *  | 
          data  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
RetCod: 0 OK, data valid -1 cancelled by user 
 
 
      
        
          | int OS_file_sig_cre  | 
          ( | 
          int  | 
          mode,  | 
        
        
           | 
           | 
          void *  | 
          data  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Input:
  mode      0  clear file; data = signalfilename; must be done first
            1  write data = string (null terminated) -> signalfile
            2  write data = int (4 bytes) -> signalfile
           99  cancelled by user (following read gives retCod -1)
           -1  read data = string (null terminated) -> data (size of data !)
           -2  read data = int (4 bytes) -> data
Output:
  data     text or int (mode);
  RetCod:   0  OK, data valid
           -1  cancelled by user
  
 
 
      
        
          | int UTX_tmp_file  | 
          ( | 
          char *  | 
          fBuf,  | 
        
        
           | 
           | 
          long *  | 
          fSiz,  | 
        
        
           | 
           | 
          char *  | 
          fNam  | 
        
        
           | 
          ) | 
           |  |