/* RCS $Id: state.c,v 1.3 2007-09-20 14:33:53 vg Exp $ -- -- SYNOPSIS -- .KEEP_STATE state file management -- -- DESCRIPTION -- Three routines to interface to the .KEEP_STATE state file. -- -- Read_state() - reads the state file if any. -- Write_state() - writes the state file. -- -- Check_state(cp,how) - checks an entry returns 0 or 1 -- and updates the entry. -- -- AUTHOR -- Dennis Vadura, dvadura@dmake.wticorp.com -- -- WWW -- http://dmake.wticorp.com/ -- -- COPYRIGHT -- Copyright (c) 1996,1997 by WTI Corp. All rights reserved. -- -- This program is NOT free software; you can redistribute it and/or -- modify it under the terms of the Software License Agreement Provided -- in the file /readme/license.txt. -- -- LOG -- Use cvs log to obtain detailed change logs. */ #include "extern.h" typedef struct se { char *st_name; /* name of cell */ uint32 st_nkey; /* name hash key */ int st_count; /* how count for how */ uint32 st_dkey; /* directory hash key */ uint32 st_key; /* hash key */ struct se *st_next; } KSTATE, *KSTATEPTR; static KSTATEPTR _st_head = NIL(KSTATE); static KSTATEPTR _st_tail = NIL(KSTATE); static int _st_upd = FALSE; static char *_st_file = NIL(char); static int _my_fgets ANSI((char *, int, FILE *)); PUBLIC void Read_state() { char *buf; char sizeb[20]; FILE *fp; KSTATEPTR sp; if( (fp = Search_file(".KEEP_STATE", &_st_file)) != NIL(FILE) ) { if( _my_fgets( sizeb, 20, fp ) ) { int size = atol(sizeb); buf = MALLOC(size+2, char); while( _my_fgets(buf, size, fp) ) { TALLOC(sp, 1, KSTATE); sp->st_name = DmStrDup(buf); (void) Hash(buf, &sp->st_nkey); if( _my_fgets(buf, size, fp) ) sp->st_count = atoi(buf); if( _my_fgets(buf, size, fp) ) sp->st_dkey = (uint32) atol(buf); if( _my_fgets(buf, size, fp) ) sp->st_key = (uint32) atol(buf); else { FREE(sp); break; } if( _st_head == NIL(KSTATE) ) _st_head = sp; else _st_tail->st_next = sp; _st_tail = sp; } FREE(buf); } Closefile(); } } PUBLIC void Write_state() { static int in_write = 0; register KSTATEPTR sp; FILE *fp; if( !_st_upd || !_st_file || (_st_file && !*_st_file) || Trace || in_write ) return; in_write++; if( (fp = Openfile(_st_file, TRUE, TRUE)) != NIL(FILE) ) { int maxlen = 0; int tmplen; for( sp = _st_head; sp; sp=sp->st_next ) if( (tmplen = strlen(sp->st_name)+2) > maxlen ) maxlen = tmplen; /* A nice arbitrary minimum size */ if( maxlen < 20 ) maxlen = 20; fprintf( fp, "%d\n", maxlen ); for( sp = _st_head; sp; sp=sp->st_next ) { uint16 hv; uint32 hk; if( Search_table(Defs, sp->st_name, &hv, &hk) ) { fprintf( fp, "%s\n", sp->st_name ); fprintf( fp, "%d\n", sp->st_count ); /* long unsigned can be != uint32, silence the warning. */ fprintf( fp, "%lu\n", (unsigned long)sp->st_dkey ); fprintf( fp, "%lu\n", (unsigned long)sp->st_key ); } } Closefile(); } else Fatal("Cannot open STATE file %s", _st_file); in_write = 0; } PUBLIC int Check_state( cp, recipes, maxrcp ) CELLPTR cp; STRINGPTR *recipes; int maxrcp; { KSTATEPTR st; STRINGPTR sp; int i; uint32 thkey; uint32 hkey; uint32 nkey; uint32 dkey; int update = FALSE; if( !_st_file || (_st_file && !*_st_file) || Trace ) return(FALSE); if( strcmp(cp->CE_NAME,".REMOVE") == 0 || (cp->ce_attr & (A_PHONY|A_NOSTATE)) ) return(FALSE); (void) Hash( cp->CE_NAME, &nkey ); thkey = nkey + (uint32) cp->ce_count; (void) Hash( Pwd, &dkey ); thkey += dkey; Suppress_temp_file = TRUE; for( i=0 ; ist_next ) { CELLPTR svct = Current_target; char *cmnd; t_attr silent = (Glob_attr & A_SILENT); Current_target = cp; Glob_attr |= A_SILENT; cmnd = Expand(sp->st_string); Glob_attr = (Glob_attr & ~A_SILENT)|silent; Current_target = svct; (void) Hash(cmnd, &hkey); thkey += hkey; FREE(cmnd); } Suppress_temp_file = FALSE; for( st=_st_head; st != NIL(KSTATE); st=st->st_next ) { if( st->st_nkey == nkey && st->st_dkey == dkey && st->st_count == cp->ce_count && !strcmp(cp->CE_NAME, st->st_name) ) break; } if( st == NIL(KSTATE) ) { KSTATEPTR nst; TALLOC(nst, 1, KSTATE); nst->st_name = cp->CE_NAME; nst->st_nkey = nkey; nst->st_dkey = dkey; nst->st_key = thkey; nst->st_count = cp->ce_count; if( _st_head == NIL(KSTATE) ) _st_head = nst; else _st_tail->st_next = nst; _st_tail = nst; _st_upd = TRUE; } else if( st->st_key != thkey ) { st->st_key = thkey; _st_upd = update = TRUE; } return(st != NIL(KSTATE) && update); } static int _my_fgets(buf, size, fp) char *buf; int size; FILE *fp; { char *p; if( fgets(buf, size, fp) == NULL ) return(0); if( (p=strrchr(buf,'\n')) != NIL(char) ) *p='\0'; if( (p=strrchr(buf,'\r')) != NIL(char) ) *p='\0'; return(1); } libreoffice-6-1+backports'>distro/lhm/libreoffice-6-1+backports LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/extras
AgeCommit message (Expand)Author
2013-04-09Update Swedish autocorrect files.Niklas Johansson
2013-04-08The library we want is called dbulo, not dbauiTor Lillqvist
2013-04-08Convert Writer asian text grid page to Widget UIOlivier Hallot
2013-04-05move autocorr.zip to packageDavid Tardon
2013-04-05move palettes.zip to packageDavid Tardon
2013-04-03re-zip bg/template.bau to get correct checksumsDavid Tardon
2013-04-02Widget UI for Calc cell alignment pageOlivier Hallot
2013-03-29remove mammut -> mamut autocorrection from HungarianAndras Timar
2013-03-24Add builder support for a few dbaui controlsMathias Hasselmann
2013-03-23Fixed templates notes view and master pagesJacqueline Rahemipour
2013-03-15add print preview to catalogCaolán McNamara
2013-03-15add extra custom widgets to glade catalogCaolán McNamara
2013-03-14add in custom category widgetsCaolán McNamara
2013-03-14remove legacy build.pl prj/build.lst files.Michael Meeks
2013-03-14Make sure output dir exsits for xsltprocStephan Bergmann
2013-03-14Show LibreOffice controls in Glade's tool paletteMathias Hasselmann
2013-03-13gbuild: use zip --must-match to fail if input files are missingMichael Stahl
2013-03-11add glade placeholder for swuilo-BookmarkComboCaolán McNamara
2013-03-06some refinements on label configurations in writerWinfried Donkers
2013-03-05make formula refButton and refEdit loadable from .uiCaolán McNamara
2013-03-04Add new dialog to Query Design ViewZolnai Tamás
2013-03-04add more custom widgets to glade catalogCaolán McNamara
2013-02-28remove all d.lstMichael Stahl
2013-02-28various efforts to consistently apply HIG rulesCaolán McNamara
2013-02-27Convert page format tab page to new widget UIOlivier Hallot
2013-02-27reluctantly support NumericBox as a custom widgetCaolán McNamara
2013-02-24add more custom widgets to glade catalogCaolán McNamara
2013-02-22wrap max-width-chars in a custom widget to avoid it getting dropped silentlyCaolán McNamara
2013-02-22[Uu]sefull -> [Uu]sefulJulien Nabet
2013-02-22more custom widgets for glade catalogCaolán McNamara
2013-02-22add some more custom widgets to the glade catalogCaolán McNamara
2013-02-22fdo#61138 add Catalan autocorrection data to makefilesAndras Timar
2013-02-22fdo#61138 add Catalan autocorrection dataJoan Montane
2013-02-21add SvxSimpleTableContainer to glade catalogCaolán McNamara
2013-02-21convert Turkish AutoText files from old binary to zipped XMLAndras Timar
2013-02-21add a glade catalog so glade can manage our custom widgetsCaolán McNamara
2013-02-14Get Labels.xcu out of configuration data.Matúš Kukan
2013-02-12remove Basque autotext files, they were in EnglishAndras Timar
2013-02-08fdo#50827 move language dependent wordlists to the appropriate dict packAndras Timar
2013-01-18add new author to font copyright list and regenerate .ttfCaolán McNamara
2013-01-18Resolves: fdo#44718 Add Unicode 2034 (Triple Prime) to OpenSymbolMathias Hasselmann
2013-01-17fdo#59396 Remove duplicate footer entries in "BrightBlue" Impress templateSamuel Mehrbrodt
2012-12-29rethink external executable setupDavid Tardon
2012-12-19Respect TARFILE_LOCATION variable.Tomas Chvatal