C-KIT-GUI-GTK 0.60
gui_ut.c File Reference

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"

Macros

#define ON   0
 
#define OFF   1
 

Functions

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)
 

Variables

int TX_mode = ON
 

Detailed Description

utility-functions

Macro Definition Documentation

#define ON   0
#define OFF   1

Function Documentation

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)
UTX_ck_num_i test if word is numeric (int)
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 
)
UTX_wrf_str write string -> file
see UTF_wrf_line
long OS_FilSiz ( char *  filnam)

OS_FilSiz returns filesize in bytes

int MSG_Tip ( char *  key)
dummyfunction for MSG_Tip
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)
UTI_round_i2b round integer to byte (back: UTI_round_b2i)
Purpose: save Integers in a single byte.
UTI_round_i2b(10000) -> 14
UTI_round_b2i(14) -> 16384
int UTI_round_b2i ( int  i1)

UTI_round_b2i make integer from byte (back from UTI_round_i2b)

char* OS_get_tmp_dir ( )

returns tempDir (with closing '/') <gcad_dir_local>tmp/

char* OS_get_ico_dir ( )

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 
)
OS_checkFilExist check if File or Directory exists
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 !

int OS_get_dialog ( )

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)
int gCad_fini ( )
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 
)
UTX_fgetLine read line nr. <lNr> out of file <filNam>
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 
)
OS_file_sig_cre create signal-file
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 
)

Variable Documentation

int TX_mode = ON