2015-01-17 10:32:52 -05:00
|
|
|
/**
|
|
|
|
* See Copyright Notice in picrin.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "picrin.h"
|
2016-02-20 10:58:58 -05:00
|
|
|
#include "picrin/extra.h"
|
2015-01-17 10:32:52 -05:00
|
|
|
|
2016-02-18 15:54:50 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-01-17 10:32:52 -05:00
|
|
|
static pic_value
|
|
|
|
pic_load_load(pic_state *pic)
|
|
|
|
{
|
2016-02-20 02:51:24 -05:00
|
|
|
pic_value envid, port;
|
2015-01-17 10:32:52 -05:00
|
|
|
char *fn;
|
2016-02-18 15:54:50 -05:00
|
|
|
FILE *fp;
|
2015-01-17 10:32:52 -05:00
|
|
|
|
|
|
|
pic_get_args(pic, "z|o", &fn, &envid);
|
|
|
|
|
2016-02-18 15:54:50 -05:00
|
|
|
fp = fopen(fn, "r");
|
|
|
|
if (fp == NULL) {
|
2016-02-22 14:03:42 -05:00
|
|
|
pic_error(pic, "load: could not open file", 1, pic_cstr_value(pic, fn));
|
2016-02-18 15:54:50 -05:00
|
|
|
}
|
|
|
|
|
2016-06-19 15:49:01 -04:00
|
|
|
port = pic_fopen(pic, fp, "r");
|
2015-07-12 19:20:07 -04:00
|
|
|
|
|
|
|
pic_load(pic, port);
|
|
|
|
|
2016-06-19 15:49:01 -04:00
|
|
|
pic_fclose(pic, port);
|
2015-01-17 10:32:52 -05:00
|
|
|
|
2016-02-18 06:15:42 -05:00
|
|
|
return pic_undef_value(pic);
|
2015-01-17 10:32:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
pic_init_load(pic_state *pic)
|
|
|
|
{
|
2016-02-18 03:39:32 -05:00
|
|
|
pic_deflibrary(pic, "scheme.load");
|
2016-02-14 23:20:26 -05:00
|
|
|
|
|
|
|
pic_defun(pic, "load", pic_load_load);
|
2015-01-17 10:32:52 -05:00
|
|
|
}
|