Eine Textdatei im Memory bearbeiten. Es gibt 2 Textbuffer; den Hauptbuffer Buf0 und Buf1. Der Memorybuffer dazu hier lokal. Buf0 = UTF_FilBuf0 (UTF_alloc1_) Buf1 = UTF_FilBuf1 Linendcharacters sind bei Unix/Windows unterschiedlich (Unix: LF; Win: CRLF !) ===================================================== Liste_Funktionen_Beginn: UTF_clear_ Memory loeschen UTF_offset_ eine Charpos (ev ex UTF_GetLinNr) in Offset umrechnen UTF_load_ text direct ins Memory 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 UTF_comment_line modify 1. (last) char of line UTF_wrf_line eine Zeile in ein File rausschreiben 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_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_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_dump__ display memInhalt UTF_dump1__ display memInhalt of Buffer1 Liste_Funktionen_Ende: =====================================================
#include "../xa/MS_Def0.h"
#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"
Defines | |
#define | UTF_BUF0_INC 2000000 |
#define | UTF_BUF1_INC 1000000 |
Functions | |
char * | UTF_get1_LnPos (int 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 (int lNr, char *lPos, int mode, char *cs) |
int | UTF_GetLinLen (char **lEnd, char *lStart) |
int | UTF_chg_lnPos (char *cPos, char *newRec) |
int | UTF_chg_line (int 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 *fn, int iniFunc(FILE *)) |
int | UTF_wri_f__ (FILE *flun) |
int | UTF_txt_chg (char *cpos, char *txt, int 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, int lNr) |
int | UTF_GetLineTx (char *lbuf, int *lNr, char *sText) |
char * | UTF_GetLinNr (char *lbuf, int *llen, int lNr) |
int | UTF_add_nl () |
int | UTF_add_line (char *txt) |
void | UTF_load_ (char *txbuf, long *txlen) |
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_line (char *txt) |
int | UTF_insertTxt (char *insPos, int cNr, char *auxBuf) |
int | UTF_insert1 (long cpos) |
int | UTF_del_text (char *cFrom, char *cTo) |
int | UTF_del_line1 (int lNr) |
char * | UTF_GetnextLnPos (char *cpos) |
char * | UTF_GetPrevLnPos (int *lNr, char *cpos) |
char * | UTF_find_tx1 (int *lNr, char *tx1) |
int | UTF_del_start (char *text) |
int | UTF_del_rest (char *text) |
Variables | |
char * | UTF_FilBuf0 = NULL |
long | UTF_FilBuf0Siz = 0 |
long | UTF_FilBuf0Len = 0 |
long | UTF_FilBuf0Stat = 0 |
char * | UTF_FilBuf1 = NULL |
long | UTF_FilBuf1Siz = 0 |
long | UTF_FilBuf1Len = 0 |
#define UTF_BUF0_INC 2000000 |
#define UTF_BUF1_INC 1000000 |
char* UTF_get1_LnPos | ( | int | 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 .. see UTF_GetnextLnPos
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 | ( | int | lNr, | |
char * | lPos, | |||
int | mode, | |||
char * | cs | |||
) |
UTF_comment_line modify 1. (last) char of line mode: 0=Restore; 1=Delete cs commentString, zB "_" - used only with mode 1
int UTF_GetLinLen | ( | char ** | lEnd, | |
char * | lStart | |||
) |
int UTF_chg_lnPos | ( | char * | cPos, | |
char * | newRec | |||
) |
int UTF_chg_line | ( | int | lNr, | |
char * | newRec | |||
) |
int UTF_chg1_Ln_cpCs | ( | char * | lPos, | |
char * | newLn | |||
) |
UTF_chg1_Ln_cpCs change Line in Buf1 Input: lPos position of line to be changed newLn 0-terminated see UTF_chg_line see UTF_chg_lnPos UTF_insert1 UTF_del_line1
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 * | fn, | |
int | iniFuncFILE * | |||
) |
Memory -> Datei rausschreiben mode 0=keine dyn-daten (HIDE, ..) rausschreiben; 1=write Dyndat. rc = 0 = Error; 1 = OK.
int UTF_wri_f__ | ( | FILE * | flun | ) |
rc = 0 = Error; 1 = OK.
int UTF_txt_chg | ( | char * | cpos, | |
char * | txt, | |||
int | 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, | |
int | lNr | |||
) |
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, | |
int * | llen, | |||
int | lNr | |||
) |
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. llen length of lbuf Retcod NULL: Line does not exist; llen = -1. else Startpos of line in UTF_FilBuf0. 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 eine Zeile hinten anfuegen
void UTF_load_ | ( | char * | txbuf, | |
long * | txlen | |||
) |
int UTF_clear_ | ( | ) |
UTF_clear den Hauptspeicher loeschen
int UTF_clear1 | ( | ) |
UTF_clear1 den Zwischenspeicher Buf1 loeschen
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 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 | ) |
int UTF_add1_line | ( | char * | txt | ) |
int UTF_insertTxt | ( | char * | insPos, | |
int | cNr, | |||
char * | auxBuf | |||
) |
int UTF_insert1 | ( | long | cpos | ) |
UTF_insert1 Zwischenspeicher im Memory an Pos cpos einfuegen insert UTF_FilBuf1 into UTF_FilBuf0 nach char # cpos (der erste = 1) cpos < 0: hinten anfuegen
int UTF_del_text | ( | char * | cFrom, | |
char * | cTo | |||
) |
UTF_del_text delete from cPos to cPos
int UTF_del_line1 | ( | int | 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 | ( | int * | 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 | ( | int * | 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
int UTF_del_rest | ( | char * | text | ) |
UTF_del_rest ab "text" Memory loeschen
char* UTF_FilBuf0 = NULL |
long UTF_FilBuf0Siz = 0 |
long UTF_FilBuf0Len = 0 |
long UTF_FilBuf0Stat = 0 |
char* UTF_FilBuf1 = NULL |
long UTF_FilBuf1Siz = 0 |
long UTF_FilBuf1Len = 0 |