gCAD3D 2.40
ut_txfil.c File Reference

textfile in memory More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../ut/ut_txt.h"
#include "../ut/ut_TX.h"
#include "../ut/ut_txfil.h"
#include "../xa/xa_mem.h"

Macros

#define UTF_BUF0_INC   2000000
 
#define UTF_BUF1_INC   1000000
 

Functions

char * UTF_get1_LnPos (long lNr)
 
char * UTF_get1_nxtLnPos (char *actPos)
 
int UTF_wrf_line (long lNr, char *fnam)
 
int UTF_get_Buf1 (char *cbuf, int maxSiz)
 
int UTF_file_Buf1__ (char *fnam)
 
int UTF_file_Buf1_w (FILE *fp1)
 
int UTF_comment_line (char *lPos, int mode, char *cs)
 
long UTF_get1_LnLen (char **lEnd, char *lStart)
 
long UTF_GetLinLen (char **lEnd, char *lStart)
 
int UTF_chg_lnPos (char *cPos, char *newRec)
 
int UTF_chg_line (long lNr, char *newRec)
 
int UTF_chg1_Ln_cpCs (char *lPos, char *newLn)
 
int UTF_alloc__ (long newSiz)
 
int UTF_alloc1_ (long newSiz)
 
int UTF_dump__ ()
 
int UTF_dump1__ ()
 
int UTF_wri_file (char *fnam, int iniFunc(FILE *))
 
int UTF_wri_f__ (FILE *flun)
 
int UTF_txt_chg (char *cpos, char *txt, long txlen)
 
int UTF_GetLnrPos (long ipos)
 
int UTF_GetPos2 (char **p1, char **p2)
 
int UTF_Buf1_GetPos2 (char **p1, char **p2)
 
long UTF_GetLen0 ()
 
char * UTF_GetPosLnr (long *llen, long lNr)
 
int UTF_GetLineTx (char *lbuf, int *lNr, char *sText)
 
char * UTF_GetLinNr (char *lbuf, long *llen, long lNr)
 
int UTF_add_nl ()
 
int UTF_add_line (char *txt)
 
int UTF_clear_ ()
 
int UTF_clear1 ()
 
int UTF_add_fil__ (char *cBuf, long *sizAct, long sizTot, char *fn)
 
int UTF_add_file (char *fn)
 
char * UTF_add1_file (char *fn)
 
long UTF_offset_ (char *cpos)
 
int UTF_add1_strLF (char *cBuf)
 
int UTF_add1_last_add (char *txt)
 
int UTF_add1_line (char *txt)
 
int UTF_insertTxt (char *insPos, long cNr, char *auxBuf)
 
int UTF_insert1 (long cpos)
 
int UTF_del_text (char *cFrom, char *cTo)
 
int UTF_del_line1 (long lNr)
 
char * UTF_GetnextLnPos (char *cpos)
 
char * UTF_GetPrevLnPos (long *lNr, char *cpos)
 
char * UTF_find_tx1 (long *lNr, char *tx1)
 
int UTF_del_start (char *text)
 

Variables

char * UTF_FilBuf0 = NULL
 
long UTF_FilBuf0Siz = 0
 
long UTF_FilBuf0Len = 0
 
char * UTF_FilBuf1 = NULL
 
long UTF_FilBuf1Siz = 0
 
long UTF_FilBuf1Len = 0
 

Detailed Description

textfile in memory

=====================================================
List_functions_start:
UTF_clear_ Memory loeschen
UTF_offset_ eine Charpos (ev ex UTF_GetLinNr) in Offset umrechnen
UTF_add_line eine Zeile hinten anfuegen
UTF_add_nl ein '\n' hintanfuegen, wenn nicht vorh.
UTF_add_file Buffer1 in den Hauptbuffer umkopieren.
UTF_add_fil__ Datei hintanhaengen
UTF_wri_file Memory -> Datei rausschreiben
UTF_wri_f__ Memory -> Datei rausschreiben
UTF_file_Buf1__ Buffer1 in eine Datei rausschreiben
UTF_txt_chg 1-n chars aendern
UTF_chg_line modify line in mem
UTF_chg_lnPos change Line im mem starting at cPos UNUSED
UTF_comment_chg change (insert/remove char cs (eg '_')) first char UNUSED
UTF_comment_line modify 1. (last) char of line
UTF_wrf_line eine Zeile in ein File rausschreiben
UTF_EMPTY test if model is empty INLINE
UTF_GetPos2 returns Startpos & Endpos of Buf0.
UTF_GetLen0 liefert die Laenge des UTF_FilBuf0 UTF_FilBuf0Len.
UTF_GetLinNr Liefert Zeile mit Zeilennummer lNr u. ihre Laenge
UTF_GetLineTx Zeile, die mit sText beginnnt, zurueckliefern
UTF_GetLinLen length of line excluding LF
UTF_GetPosLnr Startposition und Zeilenlaenge von zeile lNr liefern.
UTF_GetLnrPos ZeilenNr einer Position liefern
UTF_GetnextLnPos Position der nachfolgenden Zeile liefern
UTF_GetPrevLnPos Position der vorherigen zeile liefern
UTF_find_tx1 Zeilennummer der Zeile, die tx1 als erste enthaelt, suchen
UTF_add2_line eine Zeile zwischenspeichern; wenn laenger 80 char teilen.
UTF_get1_LnPos find startPos of line from LineNr
UTF_get1_LnLen length of line starting at lStart in UTF_FilBuf1
UTF_get1_nxtLnPos naechste Zeile aus UTF_FilBuf1 lesen
UTF_chg1_Ln_cpCs change Line in Buf1
UTF_insert1 Zwischenspeicher im Memory an der aktPos einfuegen
UTF_insertTxt insert text
UTF_Buf1_GetPos2 returns Startpos & Endpos of Buf1.
UTF_clear1 den Zwischenspeicher UTF_FilBuf1 loeschen
UTF_add1_file Eine Datei into Buffer UTF_FilBuf1.
UTF_add1_line eine Zeile in UTF_FilBuf1 hintanfuegen
UTF_add1_last_add add txt to last line in UTF_FilBuf1 (add objName)
UTF_add1_strLF add a line, which is terminated with LF, to Buffer1
UTF_file_Buf1__ Buffer1 in eine Datei rausschreiben
UTF_get_Buf1 copy Buffer1 -> memspc
UTF_del_line1 Eine Zeile im Memory loeschen
UTF_del_start bis "text" Memory loeschen
UTF_del_rest ab "text" Memory loeschen
UTF_del_text delete from cPos to cPos
UTF_dump1__ display memInhalt of Buffer1
List_functions_end:
=====================================================

Macro Definition Documentation

#define UTF_BUF0_INC   2000000
#define UTF_BUF1_INC   1000000

Function Documentation

char* UTF_get1_LnPos ( long  lNr)
* UTF_get1_LnPos find startPos of line from LineNr
* lNr of first line = 1
* RetCod: NULL for EOF or (lNr<1); else first char of line.
*
char* UTF_get1_nxtLnPos ( char *  actPos)
* UTF_get1_nxtLnPos naechste Zeile aus UTF_FilBuf1 lesen
* Input:
* actPos active Line;
* if(actPos == NULL) get first Line;erste zeile liefern.
* Output:
* retCod position of next line foooollowing actPos
* if retCod == NULL: no more line ..
*
*
int UTF_wrf_line ( long  lNr,
char *  fnam 
)

UTF_wrf_line eine Zeile in ein File rausschreiben

int UTF_get_Buf1 ( char *  cbuf,
int  maxSiz 
)

UTF_get_Buf1 copy Buffer1 -> memspc

int UTF_file_Buf1__ ( char *  fnam)

UTF_file_Buf1__ Buffer1 in eine Datei rausschreiben

int UTF_file_Buf1_w ( FILE *  fp1)

UTF_file_Buf1__ Buffer1 in eine Datei rausschreiben

int UTF_comment_line ( char *  lPos,
int  mode,
char *  cs 
)
* UTF_comment_line modify 1. (last) char of line
* mode: 0=Restore restore line, remove first char of line
* 1=Delete comment line, set first char of line = cs
* cs commentString, zB "_" - used only with mode 1
*
long UTF_get1_LnLen ( char **  lEnd,
char *  lStart 
)
* UTF_get1_LnLen length of line starting at lStart in UTF_FilBuf1
* Output:
* lEnd position of next '\n' or '\0'
* Retcod (nr of characters ) - 1
*
long UTF_GetLinLen ( char **  lEnd,
char *  lStart 
)
* UTF_GetLinLen length of line starting at lStart in UTF_FilBuf0
* Output:
* lEnd position of next '\n' or '\0'
* Retcod nr of characters
*
int UTF_chg_lnPos ( char *  cPos,
char *  newRec 
)
* change Line im mem starting at cPos
* see also UTF_chg_line
*
int UTF_chg_line ( long  lNr,
char *  newRec 
)
* change Line im mem (lNr)
* see also UTF_chg_lnPos
*
int UTF_chg1_Ln_cpCs ( char *  lPos,
char *  newLn 
)
* UTF_chg1_Ln_cpCs change Line starting at lPos in UTF_FilBuf1
* Input:
* lPos position of line to be changed
* newLn 0-terminated
*
*
int UTF_alloc__ ( long  newSiz)
int UTF_alloc1_ ( long  newSiz)
int UTF_dump__ ( )

UTF_dump__ display memInhalt

int UTF_dump1__ ( )

UTF_dump1__ display memInhalt of Buffer1

int UTF_wri_file ( char *  fnam,
int   iniFuncFILE * 
)
* write memory -> file fnam; call iniFunc first.
* iniFunc eg DL_wri_dynDat0
* rc = 0 = Error;
* 1 = OK.
*
int UTF_wri_f__ ( FILE *  flun)
* write memory -> open file; skip deleted lines ('_')
* rc = 0 = Error;
* 1 = OK.
*
int UTF_txt_chg ( char *  cpos,
char *  txt,
long  txlen 
)

UTF_txt_chg 1-n chars aendern

int UTF_GetLnrPos ( long  ipos)
* die zeilennummer zu einer offsetpos im MemFile liefern
* = die Anzahl von \n von 0 bis ipos zaehlen.
*
int UTF_GetPos2 ( char **  p1,
char **  p2 
)

UTF_GetPos2 returns Startpos & Endpos of Buf0.

int UTF_Buf1_GetPos2 ( char **  p1,
char **  p2 
)

UTF_Buf1_GetPos2 returns Startpos & Endpos of Buf1.

long UTF_GetLen0 ( )
* UTF_GetLen0 liefert die Laenge des UTF_FilBuf0 UTF_FilBuf0Len.
* = Dateisize abfragen (zB zum Check EOF ..)
*
char* UTF_GetPosLnr ( long *  llen,
long  lNr 
)
* von zeile # lNr die Startposition und die Zeilenlaenge der zeile liefern.
* ln_pos ist der erste char der line, llen ist die laenge ohne terminator;
* der Start der naechsten Zeile ist also ln_pos + llen + term_anz.
* Die erste Zeile ist lNr = 1.
* Output:
* llen gives the position of the LF
* RetCode NULL: EOF found.
*
* Usage:
* p1 = UTF_GetPosLnr (&lLen, lNr);
* UTX_dump_cnl (p1, 60); printf("\n"); // print max 60 chars, but stop at \n
*
int UTF_GetLineTx ( char *  lbuf,
int *  lNr,
char *  sText 
)
* Zeile, die mit sText beginnnt, zurueckliefern
* RetCodes:
* 0 Ok, gefunden
* -1 nix gefunden
*
char* UTF_GetLinNr ( char *  lbuf,
long *  llen,
long  lNr 
)
* get sourceline from sourcelineNr
* Liefert Zeile mit Zeilennummer lNr in lbuf (aus dem mem !)
* makes a copy of line <lNr> from UTF_FilBuf0 -> lbuf
*
* Output:
* lbuf copy of line <lNr> from UTF_FilBuf0, '\0' terminated. Or NULL.
* llen length of lbuf
* Retcod NULL: Line does not exist; llen = -1.
* else Startpos of line in UTF_FilBuf0.
*
* see also:
* UTF_GetPosLnr get a pointer to a sourcecodeline
*
* ATTENTION: lbuf must have size=mem_cbuf1_SIZ !
*
int UTF_add_nl ( )

UTF_add_nl ein '
' hintanfuegen, wenn nicht vorh.

int UTF_add_line ( char *  txt)
* UTF_add_line add line to membuf UTF_FilBuf0
* txt is \0-terminated, '\n' will be added.
*
int UTF_clear_ ( )

UTF_clear den Hauptspeicher loeschen

int UTF_clear1 ( )
* UTF_clear1 den Zwischenspeicher Buf1 loeschen
* Example see UTF_insert1
*
int UTF_add_fil__ ( char *  cBuf,
long *  sizAct,
long  sizTot,
char *  fn 
)
* Datei fn an membuf cBuf hintanhaengen; size of cBuf is sizTot.
* cBuf muss gross genug sein !!
* RetCod:
* -1 OpenError
* 0 OK
*
int UTF_add_file ( char *  fn)
* Datei in den Hauptbuffer laden - hintanhaengen
* rc = -1 = Error;
* 1 = OK.
*
char* UTF_add1_file ( char *  fn)
* Eine Datei into Buf1 laden
* rc = -1 = Error;
* 1 = OK.
*
long UTF_offset_ ( char *  cpos)

eine Charpos (ev ex UTF_GetLinNr) in Offset umrechnen

int UTF_add1_strLF ( char *  cBuf)
* UTF_add1_strLF add a line, which is terminated with LF, to Buffer1.
*
int UTF_add1_last_add ( char *  txt)
int UTF_add1_line ( char *  txt)
* UTF_add1_line add string (0-termin.) into UTF_FilBuf1
* Schreibt --> UTF_FilBuf1 (hintanfuegen)
* retCod 0 OK
* -1 out of mem
* Example see UTF_insert1
*
int UTF_insertTxt ( char *  insPos,
long  cNr,
char *  auxBuf 
)
* UTF_insertTxt insert text
* insert cNr chars of auxBuf into cBuf at pos insPos
*
int UTF_insert1 ( long  cpos)
* UTF_insert1 insert auxBuffer into mainBuffer at pos cpos.
* auxBuffer: UTF_FilBuf1; mainBuffer: UTF_FilBuf0.
* cpos < 0: join buffers (mainBuffer += auxBuffer).
* update display after buffer-update: see APED_update__ ();
* Example:
* ObjGX o1; char s1[1000]; int siz_s1=1000; Point p1={1.,0.,0.};
* UTF_clear1 (); // init auxBuf
* AP_obj_2_txt (NULL, 0L, NULL, 0L); // init AP_obj_2_txt
* OGX_SET_OBJ (&o1, Typ_PT, Typ_PT, 1, &p1); // create point-object
* AP_obj_2_txt (s1, siz_s1, &o1, -1L); // create sourcecode for obj -> auxBuf
* UTF_add1_line ("# end of xx"); // add text to auxBuf
* UTF_insert1 (-1L); // store auxBuf (add to active code)
* APED_update__ (-1L); // work new codes
*
int UTF_del_text ( char *  cFrom,
char *  cTo 
)

UTF_del_text delete from cPos to cPos

int UTF_del_line1 ( long  lNr)

Eine Zeile im Memory loeschen

char* UTF_GetnextLnPos ( char *  cpos)
* UTF_GetnextLnPos Position der nachfolgenden zeile liefern
* cpos = NULL: Bufferstartpos UTF_FilBuf0 liefern.
*
char* UTF_GetPrevLnPos ( long *  lNr,
char *  cpos 
)
* UTF_GetPrevLnPos Position der vorherigen zeile liefern
* Input:
* lNr NULL: do not provide lineNr of previous Line.
* cpos NULL: BufferEndPos UTF_FilBuf0+len liefern.
* Output:
* lNr = -1 Start of Buffer reached
*
char* UTF_find_tx1 ( long *  lNr,
char *  tx1 
)
* UTF_find_tx1 Zeilenummer der Zeile, die tx1 als erste enthaelt, suchen
* Sucht nur im Mem !
* RetCod:
* position of tx1
* NULL - tx1 not found
*
int UTF_del_start ( char *  text)

UTF_del_start bis "text" Memory loeschen

Variable Documentation

char* UTF_FilBuf0 = NULL
long UTF_FilBuf0Siz = 0
long UTF_FilBuf0Len = 0
char* UTF_FilBuf1 = NULL
long UTF_FilBuf1Siz = 0
long UTF_FilBuf1Len = 0