DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T f

⟦075de97d4⟧ TextFile

    Length: 1788 (0x6fc)
    Types: TextFile
    Names: »file_enc.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/dsap/common/file_enc.c« 

TextFile

#include "quipu/util.h"
#include "quipu/attrvalue.h"

extern LLog * log_dsap;

PE grab_filepe (av)
AttributeValue av;
{
FILE * fptr;
struct file_syntax * fs;
sntx_table *tbl, * get_syntax_table();
PE ret_pe, grab_pe();


	fs = (struct file_syntax *) av->av_struct;

	if (fs->fs_attr != NULLAttrV)
		return (grab_pe (fs->fs_attr));

	if (fs->fs_name == NULLCP) 
		return (NULLPE);	/* should never happen */

	if ((fptr = fopen (fs->fs_name,"r")) != NULL) {
		tbl = get_syntax_table (fs->fs_real_syntax);
		if (tbl->s_parse == NULLIFP) { /* treat as pure asn */
			PS fps;
			fps = ps_alloc (std_open);
			if ((std_setup (fps,fptr)) == NOTOK) {
				(void) fclose (fptr);
				ps_free (fps);
				return (NULLPE);
			}
			if ((ret_pe = ps2pe (fps)) == NULLPE)
				LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid ASN if file %s",fs->fs_name));
			(void) fclose (fptr);
			ps_free (fps);
		} else {
			char buffer [LINESIZE];
			AttributeValue newav;
			extern char * TidyString ();
	
			(void) fread (buffer,LINESIZE,1,fptr);
			(void) fclose (fptr);
			if ((newav = str2AttrV (TidyString(buffer),fs->fs_real_syntax)) == NULLAttrV){
				LLOG (log_dsap,LLOG_EXCEPTIONS,("invalid format in file %s",fs->fs_name));
			}
			ret_pe = grab_pe (newav);
			AttrV_free (newav);
		}
	} else  {
		LLOG(log_dsap,LLOG_EXCEPTIONS,("Can't open %s",fs->fs_name));
		return (NULLPE);
	}
	return (ret_pe);

}


file_decode (x)
AttributeValue x;
{
struct file_syntax * fs;

	fs = (struct file_syntax *) smalloc (sizeof(struct file_syntax));
	fs->fs_ref = 1;
	fs->fs_real_syntax = x->av_syntax - AV_WRITE_FILE;
	fs->fs_name = NULLCP;

	fs->fs_attr = AttrV_alloc ();
	fs->fs_attr->av_syntax = x->av_syntax - AV_WRITE_FILE;
	fs->fs_attr->av_struct = x->av_struct;
		
	x->av_syntax = AV_FILE;
	x->av_struct = (caddr_t)fs;
}