示例#1
0
void
vplist_free( vplist *vpl )
{
	assert( vpl );
	if ( vpl->data ) free( vpl->data );
	vplist_init( vpl );
}
示例#2
0
vplist *
vplist_new( void )
{
	vplist *vpl;
	vpl = ( vplist * ) malloc( sizeof( vplist ) );
	if ( vpl ) vplist_init( vpl );
	return vpl;
}
示例#3
0
static void
output_easyall( FILE *fp, fields *f, char *tag, char *adstag, int level )
{
	vplist a;
	int i;
	vplist_init( &a );
	fields_findv_each( f, level, FIELDS_CHRP, &a, tag );
	for ( i=0; i<a.n; ++i )
		fprintf( fp, "%s %s\n", adstag, (char *) vplist_get( &a, i ) );
	vplist_free( &a );
}
示例#4
0
static void
output_keywords( FILE *fp, fields *f )
{
	vplist vpl;
	int i;
	vplist_init( &vpl );
	fields_findv_each( f, LEVEL_ANY, FIELDS_CHRP, &vpl, "KEYWORD" );
	for ( i=0; i<vpl.n; ++i )
		fprintf( fp, "KW  - %s\n", ( char * ) vplist_get( &vpl, i ) );
	vplist_free( &vpl );
}
示例#5
0
static void
output_keys( FILE *fp, fields *f, char *tag, char *adstag, int level )
{
	vplist a;
	int i;
	vplist_init( &a );
	fields_findv_each( f, level, FIELDS_CHRP, &a, tag );
	for ( i=0; i<a.n; ++i ) {
		if ( i==0 ) fprintf( fp, "%s ", adstag );
		else fprintf( fp, ", " );
		fprintf( fp, "%s", (char *) vplist_get( &a, i ) );
	}
	if ( a.n ) fprintf( fp, "\n" );
	vplist_free( &a );
}
示例#6
0
static void
output_people( FILE *fp, fields *f, char *tag, char *ristag, int level )
{
	newstr oneperson;
	vplist people;
	int i;
	newstr_init( &oneperson );
	vplist_init( &people );
	fields_findv_each( f, level, FIELDS_CHRP, &people, tag );
	for ( i=0; i<people.n; ++i ) {
		name_build_withcomma( &oneperson, ( char * ) vplist_get( &people, i ) );
		fprintf( fp, "%s  - %s\n", ristag, oneperson.data );
	}
	vplist_free( &people );
	newstr_free( &oneperson );
}
示例#7
0
static void
output_file( FILE *fp, fields *f, char *tag, char *ristag, int level )
{
	vplist a;
	char *fl;
	int i;
	vplist_init( &a );
	fields_findv_each( f, level, FIELDS_CHRP, &a, tag );
	for ( i=0; i<a.n; ++i ) {
		fprintf( fp, "%s  - ", ristag );
		fl = ( char * ) vplist_get( &a, i );
		if ( !is_uri_scheme( fl ) )
			fprintf( fp, "file:" );
		fprintf( fp, "%s\n", fl );
	}
	vplist_free( &a );
}
示例#8
0
static void
output_people( FILE *fp, fields *f, char *tag, char *isitag, int level )
{
	vplist people;
	int i;
	vplist_init( &people );
	fields_findv_each( f, level, FIELDS_CHRP, &people, tag );
	if ( people.n ) {
		fprintf( fp, "%s ", isitag );
		for ( i=0; i<people.n; ++i ) {
			if ( i!=0 ) fprintf( fp, "   " );
			output_person( fp, (char *)vplist_get( &people, i ) );
			fprintf( fp, "\n" );
		}
	}
	vplist_free( &people );
}
示例#9
0
static void
output_keywords( FILE *fp, fields *f )
{
	vplist kw;
	int i;
	vplist_init( &kw );
	fields_findv_each( f, LEVEL_ANY, FIELDS_CHRP, &kw, "KEYWORD" );
	if ( kw.n ) {
		fprintf( fp, "DE " );
		for ( i=0; i<kw.n; ++i ) {
			if ( i>0 ) fprintf( fp, "; " );
			fprintf( fp, "%s", (char *)vplist_get( &kw, i ) );
		}
		fprintf( fp, "\n" );
	}
	vplist_free( &kw );
}
示例#10
0
static void
output_people( FILE *fp, fields *f, char *tag1, char *tag2, char *tag3, char *adstag, int level )
{
	newstr oneperson;
	vplist a;
	int i;
	newstr_init( &oneperson );
	vplist_init( &a );
	fields_findv_eachof( f, level, FIELDS_CHRP, &a, tag1, tag2, tag3, NULL );
	extern void  fields_findv_eachof( fields *f, int level, int mode, vplist *a, ... );
	for ( i=0; i<a.n; ++i ) {
		if ( i==0 ) fprintf( fp, "%s ", adstag );
		else fprintf( fp, "; " );
		name_build_withcomma( &oneperson, (char *) vplist_get( &a, i) );
		fprintf( fp, "%s", oneperson.data );
	}
	if ( a.n ) fprintf( fp, "\n" );
	vplist_free( &a );
	newstr_free( &oneperson );
}
示例#11
0
static void
output_comments( fields *info, FILE *outptr, int level )
{
	vplist notes;
	char *abs;
	int i;

	vplist_init( &notes );

	abs = fields_findv( info, level, FIELDS_CHRP, "ABSTRACT" );
	fields_findv_each( info, level, FIELDS_CHRP, &notes, "NOTES" );

	if ( abs || notes.n ) fprintf( outptr, "<b:Comments>" );
	if ( abs ) fprintf( outptr, "%s", abs );
	for ( i=0; i<notes.n; ++i )
		fprintf( outptr, "%s", (char*)vplist_get( &notes, i ) );
	if ( abs || notes.n ) fprintf( outptr, "</b:Comments>\n" );

	vplist_free( &notes );
}
示例#12
0
/* Try to determine type of reference from
 * <TypeOfResource></TypeOfResource>
 */
static int
get_type_resource( fields *f, param *p )
{
	match_type match_res[] = {
		{ "software, multimedia",      TYPE_PROGRAM },
		{ "cartographic",              TYPE_MAP     },
	};
	int nmatch_res = sizeof( match_res ) / sizeof( match_res[0] );
	int type, i, j;
	char *value;
	vplist a;

	type = TYPE_UNKNOWN;

	vplist_init( &a );
	fields_findv_each( f, LEVEL_ANY, FIELDS_CHRP, &a, "RESOURCE" );

	for ( i=0; i<a.n; ++i ) {
		value = ( char * ) vplist_get( &a, i );
		for ( j=0; j<nmatch_res; ++j ) {
			if ( !strcasecmp( value, match_res[j].name ) )
				type = match_res[j].type;
		}
		if ( p->verbose ) {
			if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
			fprintf( stderr, "Type from tag 'RESOURCE' data '%s': ", value );
			write_type( stderr, type );
			fprintf( stderr, "\n" );
		}
	}

	if ( p->verbose ) {
		if ( p->progname ) fprintf( stderr, "%s: ", p->progname );
		fprintf( stderr, "Type from resource element: " );
		write_type( stderr, type );
		fprintf( stderr, "\n" );
	}

	vplist_free( &a );
	return type;
}