ut_txt.c File Reference


Detailed Description

TEXT FUNCTIONS UTX_.

=====================================================
Liste_Funktionen_Beginn:

UTX_cp_word_2_upper    copy and change word into capitalletters. case
UTX_cp_nchr_2_upper    copy and change n chars into capitalletters.
UTX_cp_word_term       copy word bis zum Terminator.
UTX_cp_word__          copy next word
UTX_cp_word_t          copy next word, give terminator
UTX_cp_expr            copy expression (without brackets)
UTX_cp_print           add maxLen printable characters from txi --> txo
// APT_cp_ausd         kopiert einen Ausdruck (kompletter Klammerinhalt)
UTX_cp_Line            copy a Line (terminated by '\n')
UTX_cp_right           copy n chars from right side of string
UTX_cpLn_2cp           copy line between 2 pointers; del ending blanks, lf.

UTX_add_i_u            add integer to string
UTX_add_db             add double unformatted; Trennzeichen ist blank
UTX_add_pt             add Pointcoords unformatted; Trennzeichen ist blank
UTX_add_fl_u           add double unformatted (del foll. 0s and ".")
UTX_add_fl_u2          add double,double unformatted (del foll. 0s and ".")
UTX_add_fl_u3          add 3 doubles unformatted (del foll. 0s and ".")
UTX_add_fl_f           add double with x digits after dec.point
UTX_add_fl_10          add double with 10 signif digits
UTX_add_fl_15          add double with 15 signif digits
UTX_add_slash          add closing "/" to string (for dirs)

UTX_db_tx              read float from ascii-string

UTX_fgets              Zeile aus Datei lesen und CRs LFs am Ende deleten.
UTX_fgetLine           Zeile Nr. <lNr> aus Datei <filNam> lesen
UTX_fsavLine           Zeile Nr. <lNr> into Datei <filNam> schreiben
UTX_fRevL              File revert lines; eine Datei zeilenweise umdrehen;
UTX_setup_get          get parameters (typ, value) from setup-file

UTX_CleanCR            Delete Blanks, CRs u. LFs am Ende.
UTX_CleanLF            change lineEnd (Cr|CrLf ..) to single LF.
UTX_CleanCommC         Clean C-Comments (remove foll. blanks & // comments)
UTX_Clean_db           clean doubles (change ',' into '.') See also UTX_chg_chr1.
UTX_CleanSC            Change SpecialChars into '?' (alle  -> ?)
UTX_CleanBracks        Remove first/last char (brackets ..)
UTX_chg_chr1           in cBuf alle oldChr aendern in newChr
UTX_chg_str1           change substring in string
UTX_chg_nr             change following int-number
UTX_chg_2_lower        change string to lowercase (see "_upper")
UTX_endDelChar         if last char of string == chr: remove it.
UTX_endAddChar         if last char of string != chr: add it.
UTX_del_chr            delete all characters <cx> out of string cbuf
UTX_del_follBl         delete following blanks
UTX_del_foll0          Delete following 0s and following ".".
UTX_del_FilTx          delete all lines containing <dtxt>

UTX_len__              change stringlength to <len>; cut or add blanks

UTX_insert1            insert Textstring into Textbuffer
UTX_ins_s2             insert string links (s1 = s2//s1)
UTX_cut1               cut Textstring out of Textbuffer

UTX_pos_EOS            find end of string ('\0')
UTX_pos_del            find next delimiter
UTX_pos_del_next       find next delimiter (blank after cPos)
UTX_pos_del_prev       find previous delimiter (blank vor cPos)
UTX_pos_skipLeadBlk    skip blanks (returns Position of first non-blank) INLINE
UTX_pos_1n             ersetzt durch UTX_pos_skipLeadBlk
UTX_pos_skipWord       skip Word (ret. Pos. of first char after word)
UTX_pos_skipWords      skip n Words (ret. Pos. of first char after word)
UTX_pos_skipBrack      find corresponding ')' (returns Position of ')')
UTX_pos_skipBrack1     find corresponding ')' (returns Position of ')')
UTX_pos_skipDeli1      skip delimiter ' ' ',' '\n' '\r' '\t'
UTX_pos_skip_num       skip number
UTX_pos_skip_int       skip int-number

UTX_skip_1bl           skip this char and following blanks    INLINE

UTX_ck_caseChr         compare 2 characters - ignore case
UTX_ck_casenChr        compare n chars of 2 strings - ignore case
UTX_ck_caseStr         compare 2 strings - ignore case
UTX_ckc_Del1           check if char is a delimiter
UTX_ck_num1            test ob word numer ist
UTX_ck_uml_c           check for Umlaut (); change to normal char
UTX_ck_uml_s           change all umlaute of string
UTX_get_word           returns typ of word:
UTX_cmp_word_wordtab   check if word wd1 is in list wdtab
UTX_find_Del1          find next delimiter ' ' '=' ',' '\n' '\t' '{' ...
UTX_find_word1         Wort in Zeile suchen
UTX_find_wordNr        find word "was" in string "wo"; return nr of occurences
UTX_find_strrstr       find last occurence of str in cbuf
UTX_strcmp_right       check if right part of string equals string

UTX_memstr             den String sstr im Bereich von - bis suchen.
UTX_memFind            Daten suchen
UTX_memFind1           Daten mit bestimmter Laenge suchen

UTX_wordnr             returns nr of words
UTX_cnr_chr            returns nr of a certain char in string

UTX_wrf_str            Eine Variable in eine datei ausgeben;

UTX_dir_listf          Dateiliste in eine Datei ausgeben
UTX_cat_file           Datei in (offene) Datei ausgeben
UTX_ptab_f             Pointertabelle aus Datei erstellen

UTX_ftyp_s             get filetyp from filename (change => upper)
UTX_fnam_s             get fnam from string
UTX_fdir_s             get fileDirectory from string
UTX_ftyp_cut           remove Filetyp from string
UTX_safeName           make a safe modelname from a modelname

UTX_htm_fop            open html-textfile
UTX_htm_fcl            close html-textfile

UTX_dump_cnl           ausdrucken (printf) bis next '\n'
UTX_dump_c__           ausdrucken (printf) der naechsten <cLen> chars
UTX_dump_s__           dump String (replace \n\r\t\0)
UTX_dump__             dump String (replace \n\r\t)

Liste_Funktionen_Ende:
=====================================================

- see also:
UtxTab_*               Class for stacking Textstrings
UTI_iNr_chrNr          give nr of ints for n characters

#include "../xa/MS_Def0.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include "../ut/ut_geo.h"
#include "../ut/ut_txt.h"
#include "../ut/ut_os.h"

Functions

int UTX_len__ (char *txt, int sLen)
int UTX_safeName (char *snam, int mode)
int UTX_ftyp_cut (char *cbuf)
int UTX_ftyp_s (char *ftyp, char *cbuf, int mode)
int UTX_fnam_s (char *fnam, char *cbuf)
int UTX_fdir_s (char *fdir, char *cbuf)
int UTX_cat_file (FILE *fpo, char *fnam)
int UTX_wrf_str (char *fnam, char *txt)
int UTX_dir_listf (char *outFilNam, char *fPath, char *fTyp)
int UTX_ptab_f (void *outSpc, long spcSiz, char *inFilNam)
char * UTX_find_word1 (char *was, char *wo)
int UTX_find_wordNr (int *maxLen, char *was, char *wo)
int UTX_strcmp_right (char *string, char *text)
char * UTX_find_strrstr (char *cbuf, char *str)
int UTX_cmp_word_wordtab (char *wdtab[], char *wd1)
int UTX_ck_num1 (char **pOut, char *cbuf)
int UTX_ck_uml_c (char *iChar)
int UTX_ck_uml_s (char *cbuf, int *lenS, int lenMax)
int UTX_chg_2_lower (char *cbuf)
void UTX_cp_word_2_upper (char *txtout, char *txtin)
int UTX_cp_nchr_2_upper (char *txtout, char *txtin, int iNr)
char * UTX_cp_word__ (char *txtOut, char *txtIn)
char UTX_cp_word_t (char *txtOut, char **cBuf)
char * UTX_cp_word_term (char *txtOut, char *txtIn, char term)
char * UTX_cp_expr (char *cbo, char *cbi)
char * UTX_CleanBracks (char *txtbuf, char ch1, char ch2)
int UTX_chg_chr1 (char newChr, char oldChr, char *cBuf)
int UTX_chg_str1 (long *datSiz, void *datStart, void *insDat, void *delPos, long delSiz)
int UTX_chg_nr (char *txtOut, int iNr)
int UTX_endDelChar (char *txtbuf, char chr)
int UTX_endAddChar (char *txtbuf, char chr)
char * UTX_pos_1n (char string[])
char UTX_pos_del (char **txtIn, char **w_next)
long UTX_pos_del_prev (char *cBuf, long cPos)
long UTX_pos_del_next (char *cBuf, long cPos)
int UTX_add_i_u (char strBuf[], int zahl)
int UTX_add_db (char outBuf[], double *db1)
int UTX_add_pt (char outBuf[], void *pt1)
int UTX_del_chr (char *cbuf, char cx)
void UTX_del_follBl (char *cbuf)
int UTX_del_foll0 (char strBuf[])
int UTX_del_FilTx (char *dtxt, char *filNam)
int UTX_add_fl_u (char strBuf[], double zahl)
int UTX_add_fl_u2 (char outBuf[], double z1, double z2)
int UTX_add_fl_u3 (char outBuf[], double z1, double z2, double z3)
int UTX_add_fl_f (char strBuf[], double zahl, int nkAnz)
int UTX_add_fl_10 (char strBuf[], double d1)
int UTX_add_fl_15 (char strBuf[], double d1)
int UTX_add_slash (char *cbuf)
void UTX_ins_s2 (char *s1, char *s2, int maxlen)
int UTX_fsavLine (char *cbuf, char *filNam, int lNr)
int UTX_fRevL (char *fno, char *fni)
int UTX_fgetLine (char *cbuf, char *filNam, int lNr)
char * UTX_memFind (char *buf, char *str)
char * UTX_memFind1 (char *buf, long bufSiz, char *str, long strSiz)
char * UTX_memstr (char *von, char *bis, char *sstr)
char * UTX_fgets (char *line, int len, FILE *fp)
void UTX_CleanSC (char *string)
void UTX_CleanCR (char *string)
int UTX_CleanLF (char *sBuf)
int UTX_CleanCommC (char *cBuf)
int UTX_Clean_db (char *cbuf)
char * UTX_pos_skipBrack (char *cbuf)
char * UTX_pos_skipBrack1 (char *cbuf)
int UTX_ck_caseChr (char *s1, char *s2)
int UTX_ck_casenChr (char *s1, char *s2, int cNr)
int UTX_ck_caseStr (char *s1, char *s2)
int UTX_ckc_Del1 (char c1)
char * UTX_find_Del1 (char *p1)
char * UTX_pos_skipDeli1 (char *p1)
char * UTX_2db_tx (double *d1, double *d2, char *cbuf)
double UTX_db_tx (char **po, char *pi)
int UTX_pos_skip_num (char **ps)
int UTX_pos_skip_int (char **ps)
char * UTX_pos_skipWord (char *cbuf)
char * UTX_pos_skipWords (int wNr, char *p1)
int UTX_wordnr (char *cbuf)
int UTX_cnr_chr (char *txt, char c1)
int UTX_get_word (char **txtIn, char **w_next, char *txtOut, double *val, char *deli)
int UTX_cut1 (char *cbuf, long *bufSiz, long cPos, long txLen)
int UTX_insert1 (char *cbuf, long *bufSiz, char *auxBuf, long cPos)
int UTX_dump_cnl (char *cPos, int maxLen)
int UTX_dump_c__ (char *cPos, int cLen)
int UTX_dump_s__ (char *cPos, int cNr)
int UTX_dump__ (char *cPos, int maxLen)
int UTX_cp_print (char *txo, char *txi, int maxLen)
int UTX_cp_right (char *sOut, char *sIn, int cNr)
int UTX_cpLn_2cp (char *cbuf, char *pos1, char *pos2, int bufSiz)
int UTX_cp_Line (char *cTo, char **cNxt, char *cFrom, int maxLen)
int UTX_setup_get (char *cval, char *ctyp, char *ctyps, char *fnam)
int UTX_htm_fop (FILE **fp, char *fnam)
int UTX_htm_fcl (FILE **fp)

Variables

const char TX_NUL = '\0'
static double UTX_TOL_min1 = 0.000001
static char TX_buf1 [128]
static char TX_buf2 [128]


Function Documentation

int UTX_len__ ( char *  txt,
int  sLen 
)

UTX_len__ change stringlength to <len>; cut or add blanks

int UTX_safeName ( char *  snam,
int  mode 
)

UTX_safeName make a safe modelname from a modelname mode: 0: change '. ' to '_', do not change '/' (fuer absolute Filenames) 1: change all '. ' and '/' to '_'

int UTX_ftyp_cut ( char *  cbuf  ) 

UTX_ftyp_cut remove Filetyp from string

int UTX_ftyp_s ( char *  ftyp,
char *  cbuf,
int  mode 
)

    UTX_ftyp_s             get filetyp from filename (change => upper)
    Input:
      mode = 0  do not change ftyp-case
      mode = 1  change ftyp > upperLetters
    
    IRC  0: Filetyp out in ftyp (in Groszbuchstaben)
    IRC -1: kein Filetyp gefunden ..
    ".0" kein Filetyp !

int UTX_fnam_s ( char *  fnam,
char *  cbuf 
)

    UTX_fnam_s        get fnam from string
    alles nach dem letzten FilenamedelimiterChar fnam_del ist fileName;
    kein fnam_del: fnam = s
    IRC  0: OK, fnam out
    IRC -1: kein Filename gefunden ..

int UTX_fdir_s ( char *  fdir,
char *  cbuf 
)

    UTX_fdir_s        get fileDirectory from string
    last char ist immer der FilenamedelimiterChar !
    alles vor dem letzten FilenamedelimiterChar fnam_del ist fileDir;
    Wenn erster Char ist fnam_del: absolutes fileDir; else relativ.
    relativ: das pwd (os_bas_dir) vorne weg ...

int UTX_cat_file ( FILE *  fpo,
char *  fnam 
)

    UTX_cat_file           add file into open fileunit
    add file 

int UTX_wrf_str ( char *  fnam,
char *  txt 
)

    UTX_wrf_str            Eine Variable in eine datei ausgeben;
    see UTF_wrf_line

int UTX_dir_listf ( char *  outFilNam,
char *  fPath,
char *  fTyp 
)

    eine Dateiliste in eine Datei ausgeben; nach Dateitypen gefiltert.
    ftyp ohne Stern; also zB ".dat".
    fPath mit oder ohne abschliessenden "/".
    RetCode: -1 = Error; else nr of files written.

int UTX_ptab_f ( void *  outSpc,
long  spcSiz,
char *  inFilNam 
)

eine Pointertabelle (zB fuer GUI_Popup) aus einer Datei erstellen.

char* UTX_find_word1 ( char *  was,
char *  wo 
)

    UTX_find_word1         Wort in Zeile suchen
    das Wort was in der zeile wo suchen. WortTrennzeichen sind " ,()[]".
    IRC = NULL:  ist nicht enthalten
    IRC != NULL = position

int UTX_find_wordNr ( int *  maxLen,
char *  was,
char *  wo 
)

    find word "was" in string "wo"; return nr of occurences
      and max size between (max len of line).

int UTX_strcmp_right ( char *  string,
char *  text 
)

    UTX_strcmp_right              check if text is in string;
    RetCode: 0=equal; else=notEqual.

char* UTX_find_strrstr ( char *  cbuf,
char *  str 
)

    find last occurence of str in cbuf
    NULL: nicht enthalten

int UTX_cmp_word_wordtab ( char *  wdtab[],
char *  wd1 
)

    check if word wd1 is in list wdtab.
    !!! wdtab must be terminated by "" !!!!
    
    Retcod:
      -1    wd1 not in wordList wdtab
      >=0   wd1 is wdtab[Retcod]
    
    char *wdtab[]={"CUT","TRIM","nix",""};
    (int)wNr = UTX_cmp_word_wordtab (wdtab, "TRIMM");

int UTX_ck_num1 ( char **  pOut,
char *  cbuf 
)

    UTX_ck_num1          test ob word numer ist
    +-.  und Ziffern sind numer.!
    RC= 0: ja, text ist eine Zahl
    RC=-1: nein, nur Text.
    pOut = delimitchar (first char after number)

int UTX_ck_uml_c ( char *  iChar  ) 

    check for Umlaut (); change to normal char
    RetCod:
      0=kein Umlaut;
      1=Umlaut changed to normal char.

int UTX_ck_uml_s ( char *  cbuf,
int *  lenS,
int  lenMax 
)

    change all umlaute of string
    RetCod = Anzahl gefundener Umlaute

int UTX_chg_2_lower ( char *  cbuf  ) 

UTX_chg_2_lower change string to lowercase

void UTX_cp_word_2_upper ( char *  txtout,
char *  txtin 
)

    UTX_cp_word_2_upper     copy and change word into capitalletters.
      Max 80 char's.
      txtout / txtin may be same address

int UTX_cp_nchr_2_upper ( char *  txtout,
char *  txtin,
int  iNr 
)

    UTX_cp_nchr_2_upper     copy and change n chars into capitalletters.
      txtout / txtin may be same address

char* UTX_cp_word__ ( char *  txtOut,
char *  txtIn 
)

UTX_cp_word__ copy next word

char UTX_cp_word_t ( char *  txtOut,
char **  cBuf 
)

    UTX_cp_word_t          copy next word, give terminator
    see UTX_cp_word__ UTX_find_Del1 UTX_pos_del
    
    Outputs:
      Returns the delimiter found as single character
      cBuf:   word, Terminator & following blanks skipped
      txtOut: word (no leading/following blanks, no terminator) Max 252 chars.
              can be empty (*txtOut == '\0')
    
    Delimiterzeichen sind:
     "'()*+,-/;<=>  und blank
    
    Usage-example:
      char cBuf[256], tc;
      L_nxt:   tc = UTX_cp_word_t (cBuf, &tPos);
        if(cBuf[0] == '\0') return 0;  // outputstring empty
        ..
        if(tc != '\0') goto L_nxt;     // inputstring empty
    
    Nachfolgend kann man das Wort abtrennen durch
      *cp2 = '\0';

char* UTX_cp_word_term ( char *  txtOut,
char *  txtIn,
char  term 
)

    UTX_cp_word_term       copy word bis zum Terminator.
    returns Pos. HINTER dem Terminator.
    Der term.Character wird nicht nach txtOut kopiert.
    Wenn der Terminator nicht gefunden wird, wird auf das LineEnd gezeigt.

char* UTX_cp_expr ( char *  cbo,
char *  cbi 
)

    UTX_cp_expr        copy expression (without closing bracket)
    !!! cbi may not include starting bracket !!!
    cbi: |3 + 2)|            cbo: |3 + 2|      RetCod: ||
    cbi: |4+(2*4))+2|        cbo: |4+(2*4)|    RetCod: |+2|
    cbi: |sin(4+(2*4))+2|    cbo: |sin(4+(2*4)|    RetCod: |+2|
    RetCode:
      position of first char after closing bracket.
      NULL     Error

char* UTX_CleanBracks ( char *  txtbuf,
char  ch1,
char  ch2 
)

    UTX_CleanBracks        Remove first/last char (brackets ..)
    ACHTUNG: veraendert txtbuf; ueberschreibt ev. last char.
    Example:
      cp1 = UTX_CleanBracks (cp1, '(', ')');

int UTX_chg_chr1 ( char  newChr,
char  oldChr,
char *  cBuf 
)

in cBuf alle oldChr aendern in newChr (Replace)

int UTX_chg_str1 ( long *  datSiz,
void *  datStart,
void *  insDat,
void *  delPos,
long  delSiz 
)

    UTX_chg_str1          change a part in a string
    
    Input:
      datStart     Startposition des String
      insDat       String to insert
      delPos       Position where to delete and where to insert
      delSiz       how much bytes to delete at Pos delPos
    Output:
      datSiz       new size of string (datStart)
    
    
     strcpy(cbuf, "1234567890");   l1 = strlen(cbuf);
     UTX_chg_str1 (cbuf, &l1, "AAA", 3, &cbuf[4], 1); // 5 -> AAA

int UTX_chg_nr ( char *  txtOut,
int  iNr 
)

    change int-number in line beginning at txtOut into iNr
    Returncode = Laengendifferenz vorher - nachher

int UTX_endDelChar ( char *  txtbuf,
char  chr 
)

UTX_endDelChar if last char of string == chr: remove it.

int UTX_endAddChar ( char *  txtbuf,
char  chr 
)

UTX_endAddChar if last char of string != chr: add it.

char* UTX_pos_1n ( char  string[]  ) 

    UTX_pos_1n             skip blanks (returns Position of first non-blank)
    ersetzt durch  UTX_pos_skipLeadBlk

char UTX_pos_del ( char **  txtIn,
char **  w_next 
)

    UTX_pos_del            find next delimiter
    
    Outputs:
      Returns the delimiter found as single character
      txtIn:  leading blanks skipped
      w_next: the pos of the deli
    
    Delimiterzeichen sind:
     " ""'()*+,-/;<=>"
    
    Beispiel:
      char *cp1, *cp2, deli;
      deli=UTX_pos_del(&cp1, &cp2);
    
    Nachfolgend kann man das Wort abtrennen durch
      *cp2 = '\0';

long UTX_pos_del_prev ( char *  cBuf,
long  cPos 
)

    find previous delimiter (blank vor cPos)
    Return pos of first char of word before cPos
    Klammerausdruecke skippen !

long UTX_pos_del_next ( char *  cBuf,
long  cPos 
)

    find next delimiter (blank nach cPos)
    Return pos of first char of word after cPos
    Klammerausdruecke skippen !

int UTX_add_i_u ( char  strBuf[],
int  zahl 
)

UTX_add_i_u add integer to string

int UTX_add_db ( char  outBuf[],
double *  db1 
)

add double unformatted; Trennzeichen ist blank.

int UTX_add_pt ( char  outBuf[],
void *  pt1 
)

add Pointcoords unformatted; Trennzeichen ist blank.

int UTX_del_chr ( char *  cbuf,
char  cx 
)

UTX_del_chr delete all characters <cx> out of string cbuf

void UTX_del_follBl ( char *  cbuf  ) 

UTX_del_follBl delete following blanks

int UTX_del_foll0 ( char  strBuf[]  ) 

      Delete following 0's and following ".".

int UTX_del_FilTx ( char *  dtxt,
char *  filNam 
)

    delete all lines containing <dtxt>
    uses file <filNam>.tmp

int UTX_add_fl_u ( char  strBuf[],
double  zahl 
)

    UTX_add_fl_u            add double unformatted (del foll. 0's and ".")
    
      Delete following 0's and following ".".

int UTX_add_fl_u2 ( char  outBuf[],
double  z1,
double  z2 
)

    UTX_add_fl_u2          add double,double unformatted (del foll. 0's and ".")
    2 Doubles (Komma dazwischen)

int UTX_add_fl_u3 ( char  outBuf[],
double  z1,
double  z2,
double  z3 
)

    UTX_add_fl_u3          add 3 doubles unformatted (del foll. 0's and ".")
    3 Doubles (Komma dazwischen)

int UTX_add_fl_f ( char  strBuf[],
double  zahl,
int  nkAnz 
)

    UTX_add_fl_f            add double with x digits after dec.point
      to string. The nr of digits before dec.point is floating.
   
    IGES verwendet %.10f !
    
    see UTX_del_foll0

int UTX_add_fl_10 ( char  strBuf[],
double  d1 
)

UTX_add_fl_10 add double with 10 signif digits

int UTX_add_fl_15 ( char  strBuf[],
double  d1 
)

UTX_add_fl_15 add double with 15 signif digits

int UTX_add_slash ( char *  cbuf  ) 

UTX_add_slash add closing "/" to string (for dir's)

void UTX_ins_s2 ( char *  s1,
char *  s2,
int  maxlen 
)

    UTX_ins_s2             insert string links (s1 = s2//s1)
    maxlen ist die max. Lnge des S1!
    s" radf max 256 chars lang sein.

int UTX_fsavLine ( char *  cbuf,
char *  filNam,
int  lNr 
)

    UTX_fsavLine           Zeile Nr. <lNr> into Datei <filNam> schreiben
    Erste Zeile hat lNr=1.
    wenn Datei filNam weniger als lNr Zeilen hat, werden Leerzeilen erzeugt !!
    lNr = -1: hintanfuegen.
    rc -1   File does not exist
    rc -2   Line does not exist
    rc  0   OK

int UTX_fRevL ( char *  fno,
char *  fni 
)

    UTX_fRevL        File revert lines; eine Datei zeilenweise umdrehen;
    letze Zeile wird zur ersten, vorletze Zeile wird zur zweiten usw.

int UTX_fgetLine ( char *  cbuf,
char *  filNam,
int  lNr 
)

    UTX_fgetLine           Zeile Nr. <lNr> aus Datei <filNam> lesen
    
    erste Zeile ist 1.
    cbuf muss mind 80 lang sein !
    rc -1   File does not exist
    rc -2   Line does not exist
    rc  0   OK

char* UTX_memFind ( char *  buf,
char *  str 
)

str in buf suchen

char* UTX_memFind1 ( char *  buf,
long  bufSiz,
char *  str,
long  strSiz 
)

    UTX_memFind1           Daten mit bestimmter Laenge suchen
    
    Datablock str (siz = strSiz) in buf bis max. buf[strSiz] suchen.

char* UTX_memstr ( char *  von,
char *  bis,
char *  sstr 
)

    den String sstr im Bereich von - bis suchen.
    Returns:
      position of first char if found
      else NULL

char* UTX_fgets ( char *  line,
int  len,
FILE *  fp 
)

    UTX_fgets              Zeile aus Datei lesen und CR',s LF's am Ende deleten.
    
      Lesen einer Datenzeile aus einer Datei.
      Im gelesenen String werden von hinten nach vorne ueberfluessige
      Blanks ' ', Carriage Returns '\r' und Linefeeds '\n' durch
      Nullzeichen '\0' ersetzt (bis zum ersten Vorkommen eines
      anderen Zeichens).

void UTX_CleanSC ( char *  string  ) 

change all Sonderzeichen into '?'

void UTX_CleanCR ( char *  string  ) 

    UTX_CleanCR                  Delete Blanks, CR's u. LF's am Ende.
      Ersetzung von Blanks, Carriage Returns und Linefeeds durch
      Nullzeichen von hinten nach vorne bis zum ersten von diesen
      verschiedenen Zeichen.

int UTX_CleanLF ( char *  sBuf  ) 

    UTX_CleanLF           change lineEnd (Cr|CrLf ..) to single LF.
    Input:
      sBuf     line, eg from file (ex MS ..)
    Output:
      sBuf      end of line is '\n'
      RetCod    nr of characters of sBuf

int UTX_CleanCommC ( char *  cBuf  ) 

Clean C-Comments (remove // comment and following blanks)

int UTX_Clean_db ( char *  cbuf  ) 

    clean doubles (change ',' into '.') in gesamter cbuf
    MS-Win schreibt "1,0"
    See also UTX_chg_chr1.

char* UTX_pos_skipBrack ( char *  cbuf  ) 

    UTX_pos_skipBrack      find corresponding ')' (returns Position of ')')
    find end of bracket ..
    Input:
      cbuf: '(' must be the first character !
    Output:
      retCod  the position of the ')' corresponding to cbuf[0]

char* UTX_pos_skipBrack1 ( char *  cbuf  ) 

    UTX_pos_skipBrack1     find corresponding ')' (returns Position of ')')
    find end of bracket ..
    Input:
     cbuf:    !!! first '(' is not include in *cbuf !!!
              Example: "(3*3) + (4*4))"
    Output:
      retCod  the position of the ')' corresponding to the missing ')'
              Example: ")"

int UTX_ck_caseChr ( char *  s1,
char *  s2 
)

    compare 2 characters - ignore case
    s1 is changed to uppercase; s2 must be uppercase !
    Cannot handle german specialChars (ae, ue, ..).
    Retcod:
        0    both chars are equal
        1    chars are NOT equal
    
    see also strcasecmp strncasecmp (nur Linux !)

int UTX_ck_casenChr ( char *  s1,
char *  s2,
int  cNr 
)

    compare n chars of 2 strings - ignore case
    s1 is changed to uppercase; s2 must be uppercase !
    Cannot handle german specialChars (ae, ue, ..).
    Retcod:
        0    both Strings are equal
        1    Strings are NOT equal
    
    see also strcasecmp strncasecmp (nur Linux !)

int UTX_ck_caseStr ( char *  s1,
char *  s2 
)

    compare 2 strings - ignore case
    s1 is changed to uppercase; s2 must be uppercase !
    Cannot handle german specialChars (ae, ue, ..).
    Retcod:
        0    both Strings are equal
        1    Strings are NOT equal
    
    see also strcasecmp strncasecmp (nur Linux !)

int UTX_ckc_Del1 ( char  c1  ) 

    UTX_ckc_Del1           check if char is a delimiter
    RC 0 = yes, char is a delimiter
    RC 1 = no;

char* UTX_find_Del1 ( char *  p1  ) 

find next delimiter ' ' '=' ',' '
' '' '{' ...

char* UTX_pos_skipDeli1 ( char *  p1  ) 

UTX_pos_skipDeli1 skip delimiter ' ' ',' '
' '' ''

char* UTX_2db_tx ( double *  d1,
double *  d2,
char *  cbuf 
)

see also UT3D_pt_txt

double UTX_db_tx ( char **  po,
char *  pi 
)

    read float from ascii-string
    po == pi erlaubt ..
    ACHTUNG: pi muss veraenderbar sein !! (D wird in E umgewandelt ...)

int UTX_pos_skip_num ( char **  ps  ) 

skip number

int UTX_pos_skip_int ( char **  ps  ) 

skip int-number in string

char* UTX_pos_skipWord ( char *  cbuf  ) 

    UTX_pos_skipWord       skip Word (ret. Pos. of first char after word)
    find next '\0' oder ','; skip "(...)".
    DOES NOT SKIP STRINGS ("...").
    following blanks werden geskippt

char* UTX_pos_skipWords ( int  wNr,
char *  p1 
)

UTX_pos_skipWords skip wNr Words (ret. Pos. of first char after word)

int UTX_wordnr ( char *  cbuf  ) 

    UTX_wordnr             returns nr of words
    returns Anzahl von Worten in cbuf
    als delimiter gelten nur blank und oder ","
    Ausdruck wird korrekt behandelt ("D(0 0 1)" ist nur 1 Wort !!)

int UTX_cnr_chr ( char *  txt,
char  c1 
)

returns nr of char c1 in string txt

int UTX_get_word ( char **  txtIn,
char **  w_next,
char *  txtOut,
double *  val,
char *  deli 
)

    UTX_get_word           copy word & return typ of word:
    
    Input:  
      txtIn
    
    Output:
      txtIn  leading blanks skipped
      w_next Startpos des nach dem 1. Wort folgenden Textes;
             excluding Delimiter, but not operators, Blanks skipped.
      txtOut Kopie des 1. Wortes im Buffer txtIn; max. 32 char;
             (nur bei Typ 1 und 2);  without leading & following blanks
      val    value (des 1. Wortes, atof)
      deli   der Delimiter (ein single char; der erste char NACH dem Wort)
             
    Returncodes:
    TXT_Typ_EOF    0 = end of txtIn (empty);
    TXT_Typ_spec   1 = spec.char (out in txtOut)  + - / * ^ . ; ( ) $ ,
    TXT_Typ_text   2 = alfatext, (out in txtOut) delimiters are blank , + - / *
                       . _ does not terminate text.
    TXT_Typ_num    3 = num. value (double, out in val);
    TXT_Typ_string 4 = string (durch " beidseitig begrenzt) String is copied
                       to txtOut (max 32 chars) without ", terminated with \0
    
    
    Beispiele:
               RC   val  deli  w_next  txtOut
    "+3"       num    3  ' '   ""      -
    "-3+2"     num   -3  '+'   "2"     -
    "-3 -2"    num   -3  ' '   "-2"    -             <<<<<<<<<
    "- 3"      spec      '-'   "3"     "-"
    "*3"       spec      '*'   "3"     "*"
    "(3+1)*2"  spec      ' '   "3"     "("
    "v1=5"     text   -  '='   "5"     "v1"
    "v1 = 5"   text   -  '='   "5"     "v1"
    "v1-5"     text   -  '-'   "5"     "v1"          <<<<<<<<<
    "v1 -5"    text   -  ' '   "-5"    "v1"          <<<<<<<<<
    "v1 p2"    text   -  ' '   "p"     "v1"
    ""ab ""    string    ' '           "ab "
    "abc "a""  text      '"'   "a""    "abc"

int UTX_cut1 ( char *  cbuf,
long *  bufSiz,
long  cPos,
long  txLen 
)

    UTX_cut1               cut Textstring out of Textbuffer
    Aus cbuf von Pos. cPos weg txLen characters rausloeschen.

int UTX_insert1 ( char *  cbuf,
long *  bufSiz,
char *  auxBuf,
long  cPos 
)

    UTX_insert1            insert Textstring into Textbuffer
    den textstring auxBuf in den Buffer cbuf an Position cPos einfuegen.
    Die momentane Size von cbuf ist bufSiz.
    
    long i1;
    i1 = strlen(cbuf);
    UTX_insert1(cBuf, &i1, "FSUB ", 0);

int UTX_dump_cnl ( char *  cPos,
int  maxLen 
)

    print next <maxLen> characters, but stop at \n.
    "dynamic" format "%<len>.<len>s"
       printf("|");UTX_dump_cnl(p1,40);printf("|\n");
       printf(" Line %d |",i1);UTX_dump_cnl(cpos,50);printf("|\n");

int UTX_dump_c__ ( char *  cPos,
int  cLen 
)

    print next <cLen> characters;  ignores \n !!
    "dynamic" format "%<cLen>.<cLen>s"
       printf(" Line %d |",i1);
       UTX_dump_c__ (cpos, cLen);
       printf("|\n");

int UTX_dump_s__ ( char *  cPos,
int  cNr 
)

    UTX_dump_s__    dump String (replace \n\r\t\0)
    Es wird auch '\0' und die folgenden chars ausgegeben !!

int UTX_dump__ ( char *  cPos,
int  maxLen 
)

    UTX_dump__   dump String (replace \n\r\t)
    Es wird bei '\0' gestoppt.

int UTX_cp_print ( char *  txo,
char *  txi,
int  maxLen 
)

    add printable characters from txi --> txo; but max. maxLen Chars.
    size of txo must be (maxLen + 1) !
    Change nonprintable characters to '?'

int UTX_cp_right ( char *  sOut,
char *  sIn,
int  cNr 
)

    UTX_cp_right           copy n chars from right side of string
    RetCod 0=Ok
    
    RetCode: 0=equal; else=notEqual.

int UTX_cpLn_2cp ( char *  cbuf,
char *  pos1,
char *  pos2,
int  bufSiz 
)

    UTX_cpLn_2cp      copy line between 2 pointers; del ending blanks, lf.
    Input:
      pos1        start of line to be copied
      pos2        start of next line

int UTX_cp_Line ( char *  cTo,
char **  cNxt,
char *  cFrom,
int  maxLen 
)

    UTX_cp_Line            copy a Line (terminated by '\n')
    Input:
      cFrom        string in, 
      maxLen       size of cTo, including "\0" (minimum 2)
    Output:
      cTo          string out; \n is not included;
                     terminated with "\0"; length=maxlen or less 
      cNxt         position of 1 char of next Line
      retCod       length of cTo

int UTX_setup_get ( char *  cval,
char *  ctyp,
char *  ctyps,
char *  fnam 
)

    UTX_setup_get          get parameters (typ, value) from setup-file
    einlesen der Defaultwerte; zB Reset Modelsize / Reset Textsize ...
    ACHTUNG: Lesen bis EOF (irc < 0 oder *ctyp == NULL)
    Datei enthaelt TYP wert
    es werden alle Werte geliefert, deren Typ das gesuchte ctyps enthaelt.

int UTX_htm_fop ( FILE **  fp,
char *  fnam 
)

UTX_htm_fop open html-textfile

int UTX_htm_fcl ( FILE **  fp  ) 

UTX_htm_fcl close html-textfile


Variable Documentation

const char TX_NUL = '\0'

double UTX_TOL_min1 = 0.000001 [static]

char TX_buf1[128] [static]

char TX_buf2[128] [static]


Generated on Sat May 30 09:31:56 2009 for gCAD3D by  doxygen 1.5.6