⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mal_import.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
字号:
#line 47 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"#include "mal_config.h"#include "mal_import.h"#include "mal_interpreter.h"	/* for showErrors() */#include "mal_linker.h"		/* for loadModuleLibrary() */#include "mal_parser.h"voidslash_2_dir_sep(str fname){	char *s;	for (s = fname; *s; s++)		if (*s == '/')			*s = DIR_SEP;}static stream *malOpenSource(str fname){	stream *fd = NULL;	char path[PATHLENGTH];	str fullname;	snprintf(path,PATHLENGTH,"%s",fname);	slash_2_dir_sep(path);	fullname = MSP_locate_script(path);	if (fullname) {		fd = open_rastream(fullname);		GDKfree(fullname);	} else {		fd = open_rastream(path);	}	return fd;}#line 93 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"strmalLoadScript(str name, bstream **fdin){	stream *fd;	fd = malOpenSource(name);	if (stream_errnr(fd) == OPEN_ERROR) {		stream_destroy(fd);		throw(MAL, "malInclude", "could not open file: %s", name);	}	*fdin = bstream_create(fd, 128 * BLOCK);	if( bstream_next(*fdin) < 0)			stream_printf(GDKout,"!WARNING: could not read %s\n",name);	return MAL_SUCCEED;}#line 167 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"voidmalInclude(Client c, str name, int listing){	str s;	bstream *oldfdin = c->fdin;	int oldyycur = c->yycur;	int oldlisting = c->listing;	int oldmode = c->mode;	int oldblkmode = c->blkmode;	ClientInput *oldbak = c->bak;	str oldprompt = c->prompt;	str oldsrcFile = c->srcFile;	MalStkPtr oldglb = c->glb;	Module oldnspace = c->nspace;	Symbol oldprg = c->curprg;	c->yycur = 0;	c->prompt = GDKstrdup("");	/* do not produce visible prompts */	c->promptlength = strlen(c->prompt);	c->listing = listing;	c->bak = NULL;	c->fdin = NULL;	c->srcFile = name;	if ((s = malLoadScript(name, &c->fdin)))		stream_printf(c->fdout, "!%s\n", s);	else 		parseMAL(c,c->curprg);	#line 151 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 151 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 152 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"#line 198 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"}#line 221 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"strevalFile(Client c, str fname, int listing){	#line 118 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	bstream *oldfdin = c->fdin;	int oldyycur = c->yycur;	int oldlisting = c->listing;	int oldmode = c->mode;	int oldblkmode = c->blkmode;	str oldsrcFile = c->srcFile;	ClientInput *oldbak = c->bak;	str oldprompt = c->prompt;	Module oldnspace = c->nspace;	Symbol oldprg = c->curprg;	MalStkPtr oldglb = c->glb;#line 223 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	stream *fd;	str msg= MAL_SUCCEED;	c->yycur = 0;	c->prompt = GDKstrdup("");	/* do not produce visible prompts */	c->promptlength = strlen(c->prompt);	c->listing = listing;	c->bak = NULL;	c->fdin = NULL;	c->srcFile= fname;	fd = malOpenSource(fname);	if (stream_errnr(fd) == OPEN_ERROR) {		stream_destroy(fd);		stream_printf(c->fdout, "#WARNING: could not open file: %s", fname);	} else {		c->fdin = bstream_create(fd, 128 * BLOCK);		MSinitClientPrg(c,"user","main");	/* re-initialize context */		msg= runScenario(c);	}	#line 151 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 151 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 152 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"#line 245 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	return msg;}#line 251 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"strcompileString(Symbol *fcn, Client c, str s){	#line 118 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	bstream *oldfdin = c->fdin;	int oldyycur = c->yycur;	int oldlisting = c->listing;	int oldmode = c->mode;	int oldblkmode = c->blkmode;	str oldsrcFile = c->srcFile;	ClientInput *oldbak = c->bak;	str oldprompt = c->prompt;	Module oldnspace = c->nspace;	Symbol oldprg = c->curprg;	MalStkPtr oldglb = c->glb;#line 253 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	int len = strlen(s);	buffer *b;	str msg = MAL_SUCCEED;	str qry;	c->yycur = 0;	c->prompt = GDKstrdup("");	/* do not produce visible prompts */	c->promptlength = strlen(c->prompt);	c->listing = 0;	c->bak = NULL;	c->fdin = NULL;	c->srcFile= NULL;	b = (buffer *) GDKmalloc(sizeof(buffer));	if (s[len - 1] != '\n') {		char *n = GDKmalloc(len + 1 + 1);		strncpy(n, s, len);		n[len] = '\n';		n[len + 1] = 0;		s = n;		len++;	}	mal_unquote(qry = GDKstrdup(s));	buffer_init(b, qry, len);	MCpushClientInput(c, bstream_create(buffer_rastream(b, "compileString"), b->len), 0, "");	MSinitClientPrg(c,"user", "main");	/* create new context */	/* runPhase(READER,restoreClient1) */	if(msg== MAL_SUCCEED && c->phase[READER] && 		(msg= (str) (*c->phase[READER])(c)) ){		#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 284 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return msg;	}	/* runPhase(PARSER,restoreClient1) */	if(msg== MAL_SUCCEED && c->phase[PARSER] && 		(msg= (str) (*c->phase[PARSER])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 292 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return msg;	}	*fcn= c->curprg;	/* restore IO channel */	#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 297 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->listing = oldlisting;	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;	GDKfree(qry);	return MAL_SUCCEED;}#line 309 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"voidcallString(Client c, str s, int listing){	#line 118 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	bstream *oldfdin = c->fdin;	int oldyycur = c->yycur;	int oldlisting = c->listing;	int oldmode = c->mode;	int oldblkmode = c->blkmode;	str oldsrcFile = c->srcFile;	ClientInput *oldbak = c->bak;	str oldprompt = c->prompt;	Module oldnspace = c->nspace;	Symbol oldprg = c->curprg;	MalStkPtr oldglb = c->glb;#line 312 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	int len = strlen(s);	buffer *b;	str msg = MAL_SUCCEED,qry;	c->yycur = 0;	c->prompt = GDKstrdup("");	/* do not produce visible prompts */	c->promptlength = strlen(c->prompt);	c->listing = listing;	c->bak = NULL;	c->fdin = NULL;	c->srcFile= NULL;	b = (buffer *) GDKmalloc(sizeof(buffer));	if (s[len - 1] != '\n') {		char *n = GDKmalloc(len + 1 + 1);		strncpy(n, s, len);		n[len] = '\n';		n[len + 1] = 0;		s = n;		len++;	}	mal_unquote(qry = GDKstrdup(s));	buffer_init(b, qry, len);	MCpushClientInput(c, bstream_create(buffer_rastream(b, "callString"), b->len), listing, "");	MSinitClientPrg(c,"user", "main");	/* create new context */	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if(msg== MAL_SUCCEED && c->phase[READER] && (msg= (str) (*c->phase[READER])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		GDKfree(msg); msg=MAL_SUCCEED;		#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 158 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return;	}#line 339 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if(msg== MAL_SUCCEED && c->phase[PARSER] && (msg= (str) (*c->phase[PARSER])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		GDKfree(msg); msg=MAL_SUCCEED;		#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 158 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return;	}#line 340 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	/* restore IO channel */	#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if (c->fdin) {		(void) stream_close(c->fdin->s);		(void) stream_destroy(c->fdin->s);		(void) bstream_destroy(c->fdin);	}	c->fdin = oldfdin; 	c->yycur = oldyycur; 	c->listing = oldlisting;	c->mode = oldmode;	c->blkmode = oldblkmode;	c->bak = oldbak;	c->srcFile = oldsrcFile;	if(c->prompt) GDKfree(c->prompt);	c->prompt = oldprompt;	c->promptlength= strlen(c->prompt);#line 342 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if(msg== MAL_SUCCEED && c->phase[OPTIMIZE] && (msg= (str) (*c->phase[OPTIMIZE])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		GDKfree(msg); msg=MAL_SUCCEED;		#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 158 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return;	}#line 343 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if(msg== MAL_SUCCEED && c->phase[SCHEDULER] && (msg= (str) (*c->phase[SCHEDULER])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		GDKfree(msg); msg=MAL_SUCCEED;		#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 158 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return;	}#line 344 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	if(msg== MAL_SUCCEED && c->phase[ENGINE] && (msg= (str) (*c->phase[ENGINE])(c)) ){		/* error occurred  and ignored */		/* stream_printf(GDKout,"%s",msg);*/		GDKfree(msg); msg=MAL_SUCCEED;		#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 158 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"		return;	}#line 345 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	#line 147 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	c->glb = oldglb;	c->nspace = oldnspace;	c->curprg = oldprg;#line 346 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/mal/mal_import.mx"	GDKfree(qry);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -