gCAD3D 2.40
ut_os_aix.c File Reference

opsys functions for unix (AIX, Linux) More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <dlfcn.h>
#include <stdarg.h>
#include <dirent.h>
#include <sys/utsname.h>
#include <time.h>
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "../ut/ut_txt.h"
#include "../ut/ut_os.h"
#include "../ut/ut_cast.h"
#include "../ut/func_types.h"

Macros

#define PTRSIZ   sizeof(void*)
 f. access, R_OK .. More...
 
#define VER_LIBC_MAJ   2
 
#define VER_LIBC_MIN   9
 
#define VER_GTK_MAJ   2
 
#define VER_GTK_MIN   16
 

Functions

int OS_stdout__ (int mode, char *fn)
 
int OS_file_waitExist (char *fn, int maxTim)
 
int OS_config ()
 
char * OS_prc__ ()
 
int OS_ck_libcVersion (int vMaj, int vMin)
 
int OS_ck_SW_is_installed (char *ssw)
 
int OS_CkPrcIsActive (char *prcNam)
 
int OS_Init_ (char *cmd)
 
void OS_get_curDir (char *sd, int sSiz)
 
char * OS_get_lang ()
 
char * OS_get_browser ()
 
int OS_get_dialog ()
 
char * OS_get_edi ()
 
char * OS_get_term ()
 
char * OS_get_vwr_ps ()
 
char * OS_get_user ()
 
int OS_browse_ (char *filnam)
 
int OS_edit_ (char *filnam)
 
char * OS_get_printer ()
 
int OS_spawn_wait (char *cmd, int iwait)
 
void OS_Wait (int millisecs)
 
void OS_beep ()
 
char * OS_os_s ()
 
int OS_os_bits ()
 
void OS_date (long *i1, long *i2, long *i3)
 
char * OS_date1 ()
 
 OS_date_cmp (time_t *tim1, time_t *tim2)
 
void OS_time (long *i1, long *i2, long *i3)
 
int OS_timA_now (char *sts1)
 
int OS_tim_timA (struct tm *tm, char *stA)
 
int OS_timA_diff_s (double *dd, char *sts1, char *sts2)
 
double OS_prc_time_diff (double timStart)
 
double OS_prc_time_start ()
 
double OS_rTime ()
 
int OS_TimeStamp (TimeStamp *ts1)
 
int OS_system (char *buf)
 
int OS_sys1 (char *sOut, int sSiz, char *cmd)
 
int OS_exec (char *txt)
 
int OS_ckFileWritable (char *fnam)
 
int OS_checkFilExist (char *filnam, int mode)
 
int OS_checkDirExist (char *dirnam)
 
char * OS_get_dir_pwd ()
 
int OS_ck_DirAbs (char *fNam)
 
int OS_dirAbs_fNam (char *dirOut, char *fNam)
 
 OS_file_date_m (time_t *tim_m, char *filnam)
 
long OS_FilSiz (char *filnam)
 
int OS_check_isDir (char *dirnam)
 
int OS_dir_root (char *roots, int csiz)
 
int OS_dir_ck1 (char *p1)
 
int OS_dir_ck2 (char *dir)
 
int OS_dir_scan_ (char *cbuf, int *iNr)
 
int OS_filterff (char *fnamO, char *fnamI, char *ftext)
 
int OS_file_delGrp (char *fNam)
 
int OS_file_copy (char *oldNam, char *newNam)
 
int OS_file_rename (char *fnOld, char *fnNew)
 
int OS_file_delete (char *fNam)
 
int OS_file_readm1 (char *cbuf, int cSiz, char *fnam)
 
int OS_prc_dll (int mode, void *fDat)
 
int OS_dll_build (char *dllNam)
 =================================================================== More...
 
int OS_dll_close (void **dl1)
 
int OS_dll__ (void **dl1, int mode, void *fDat)
 
int OS_debug_dll_ (char *dllNam)
 
int OS_dll_do (char *dllNam, char *fncnam, void *fncdat)
 
int OS_dll_run (char *dllNam, char *fncNam, void *fncDat)
 
int OS_file_zip (int mode, char *fnFrom, char *fnTo)
 
int OS_file_concat (char *fno, char *fn1, char *fn2)
 
int OS_file_compare_A (char *fn1, char *fn2)
 
char * OS_get_imgConv1 ()
 
char * OS_get_imgConv2 ()
 
int OS_jpg_bmp (char *fn_jpg, char *fn_bmp)
 
int OS_dev_ck ()
 
int OS_err1 (char *fNam)
 

Variables

static char txbuf [256]
 

Detailed Description

opsys functions for unix (AIX, Linux)

Needs:
#include "../ut/ut_os.h" // OS_ ..
-ldl (unix)
=====================================================
List_functions_start:
OS_Init_ (argv[0]); save basedir
OS_os_s returns "Linux" or "MS"
OS_os_bits returns 32 or 64
// OS_id Read System - ID (uname -m) (HW-ID!)
OS_date Datum (als iyear, imon, iday) holen
OS_date1 Format: 2002/09/04-13:30:33
OS_time Zeit (ihour, imin, isec) holen
OS_timA_now get timestamp-string "now"; |2017-10-14 10:32:07|
OS_timA_diff_s get difftime in seconds of two timestrings
OS_tim_timA get timestamp from time-string
OS_rTime returns time in sec's, (res = mycrosec's)
OS_prc_time_start returns processor-time
OS_prc_time_diff returns processor-time
OS_TimeStamp get TimeStamp (sec; res = 0.01; ~1 year)
OS_date_cmp compare 2 dates
OS_Wait in millisecs
OS_system Perform OS-Command; wait for completion (system)
OS_sys1 get systemCommand (popen)
OS_exec Perform OS-Command; do not wait for completion.
OS_spawn_wait execute command and wait explicit
OS_browse_ display file in HTML-browser
OS_err1 print errno
OS_check_isDir is this dir (or file ..)
OS_checkFilExist check if File or Directory exists
OS_checkFileWritable check if file is writeable;
OS_checkDirExist und try to create dir
OS_CkPrcIsActive check if process with name prcNam is active
OS_ck_SW_is_installed Test if software <ssw> is installed
OS_prc__ get full filename of active process
OS_get_curDir get current directory
OS_get_lang getenv("LANG")
OS_get_edi liefert bei Linux "gedit"
OS_get_printer get 1. word of /etc/printcap
OS_get_browser liefert konqueror/mozilla/netscape
OS_get_term liefert bei Linux "xterm "
OS_get_dialog check if zenity is installed
OS_get_imgConv1 returns jpg2bmp-converter; eg /usr/bin/djpeg
OS_get_imgConv2 returns bmp2jpg-converter-program; eg /usr/bin/cjpeg
OS_jpg_bmp convert BMP -> JPG
OS_get_dir_pwd get current process-working-directory "PWD"
OS_ck_DirAbs check if string is absoluter or relativer Filname
OS_dirAbs_fNam get full (absolut) path from filename
OS_dir_scan_ scan (list) directory (see UTX_dir_listf)
OS_dir_root Liste der untersten Rootverzeichnisse anlegen
OS_dir_ck1 check ob rootDir beschreibbar ist
OS_stdout__ direct console-output into file
OS_file_copy copy file
OS_file_rename rename File; keine Wildcards !
OS_file_delete delete File; keine Wildcards !
OS_file_delGrp Delete files/Wildcard; Single File "remove (fn);"
Rename files via "rename (oldNam, newNam);"
OS_file_waitExist wait max <maxTim> secords for existence of file <fn>
OS_file_readm1 read complete file into memory
OS_file_zip compress/uncompress file
OS_file_concat concatenate 2 files (fno = fn1 + fn2)
OS_file_compare_A compare 2 files ascii
OS_file_date_m get last modification-date of file
OS_FilSiz query filesize
OS_filterff sort & filter file
OS_dll_do load dll, start function, unload dll
OS_dll_run load dll, start function, unload dll
OS_dll__ load dll| start function| unload dll
OS_dll_build (re)build dll
OS_dll_close close dll
List_functions_end:
=====================================================
see also:
../ut/ut_os__.c OS-independant functions

Macro Definition Documentation

#define PTRSIZ   sizeof(void*)

f. access, R_OK ..

#define VER_LIBC_MAJ   2
#define VER_LIBC_MIN   9
#define VER_GTK_MAJ   2
#define VER_GTK_MIN   16

Function Documentation

int OS_stdout__ ( int  mode,
char *  fn 
)

OS_stdout__ direct console-output into file mode 0 open file for console-output 1 reconnect stdout

int OS_file_waitExist ( char *  fn,
int  maxTim 
)
int OS_config ( )
char* OS_prc__ ( )

OS_prc__ get full filename of active process

int OS_ck_libcVersion ( int  vMaj,
int  vMin 
)
* test if new software with Lib-version <versionLinked> can be used.
* <versionLinked> must be equal or less then the active Lib-version.
* View the active GNU-Lib-version in a shell with "/lib/libc.so.6"
* Mandriva 2009 reports "glibc 2.8"
* Input:
* versionLinked of the software at the time of binding
* RetCod: 0 OK; active-libc-version is >= <versionLinked>
* -1 Error; active-libc-version is < <versionLinked>
*
int OS_ck_SW_is_installed ( char *  ssw)
int OS_CkPrcIsActive ( char *  prcNam)
* OS_CkPrcIsActive check if process with name prcNam is active
* Retcode:
* 0 process is active
* 1 process is not active
*
int OS_Init_ ( char *  cmd)
void OS_get_curDir ( char *  sd,
int  sSiz 
)

OS_get_curDir get current directory

char* OS_get_lang ( )

returns language; eg "de" or "en"

char* OS_get_browser ( )

returns html-browser; eg "mozilla"

int OS_get_dialog ( )

check if zenity is installed. 1=yes, -1=no.

char* OS_get_edi ( )

returns fileEditorProgram; eg "gedit " or "kedit "

char* OS_get_term ( )

returns console-program; eg "xterm -e "

char* OS_get_vwr_ps ( )

returns ps-viewer (gv|evince)

char* OS_get_user ( )

returns console-program; eg "xterm -e "

int OS_browse_ ( char *  filnam)
* html-browse <filnam>
* do not wait for end of process.
*
int OS_edit_ ( char *  filnam)
* <edit> <filnam>
* waits for end of process.
* DO NOT USE: use APP_edit
*
char* OS_get_printer ( )

get 1. word of /etc/printcap

int OS_spawn_wait ( char *  cmd,
int  iwait 
)
* execute command and wait explicit
* cmd should be one word without parameters ...
* iwait = time to wait in secs
*
void OS_Wait ( int  millisecs)

wait - milli-seconds (<millisecs> * 0.001 seconds)

void OS_beep ( )
char* OS_os_s ( )
int OS_os_bits ( )
void OS_date ( long *  i1,
long *  i2,
long *  i3 
)

OS_date returns (year, mon, day)

char* OS_date1 ( )
* Format: 2002/09/04-13:30:33
* printf ("# %s\n", OS_date1());
*
OS_date_cmp ( time_t *  tim1,
time_t *  tim2 
)
void OS_time ( long *  i1,
long *  i2,
long *  i3 
)

OS_time returns (hour, min, sec)

int OS_timA_now ( char *  sts1)
int OS_tim_timA ( struct tm *  tm,
char *  stA 
)
* OS_tim_timA get timestamp from time-string
* timestring format: |2017-10-14 10:32:07|
*
int OS_timA_diff_s ( double *  dd,
char *  sts1,
char *  sts2 
)
* get difftime in seconds of two timestrings
* timestring format: |2017-10-14 10:32:07|
*
double OS_prc_time_diff ( double  timStart)
* OS_prc_time_diff returns processor-time
* processor-time does not include usleep ..
* Example:
* d1 = OS_prc_start_time();
* ..
* printf(" processor-time used (secs) %lf \n", OS_prc_diff_time(d1));
*
double OS_prc_time_start ( )
* OS_prc_time_start returns processor-time
*
double OS_rTime ( )
* OS_rTime returns time in sec's, (res = mycrosec's)
* Example:
* d1 = OS_rTime (); ... d2 = OS_rTime ();
* printf(" time used (secs) %lf \n",d2 - d1);
*
int OS_TimeStamp ( TimeStamp ts1)
* OS_TimeStamp returns TimeStamp (sec; res = 0.01; ~1 year)
*
* Example:
* TimeStamp ts1=0, ts2;
* OS_TimeStamp (&ts2);
* if(ts1 != ts2) {update; ts1 = ts2; }
*
int OS_system ( char *  buf)
* OS_system Perform OS-Command; wait for completion (system)
* do not wait: use OS_exec
*
int OS_sys1 ( char *  sOut,
int  sSiz,
char *  cmd 
)
* OS_sys1 get systemCommand (popen)
* RetCod:
* >0 OK, nr of chars returned in sOut
* -1 cannot open pipe
* -2 sOut too small
*
int OS_exec ( char *  txt)
* OS_exec Perform OS-Command; do not wait for completion.
* do wait: use OS_system
*
int OS_ckFileWritable ( char *  fnam)
* OS_checkFileWritable check if file is writeable;
* 0=no, 1=yes.
*
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_checkDirExist ( char *  dirnam)
* if dir dirnam does not exist, try to create it.
* Nur testen ob directory existiert: use OS_checkFilExist.
*
* rc = 0 = Fehler; Dir existiert NICHT.
* rc = 1 = Dir sucessfully created.
* rc = 2 = Dir did already exist.
*
char* OS_get_dir_pwd ( )

OS_get_dir_pwd get current process-working-directory "PWD"

int OS_ck_DirAbs ( char *  fNam)
* check if string is absolute or relative Filname ..
* Returncodes:
* 0 = yes, absolut
* 1 = no, relativ ..
*
* see also OS_dirAbs_fNam
*
* Varianten:
* /dir/fn
* ./fn
* ../dir/fn
* dir/fn
*
int OS_dirAbs_fNam ( char *  dirOut,
char *  fNam 
)

OS_dirAbs_dir get full (absolut) path from filename

OS_file_date_m ( time_t *  tim_m,
char *  filnam 
)
long OS_FilSiz ( char *  filnam)

OS_FilSiz returns filesize in bytes

int OS_check_isDir ( char *  dirnam)
* returns if {dirnam} is directory or file
* rc = 1 = OFF = NO; dirnam is NOT directory
* rc = 0 = ON = OK; dirnam is directory.
* rc = -1 = Error - dirnam does not exist
*
int OS_dir_root ( char *  roots,
int  csiz 
)

OS_dir_root returns a list of root-directories

int OS_dir_ck1 ( char *  p1)
* check rootDir
* irc=0 CD-Rom,
* 1 Diskette,
* 2 normal
*
int OS_dir_ck2 ( char *  dir)
* check if directory is writable
* irc=0=no, not writable,
* 1=jes, directory is writable
*
int OS_dir_scan_ ( char *  cbuf,
int *  iNr 
)
* scan directory
* iNr = 0: init suche; zu scannender Pfad ist cbuf.
* iNr > 0: cbuf ist next found file; do not change iNr! (Filename ohne Path !)
* iNr < 0; kein weiteres File found; directory closed.
*
int OS_filterff ( char *  fnamO,
char *  fnamI,
char *  ftext 
)
* sort & filter file. Ignore case.
* gesamte Liste (Datei) sortieren u. filtern;
* ftext = Filtertext
* RC = -1: kein Inputfile
*
int OS_file_delGrp ( char *  fNam)

OS_file_delGrp Delete files/Wildcard; Single File "remove (fn);"

int OS_file_copy ( char *  oldNam,
char *  newNam 
)

OS_file_copy copy file

int OS_file_rename ( char *  fnOld,
char *  fnNew 
)

rename File; NO Wildcards !

int OS_file_delete ( char *  fNam)
* delete File; NO Wildcards !
* MS u Unix gleich.
* retCod: 0=OK; -1=Error.
*
int OS_file_readm1 ( char *  cbuf,
int  cSiz,
char *  fnam 
)
* read complete file into memory
* Datei fnam in den Buff cbuf einlesen.
* cSiz = size of cbuf
* Retcode:
* -1 Error
* >0 size of file
*
int OS_prc_dll ( int  mode,
void *  fDat 
)
* load dll | start dll-function | unload dll
* TODO: replace with OS_dll__
* mode >=0 work (mode = nc-function from NCCmdTab)
* mode -1 = work (programfunction fDat = "FUNC_xx")
* mode -2 = open (load Lib fNam)
* mode -3 = connect (connect Func fDat)
* mode -4 = unload active lib
*
int OS_dll_build ( char *  dllNam)

===================================================================

===================================================================

* OS_dll_build (re)build dll
* wenn .mak vorh: compile/link
*
int OS_dll_close ( void **  dl1)
int OS_dll__ ( void **  dl1,
int  mode,
void *  fDat 
)
* load dll | start dll-function | unload dll
* Input:
* mode
* FUNC_LOAD_only = load DLL. fDat: dll-name without directory, fTyp.
* FUNC_LOAD_all = load DLL. fDat: dll-name without directory, fTyp.
* FUNC_CONNECT = connect (connect Func fDat)
* FUNC_EXEC = work (call active Func with parameter fDat)
* FUNC_UNLOAD = unload active lib; fDat unused
* FUNC_RECOMPILE = recompile DLL; fDat ?
* Output:
* dll (address of) loaded DLL
* retCod 0=OK; else error
*
int OS_debug_dll_ ( char *  dllNam)
* wenn im Debug-Modus wird hier gestoppt;
* In .gdbinit muss stehen:
* wenn Debugger steht, eingeben "watch varnam" und "c"
*
* Zweck: Debugger kann DLL nur ansprechen wenn geladen.
*
int OS_dll_do ( char *  dllNam,
char *  fncnam,
void *  fncdat 
)

load dll; start function fncNam (fncDat); unload dll.

int OS_dll_run ( char *  dllNam,
char *  fncNam,
void *  fncDat 
)

load dll; start function fncNam (fncDat); unload dll. see also UI_DllLst_work

int OS_file_zip ( int  mode,
char *  fnFrom,
char *  fnTo 
)
* compress | uncompress file
* mode = 0: compress: gzip -c9 t1.gcad > t1.gcaz
* mode = 1: uncompress: gzip -dc t1.gcaz > t1.gcad
*
int OS_file_concat ( char *  fno,
char *  fn1,
char *  fn2 
)
int OS_file_compare_A ( char *  fn1,
char *  fn2 
)
char* OS_get_imgConv1 ( )

returns jpg2bmp-converter-program; eg /usr/bin/djpeg

char* OS_get_imgConv2 ( )

returns bmp2jpg-converter-program; eg /usr/bin/cjpeg

int OS_jpg_bmp ( char *  fn_jpg,
char *  fn_bmp 
)
int OS_dev_ck ( )
int OS_err1 ( char *  fNam)
* OS_err1 print errno
* Example:
*

Variable Documentation

char txbuf[256]
static