1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
/*
* This file is part of XForms.
*
* XForms is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1, or
* (at your option) any later version.
*
* XForms is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with XForms. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file fd_util.c
*
* Eliminate the emission of duplicate info. This is necessary as
* some #include define data (pixmap for example).
*
* We should eventually move the functionality of already_emited in
* fd_printC.c into this function so callback is also checked. This
* probably means we need make struct CodeInfo more efficient.
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "include/forms.h"
#include "fd_main.h"
#define MAXREC 80
#define MAXLEN 79
typedef struct {
FL_FORM * form;
char buf[ MAXLEN + 1 ];
} CodeInfo;
static CodeInfo info[ MAXREC ];
static int ninfo;
/***************************************
***************************************/
void
reset_dupinfo_cache( void )
{
ninfo = 0;
}
/***************************************
***************************************/
int
is_duplicate_info( FL_OBJECT * ob FL_UNUSED_ARG,
const char * s )
{
int i;
for ( i = 0; i < ninfo; i++ )
if ( strcmp( s, info[ i ].buf ) == 0 )
return 1;
if ( ninfo == MAXREC )
{
fprintf( stderr, "dupinfo cache overflown\n" );
ninfo--;
}
fli_sstrcpy( info[ ninfo++ ].buf, s, MAXLEN );
return 0;
}
/*
* Local variables:
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/
|