Wild Life  2.30
 All Data Structures Files Functions Variables Typedefs Macros
Data Structures | Macros | Typedefs | Functions
sys.c File Reference

system functions More...

Go to the source code of this file.

Data Structures

struct  a_stream
 
struct  psi_feature
 

Macros

#define BYTEDATA_SIZE(X)   (*(unsigned long *)(X->value_3))
 
#define BYTEDATA_DATA(X)   ((char*)((char*)X->value_3 + sizeof(unsigned long)))
 
#define BV_AND   0
 
#define BV_OR   1
 
#define BV_XOR   2
 
#define BV_NOT   0
 
#define BV_COUNT   1
 
#define BV_GET   0
 
#define BV_SET   1
 
#define BV_CLEAR   2
 
#define FP_NONE   0
 
#define FP_INPUT   1
 
#define FP_OUTPUT   2
 
#define FP_PREPARE(s, OP)
 
#define SEEK_SET   0
 
#define SEEK_CUR   1
 
#define SEEK_END   2
 
#define SETFEATURE(lst, n, nam, val)   ((lst[n].name_str=nam),(lst[n].value_str=val))
 

Typedefs

typedef struct a_streamptr_stream
 

Functions

long call_primitive (long(*fun)(), int num, psi_arg argi[], GENERIC info)
 call_primitive More...
 
static ptr_psi_term make_bytedata (ptr_definition sort, unsigned long bytes)
 make_bytedata( More...
 
static long make_bitvector_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 make_bitvector_internal More...
 
static long c_make_bitvector ()
 c_make_bitvector More...
 
static long bitvector_binop_code (unsigned long *bv1, unsigned long *bv2, ptr_psi_term result, GENERIC op)
 bitvector_binop_code More...
 
static long bitvector_binop_internal (ptr_psi_term *args, ptr_psi_term result, ptr_psi_term funct, GENERIC op)
 bitvector_binop_internal More...
 
static long bitvector_binop (long op)
 bitvector_binop More...
 
static long c_bitvector_and ()
 c_bitvector_and More...
 
static long c_bitvector_or ()
 c_bitvector_or More...
 
static long c_bitvector_xor ()
 c_bitvector_xor More...
 
static long bitvector_unop_code (unsigned long *bv1, ptr_psi_term result, int op)
 bitvector_unop_code More...
 
static long bitvector_unop_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, int op)
 bitvector_unop_internal More...
 
static long bitvector_unop (GENERIC op)
 bitvector_unop More...
 
static long c_bitvector_not ()
 c_bitvector_not More...
 
static long c_bitvector_count ()
 c_bitvector_count More...
 
static long bitvector_bit_code (unsigned long *bv1, long idx, ptr_psi_term result, int op, ptr_psi_term funct)
 bitvector_bit_code More...
 
static long bitvector_bit_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, int op)
 bitvector_bit_internal More...
 
static long bitvector_bit (long op)
 bitvector_bit More...
 
static long c_bitvector_get ()
 c_bitvector_get More...
 
static long c_bitvector_set ()
 c_bitvector_set More...
 
static long c_bitvector_clear ()
 c_bitvector_clear More...
 
void regerror (char *s)
 regerror More...
 
static long regexp_compile_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 regexp_compile_internal More...
 
static long c_regexp_compile ()
 c_regexp_compile More...
 
static long regexp_execute_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 regexp_execute_internal More...
 
static long c_regexp_execute ()
 c_regexp_execute More...
 
ptr_psi_term fileptr2stream (FILE *fp, ptr_definition typ)
 fileptr2stream More...
 
static long int2stream_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 int2stream_internal More...
 
static long c_int2stream ()
 c_int2stream More...
 
static long fopen_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 fopen_internal More...
 
static long c_fopen ()
 c_fopen More...
 
static long fclose_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 fclose_internal More...
 
static long c_fclose ()
 c_fclose More...
 
static long fwrite_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 fwrite_internal More...
 
static long c_fwrite ()
 c_fwrite More...
 
static long fflush_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 fflush_internal More...
 
static long c_fflush ()
 c_fflush More...
 
static long get_buffer_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 get_buffer_internal More...
 
static long c_get_buffer ()
 c_get_buffer More...
 
int text_buffer_next (struct text_buffer *buf, int idx, char c, struct text_buffer **rbuf, int *ridx)
 text_buffer_next More...
 
char * text_buffer_cmp (struct text_buffer *buf, int idx, char *str)
 text_buffer_cmp More...
 
void text_buffer_push (struct text_buffer **buf, char c)
 text_buffer_push More...
 
void text_buffer_free (struct text_buffer *buf)
 text_buffer_free More...
 
static long get_record_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 get_record_internal More...
 
static long c_get_record ()
 c_get_record More...
 
static long get_code_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 get_code_internal More...
 
static long c_get_code ()
 c_get_code More...
 
static long ftell_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 ftell_internal More...
 
static long c_ftell ()
 c_ftell More...
 
static long fseek_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 fseek_internal More...
 
static long c_fseek ()
 c_fseek More...
 
static long stream2sys_stream_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 stream2sys_stream_internal More...
 
static long c_stream2sys_stream ()
 c_stream2sys_stream More...
 
static long sys_stream2stream_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 sys_stream2stream_internal More...
 
static long c_sys_stream2stream ()
 c_sys_stream2stream More...
 
static long socket_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 socket_internal More...
 
static long c_socket ()
 c_socket More...
 
int is_ipaddr (char *s)
 is_ipaddr More...
 
static long bind_or_connect_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, void *info)
 bind_or_connect_internal More...
 
static long c_bind ()
 c_bind More...
 
static long c_connect ()
 c_connect More...
 
static long listen_internal (args, result, funct)
 
static long c_listen ()
 c_listen More...
 
static long accept_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 accept_internal More...
 
static long c_accept ()
 c_accept More...
 
static long errno_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 errno_internal More...
 
static long c_errno ()
 c_errno More...
 
static long errmsg_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 errmsg_internal More...
 
static long c_errmsg ()
 c_errmsg More...
 
static long import_symbol_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 import_symbol_internal More...
 
static long c_import_symbol ()
 c_import_symbol More...
 
static long fork_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 
static long c_fork ()
 c_fork More...
 
static long unify_pterm_result (ptr_psi_term t, ptr_definition sym, psi_feature lst[], int n)
 unify_pterm_result More...
 
char * get_numeric_feature (long n)
 get_numeric_feature More...
 
static long unify_wait_result (ptr_psi_term result, pid_t id, int status)
 unify_wait_result More...
 
static long wait_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 wait_internal More...
 
static long c_wait ()
 c_wait More...
 
static long waitpid_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 waitpid_internal More...
 
static long c_waitpid ()
 c_waitpid More...
 
static long kill_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 kill_internal More...
 
static long c_kill ()
 c_kill More...
 
static long cuserid_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 cuserid_internal More...
 
static long c_cuserid ()
 c_cuserid More...
 
static long gethostname_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 gethostname_internal More...
 
static long c_gethostname ()
 c_gethostname More...
 
static long lazy_project_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 lazy_project_internal More...
 
static long c_lazy_project ()
 c_lazy_project More...
 
static long wait_on_feature_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 wait_on_feature_internal More...
 
static long c_wait_on_feature ()
 c_wait_on_feature More...
 
static long my_wait_on_feature_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 my_wait_on_feature_internal More...
 
static long c_my_wait_on_feature ()
 c_my_wait_on_feature More...
 
static long call_once_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 call_once_internal More...
 
static long c_call_once ()
 c_call_once More...
 
static long apply1_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 apply1_internal More...
 
static long c_apply1 ()
 c_apply1() More...
 
static long getpid_internal (ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
 getpid_internal More...
 
static long c_getpid ()
 c_getpid More...
 
void make_sys_type_links ()
 make_sys_type_links More...
 
void check_sys_definitions ()
 check_sys_definitions More...
 
void insert_sys_builtins ()
 insert_sys_builtins More...
 

Detailed Description

system functions

All new system utilities and extensions to Wild LIFE 1.01 are implemented in this file and made available in LIFE module "sys"

Definition in file sys.c.

Macro Definition Documentation

#define BV_AND   0

Definition at line 181 of file sys.c.

#define BV_CLEAR   2

Definition at line 383 of file sys.c.

#define BV_COUNT   1

Definition at line 287 of file sys.c.

#define BV_GET   0

Definition at line 381 of file sys.c.

#define BV_NOT   0

Definition at line 286 of file sys.c.

#define BV_OR   1

Definition at line 182 of file sys.c.

#define BV_SET   1

Definition at line 382 of file sys.c.

#define BV_XOR   2

Definition at line 183 of file sys.c.

#define BYTEDATA_DATA (   X)    ((char*)((char*)X->value_3 + sizeof(unsigned long)))

Definition at line 139 of file sys.c.

#define BYTEDATA_SIZE (   X)    (*(unsigned long *)(X->value_3))

Definition at line 138 of file sys.c.

#define FP_INPUT   1

Definition at line 669 of file sys.c.

#define FP_NONE   0

Definition at line 668 of file sys.c.

#define FP_OUTPUT   2

Definition at line 670 of file sys.c.

#define FP_PREPARE (   s,
  OP 
)
Value:
if (s->op != OP && s->op != FP_NONE) fflush(s->fp); \
s->op = OP;
#define FP_NONE
Definition: sys.c:668

Definition at line 677 of file sys.c.

#define SEEK_CUR   1

Definition at line 1155 of file sys.c.

#define SEEK_END   2

Definition at line 1158 of file sys.c.

#define SEEK_SET   0

Definition at line 1152 of file sys.c.

#define SETFEATURE (   lst,
  n,
  nam,
  val 
)    ((lst[n].name_str=nam),(lst[n].value_str=val))

Definition at line 1665 of file sys.c.

Typedef Documentation

typedef struct a_stream * ptr_stream

Function Documentation

static long accept_internal ( ptr_psi_term  args[],
ptr_psi_term  argsresult,
ptr_psi_term  argsfunct 
)
static

accept_internal

Parameters
args- ptr_psi_term args[]
argsresult- ptr_psi_term argsresult
argsfunct- ptr_psi_term argsfunct

(FILE**)BYTEDATA_DATA(args[0]));

Definition at line 1476 of file sys.c.

References BYTEDATA_DATA, Errorline(), FALSE, fileptr2stream(), NULL, push_goal(), sys_socket_stream, TRUE, and unify.

1477 {
1478  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1479  int s;
1480 
1481  if ((s=accept(fd,NULL,NULL)) < 0) return FALSE;
1482  else {
1483  FILE * fp = fdopen(s,"r+");
1484  // ptr_psi_term t;
1485 
1486  if (fp==NULL) {
1487  Errorline("fdopen failed on socket in %P.\n",funct);
1488  return FALSE;
1489  }
1490 
1491  /* t = make_bytedata(sys_socket_stream,sizeof(fp));
1492  *(FILE**)BYTEDATA_DATA(t) = fp;*/
1493  push_goal(unify,fileptr2stream(fp,sys_socket_stream),result,NULL); // added & DJD
1494  return TRUE;
1495  }
1496 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
fileptr2stream
Definition: sys.c:688
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
Definition: sys.c:672
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
static long apply1_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

apply1_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 2099 of file sys.c.

References wl_psi_term::attr_list, clear_copy(), distinct_copy(), Errorline(), eval, FALSE, FEATCMP, function_it, get_numeric_feature(), heap_copy_string(), integer, push_goal(), quoted_string, REAL, residuate(), wl_definition::rule, stack_insert(), sub_type(), top, TRUE, and wl_psi_term::type.

2100 {
2101  long success=TRUE;
2102  if (args[0]->type==top) residuate(args[0]);
2103  else if (args[0]->type->type_def!=(def_type)function_it) {
2104  Errorline("1st arg not a function in %P.\n",funct);
2105  success=FALSE;
2106  }
2107  else {
2108  // char buffer_loc[1000];
2109  char * feat;
2110  ptr_psi_term fun;
2111  if (sub_type(args[1]->type,integer) && args[1]->value_3)
2112  feat = get_numeric_feature((long)*(REAL*)args[1]->value_3);
2113  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
2114  feat = (char *)args[1]->value_3;
2115  else
2116  feat = (char *)heap_copy_string(args[1]->type->keyword->symbol);
2117  clear_copy();
2118  fun=distinct_copy(args[0]);
2119  (void)stack_insert(FEATCMP,(char *)feat,&(fun->attr_list),(GENERIC)args[2]);
2120  push_goal(eval,fun,result,(GENERIC)fun->type->rule);
2121  }
2122  return success;
2123 }
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void clear_copy()
clear_copy
Definition: copy.c:53
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define eval
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1086
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
ptr_psi_term distinct_copy(ptr_psi_term t)
distinct_copy
Definition: copy.c:393
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * get_numeric_feature(long n)
get_numeric_feature
Definition: sys.c:1698
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_node attr_list
Definition: def_struct.h:187
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long bind_or_connect_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct,
void *  info 
)
static

bind_or_connect_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct
info- void *info

(FILE**)BYTEDATA_DATA(args[0]));

Definition at line 1351 of file sys.c.

References BYTEDATA_DATA, Errorline(), FALSE, is_ipaddr(), NULL, REAL, and TRUE.

1352 {
1353  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1354  int do_bind = info==NULL;
1355 
1356  if (args[1] || args[2]) {
1357  /* bind or connect in the internet domain */
1358  struct sockaddr_in name_loc;
1359  char* hostname = args[1]?(char*)args[1]->value_3:NULL;
1360  if (!args[2]) {
1361  Errorline("Missing port number in %P.\n",funct);
1362  return FALSE;
1363  }
1364 
1365  bzero((char*)&name_loc,sizeof(name_loc));
1366  name_loc.sin_family = AF_INET;
1367  name_loc.sin_port = htons((unsigned short)*(REAL*)args[2]->value_3);
1368 
1369  if (!hostname || *hostname=='\0' || !strcasecmp(hostname,"localhost"))
1370  name_loc.sin_addr.s_addr = INADDR_ANY;
1371  else {
1372  struct hostent * h;
1373  int ipaddr;
1374  if ((ipaddr=is_ipaddr(hostname))) {
1375  int i = inet_addr(hostname);
1376  h = gethostbyaddr((char*)&i,sizeof(i),AF_INET);
1377  } else h = gethostbyname(hostname);
1378  if (h==NULL) {
1379  Errorline("%s failed for %P.\n",
1380  ipaddr?"gethostbyaddr":"gethostbyname",funct);
1381  return FALSE;
1382  }
1383  bcopy(h->h_addr,(char*)&(name_loc.sin_addr.s_addr),h->h_length);
1384  }
1385  if ((do_bind?
1386  bind(fd,(struct sockaddr *)&name_loc,sizeof(name_loc)):
1387  connect(fd,(struct sockaddr *)&name_loc,sizeof(name_loc))) < 0) {
1388  Errorline("%s failed in %P.\n",do_bind?"bind":"connect",funct);
1389  return FALSE;
1390  }
1391  }
1392  else if (args[3]) {
1393  /* bind in the unix domain */
1394  struct sockaddr_un name_loc;
1395  char* path = (char*)args[3]->value_3;
1396 
1397  name_loc.sun_family = AF_UNIX;
1398  strcpy(name_loc.sun_path,path);
1399 
1400  if ((do_bind?
1401  bind(fd,(struct sockaddr *)&name_loc,sizeof(name_loc)):
1402  connect(fd,(struct sockaddr *)&name_loc,sizeof(name_loc))) < 0) {
1403  Errorline("%s failed in %P.\n",do_bind?"bind":"connect",funct);
1404  return FALSE;
1405  }
1406  }
1407  else {
1408  Errorline("Too few arguments in %P.\n",funct);
1409  return FALSE;
1410  }
1411  return TRUE;
1412 }
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
int is_ipaddr(char *s)
is_ipaddr
Definition: sys.c:1333
#define FALSE
Standard boolean.
Definition: def_const.h:275
Definition: sys.c:672
static long bitvector_binop ( long  op)
static

bitvector_binop

Parameters
op- long op

Definition at line 248 of file sys.c.

References bitvector_binop_internal(), call_primitive(), NARGS, REQUIRED, SETARG, and sys_bitvector.

249 {
250  psi_arg args[2];
251  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
252  SETARG(args,1, "2" , sys_bitvector , REQUIRED );
253  return call_primitive(bitvector_binop_internal,NARGS(args),args,(GENERIC)op);
254 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
static long bitvector_binop_internal(ptr_psi_term *args, ptr_psi_term result, ptr_psi_term funct, GENERIC op)
bitvector_binop_internal
Definition: sys.c:235
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
static long bitvector_binop_code ( unsigned long *  bv1,
unsigned long *  bv2,
ptr_psi_term  result,
GENERIC  op 
)
static

bitvector_binop_code

Parameters
bv1- unsigned long *bv1
bv2- unsigned long *bv2
result- ptr_psi_term result
op- GENERIC op changed to GENERIC 2.16 no effect DJD

Definition at line 194 of file sys.c.

References BV_AND, BV_OR, BV_XOR, c_abort(), make_bytedata(), NULL, push_goal(), sys_bitvector, TRUE, unify, and wl_psi_term::value_3.

195 {
196  unsigned long size1 = *bv1;
197  unsigned long size2 = *bv2;
198  unsigned long size3 = (size1>size2)?size1:size2;
199  ptr_psi_term temp_result = make_bytedata(sys_bitvector,size3);
200  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
201  unsigned char *s2 = ((unsigned char*)bv2)+sizeof(size2);
202  unsigned char *s3 = ((unsigned char *) temp_result->value_3) + sizeof(size3);
203  unsigned long i;
204  switch ((long)op) { // added cast DJD 2.16
205  case BV_AND:
206  for(i=0;i<size3;i++) s3[i] = s1[i] & s2[i];
207  if (size1<size2) for(;i<size2;i++) s3[i] = 0;
208  else for(;i<size1;i++) s3[i] = 0;
209  break;
210  case BV_OR:
211  for(i=0;i<size3;i++) s3[i] = s1[i] | s2[i];
212  if (size1<size2) for(;i<size2;i++) s3[i] = s2[i];
213  else for(;i<size1;i++) s3[i] = s1[i];
214  break;
215  case BV_XOR:
216  for(i=0;i<size3;i++) s3[i] = s1[i] ^ s2[i];
217  if (size1<size2) for(;i<size2;i++) s3[i] = (unsigned char) 0 ^ s2[i];
218  else for(;i<size1;i++) s3[i] = s1[i] ^ (unsigned char) 0;
219  break;
220  default: return (c_abort());
221  }
222  push_goal(unify,temp_result,result,NULL);
223  return TRUE;
224 }
#define BV_OR
Definition: sys.c:182
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define BV_XOR
Definition: sys.c:183
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
long c_abort()
c_abort
Definition: built_ins.c:2247
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define BV_AND
Definition: sys.c:181
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
static long bitvector_binop_internal ( ptr_psi_term args,
ptr_psi_term  result,
ptr_psi_term  funct,
GENERIC  op 
)
static

bitvector_binop_internal

Parameters
args- ptr_psi_term *args
result- ptr_psi_term result
funct- ptr_psi_term funct
op- GENERIC op changed to GENERIC 2.16 DJD

BITVECTOR_BINOP

Definition at line 235 of file sys.c.

References bitvector_binop_code().

236 {
237  return bitvector_binop_code((unsigned long *)args[0]->value_3,
238  (unsigned long *)args[1]->value_3,
239  result,(GENERIC)op);
240 }
static long bitvector_binop_code(unsigned long *bv1, unsigned long *bv2, ptr_psi_term result, GENERIC op)
bitvector_binop_code
Definition: sys.c:194
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
static long bitvector_bit ( long  op)
static

bitvector_bit

Parameters
op- long op

Definition at line 449 of file sys.c.

References bitvector_bit_internal(), call_primitive(), integer, NARGS, REQUIRED, SETARG, and sys_bitvector.

450 {
451  psi_arg args[2];
452  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
453  SETARG(args,1, "2" , integer , REQUIRED );
454  return call_primitive(bitvector_bit_internal,NARGS(args),args,(GENERIC)op);
455 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long bitvector_bit_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, int op)
bitvector_bit_internal
Definition: sys.c:436
#define NARGS(args)
Definition: def_macro.h:174
static long bitvector_bit_code ( unsigned long *  bv1,
long  idx,
ptr_psi_term  result,
int  op,
ptr_psi_term  funct 
)
static

bitvector_bit_code

Parameters
bv1- unsigned long *bv1
idx- long idx
result- ptr_psi_term result
op- int op
funct- ptr_psi_term funct

Definition at line 395 of file sys.c.

References BV_CLEAR, BV_GET, BV_SET, Errorline(), FALSE, make_bytedata(), NULL, push_goal(), REAL, sys_bitvector, TRUE, unify, unify_real_result(), and wl_psi_term::value_3.

396 {
397  unsigned long size1 = *bv1;
398  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
399  unsigned long i = idx / sizeof(char);
400  int j = idx % sizeof(char);
401  ptr_psi_term temp_result;
402  unsigned char *s2;
403  if (idx<0 || idx>=size1) {
404  Errorline("Index out of bound in %P.\n",funct);
405  return FALSE; }
406  switch (op) {
407  case BV_GET:
408  return unify_real_result(result,(REAL)((s1[i] & (1<<j))?1:0));
409  break;
410  case BV_SET:
411  temp_result = make_bytedata(sys_bitvector,size1);
412  s2 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
413  bcopy(s1,s2,size1);
414  s2[i] |= 1<<j;
415  break;
416  case BV_CLEAR:
417  temp_result = make_bytedata(sys_bitvector,size1);
418  s2 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
419  bcopy(s1,s2,size1);
420  s2[i] &= ~ (1<<j);
421  break;
422  }
423  push_goal(unify,temp_result,result,NULL);
424  return TRUE;
425 }
#define BV_CLEAR
Definition: sys.c:383
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define BV_SET
Definition: sys.c:382
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define BV_GET
Definition: sys.c:381
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
static long bitvector_bit_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct,
int  op 
)
static

bitvector_bit_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct
op- int op 12/10/2016 changed from GENERIC to int 2.29 DJD

Definition at line 436 of file sys.c.

References bitvector_bit_code(), and REAL.

437 {
438  return bitvector_bit_code((unsigned long *)args[0]->value_3,
439  (long)*((REAL*)args[1]->value_3),
440  result,op,funct);
441 }
static long bitvector_bit_code(unsigned long *bv1, long idx, ptr_psi_term result, int op, ptr_psi_term funct)
bitvector_bit_code
Definition: sys.c:395
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
static long bitvector_unop ( GENERIC  op)
static

bitvector_unop

Parameters
op- GENERIC op 12/10/2016 changed from long to GENERIC (2.29) DJD

Definition at line 354 of file sys.c.

References bitvector_unop_internal(), call_primitive(), NARGS, REQUIRED, SETARG, and sys_bitvector.

355 {
356  psi_arg args[1];
357  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
358  return call_primitive(bitvector_unop_internal,NARGS(args),args,op);
359 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long bitvector_unop_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, int op)
bitvector_unop_internal
Definition: sys.c:343
#define NARGS(args)
Definition: def_macro.h:174
static long bitvector_unop_code ( unsigned long *  bv1,
ptr_psi_term  result,
int  op 
)
static

bitvector_unop_code

Parameters
bv1- unsigned long *bv1
result- ptr_psi_term result
op- int op

Definition at line 297 of file sys.c.

References BV_COUNT, BV_NOT, c_abort(), make_bytedata(), NULL, push_goal(), REAL, sys_bitvector, TRUE, unify, unify_real_result(), and wl_psi_term::value_3.

298 {
299  unsigned long size1 = *bv1;
300  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
301  unsigned long i;
302  ptr_psi_term temp_result;
303  unsigned char *s3;
304  switch (op) {
305  case BV_NOT:
306  temp_result = make_bytedata(sys_bitvector,size1);
307  s3 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
308  for(i=0;i<size1;i++) s3[i] = ~(s1[i]);
309  break;
310  case BV_COUNT:
311  {
312  int cnt = 0;
313  register unsigned char c;
314  for(i=0;i<size1;i++) {
315  c=s1[i];
316  if (c & 1<<0) cnt++;
317  if (c & 1<<1) cnt++;
318  if (c & 1<<2) cnt++;
319  if (c & 1<<3) cnt++;
320  if (c & 1<<4) cnt++;
321  if (c & 1<<5) cnt++;
322  if (c & 1<<6) cnt++;
323  if (c & 1<<7) cnt++; }
324  return unify_real_result(result,(REAL) cnt);
325  }
326  break;
327  default: return (c_abort());
328  }
329  push_goal(unify,temp_result,result,NULL);
330  return TRUE;
331 }
#define BV_NOT
Definition: sys.c:286
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
long c_abort()
c_abort
Definition: built_ins.c:2247
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
#define BV_COUNT
Definition: sys.c:287
static long bitvector_unop_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct,
int  op 
)
static

bitvector_unop_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct
op- int op 12/10/2016 changed from GENERIC to int (2.29) DJD

BITVECTOR_UNOP

Definition at line 343 of file sys.c.

References bitvector_unop_code().

344 {
345  return bitvector_unop_code((unsigned long *)args[0]->value_3,result, op);
346 }
static long bitvector_unop_code(unsigned long *bv1, ptr_psi_term result, int op)
bitvector_unop_code
Definition: sys.c:297
static long c_accept ( )
static

c_accept

Definition at line 1503 of file sys.c.

References accept_internal(), call_primitive(), NARGS, REQUIRED, SETARG, and sys_socket_stream.

1504 {
1505  psi_arg args[1];
1506  SETARG(args,0,"1",sys_socket_stream,REQUIRED);
1507  return call_primitive(accept_internal,NARGS(args),args,0);
1508 }
static long accept_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
accept_internal
Definition: sys.c:1476
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
static long c_apply1 ( )
static

c_apply1()

Definition at line 2130 of file sys.c.

References apply1_internal(), call_primitive(), NARGS, NOVALUE, REQUIRED, SETARG, and top.

2131 {
2132  psi_arg args[3];
2133  SETARG(args,0,"1",top,REQUIRED|NOVALUE);
2134  SETARG(args,1,"2",top,REQUIRED|NOVALUE);
2135  SETARG(args,2,"3",top,REQUIRED|NOVALUE);
2136  return call_primitive(apply1_internal,NARGS(args),args,0);
2137 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
static long apply1_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
apply1_internal
Definition: sys.c:2099
static long c_bind ( )
static

c_bind

Definition at line 1419 of file sys.c.

References bind_or_connect_internal(), call_primitive(), integer, MANDATORY, NARGS, NULL, OPTIONAL, quoted_string, SETARG, and sys_socket_stream.

1420 {
1421  psi_arg args[4];
1422  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1423  SETARG(args,1,"host",quoted_string,OPTIONAL);
1424  SETARG(args,2,"port",integer,OPTIONAL);
1425  SETARG(args,3,"path",quoted_string,OPTIONAL);
1427 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long bind_or_connect_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, void *info)
bind_or_connect_internal
Definition: sys.c:1351
#define NULL
Definition: def_const.h:533
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_bitvector_and ( )
static

c_bitvector_and

Definition at line 261 of file sys.c.

References bitvector_binop(), and BV_AND.

262 {
263  return bitvector_binop(BV_AND);
264 }
static long bitvector_binop(long op)
bitvector_binop
Definition: sys.c:248
#define BV_AND
Definition: sys.c:181
static long c_bitvector_clear ( )
static

c_bitvector_clear

Definition at line 482 of file sys.c.

References bitvector_bit(), and BV_CLEAR.

483 {
484  return bitvector_bit(BV_CLEAR);
485 }
#define BV_CLEAR
Definition: sys.c:383
static long bitvector_bit(long op)
bitvector_bit
Definition: sys.c:449
static long c_bitvector_count ( )
static

c_bitvector_count

Definition at line 376 of file sys.c.

References bitvector_unop(), and BV_COUNT.

377 {
378  return bitvector_unop((GENERIC)BV_COUNT); // cast added 12/10/2016 DJD 2.29
379 }
static long bitvector_unop(GENERIC op)
bitvector_unop
Definition: sys.c:354
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define BV_COUNT
Definition: sys.c:287
static long c_bitvector_get ( )
static

c_bitvector_get

Definition at line 462 of file sys.c.

References bitvector_bit(), and BV_GET.

463 {
464  return bitvector_bit(BV_GET);
465 }
static long bitvector_bit(long op)
bitvector_bit
Definition: sys.c:449
#define BV_GET
Definition: sys.c:381
static long c_bitvector_not ( )
static

c_bitvector_not

Definition at line 366 of file sys.c.

References bitvector_unop(), and BV_NOT.

367 {
368  return bitvector_unop((GENERIC)BV_NOT); // cast added 12/10/2016 DJD 2.29
369 }
#define BV_NOT
Definition: sys.c:286
static long bitvector_unop(GENERIC op)
bitvector_unop
Definition: sys.c:354
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
static long c_bitvector_or ( )
static

c_bitvector_or

Definition at line 271 of file sys.c.

References bitvector_binop(), and BV_OR.

272 {
273  return bitvector_binop(BV_OR);
274 }
#define BV_OR
Definition: sys.c:182
static long bitvector_binop(long op)
bitvector_binop
Definition: sys.c:248
static long c_bitvector_set ( )
static

c_bitvector_set

Definition at line 472 of file sys.c.

References bitvector_bit(), and BV_SET.

473 {
474  return bitvector_bit(BV_SET);
475 }
#define BV_SET
Definition: sys.c:382
static long bitvector_bit(long op)
bitvector_bit
Definition: sys.c:449
static long c_bitvector_xor ( )
static

c_bitvector_xor

Definition at line 281 of file sys.c.

References bitvector_binop(), and BV_XOR.

282 {
283  return bitvector_binop(BV_XOR);
284 }
#define BV_XOR
Definition: sys.c:183
static long bitvector_binop(long op)
bitvector_binop
Definition: sys.c:248
static long c_call_once ( )
static

c_call_once

Definition at line 2084 of file sys.c.

References call_once_internal(), call_primitive(), MANDATORY, NARGS, NOVALUE, SETARG, top, and UNEVALED.

2085 {
2086  psi_arg args[1];
2087  SETARG(args,0,"1",top,MANDATORY|NOVALUE|UNEVALED);
2088  return call_primitive(call_once_internal,NARGS(args),args,0);
2089 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long call_once_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
call_once_internal
Definition: sys.c:2063
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
#define UNEVALED
for call_primitive
Definition: def_const.h:678
static long c_connect ( )
static

c_connect

Definition at line 1434 of file sys.c.

References bind_or_connect_internal(), call_primitive(), integer, MANDATORY, NARGS, OPTIONAL, quoted_string, SETARG, and sys_socket_stream.

1435 {
1436  psi_arg args[4];
1437  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1438  SETARG(args,1,"host",quoted_string,OPTIONAL);
1439  SETARG(args,2,"port",integer,OPTIONAL);
1440  SETARG(args,3,"path",quoted_string,OPTIONAL);
1441  return call_primitive(bind_or_connect_internal,NARGS(args),args,(GENERIC)1);
1442 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long bind_or_connect_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct, void *info)
bind_or_connect_internal
Definition: sys.c:1351
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_cuserid ( )
static

c_cuserid

Definition at line 1869 of file sys.c.

References call_primitive(), cuserid_internal(), and NULL.

1870 {
1871  return call_primitive(cuserid_internal,0,NULL,0);
1872 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define NULL
Definition: def_const.h:533
static long cuserid_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
cuserid_internal
Definition: sys.c:1854
static long c_errmsg ( )
static

c_errmsg

Definition at line 1564 of file sys.c.

References call_primitive(), errmsg_internal(), integer, NARGS, OPTIONAL, and SETARG.

1565 {
1566  psi_arg args[1];
1567  SETARG(args,0, "1" , integer , OPTIONAL );
1568  return call_primitive(errmsg_internal,NARGS(args),args,0);
1569 }
static long errmsg_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
errmsg_internal
Definition: sys.c:1549
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
static long c_errno ( )
static

c_errno

Definition at line 1532 of file sys.c.

References call_primitive(), errno_internal(), and NULL.

1533 {
1534  return call_primitive(errno_internal,0,NULL,0);
1535 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define NULL
Definition: def_const.h:533
static long errno_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
errno_internal
Definition: sys.c:1521
static long c_fclose ( )
static

c_fclose

Definition at line 787 of file sys.c.

References call_primitive(), fclose_internal(), NARGS, REQUIRED, SETARG, and sys_stream.

788 {
789  psi_arg args[1];
790  SETARG(args,0, "1" , sys_stream , REQUIRED );
791  return call_primitive(fclose_internal,NARGS(args),args,0);
792 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long fclose_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
fclose_internal
Definition: sys.c:774
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
static long c_fflush ( )
static

c_fflush

Definition at line 849 of file sys.c.

References call_primitive(), fflush_internal(), MANDATORY, NARGS, SETARG, and sys_stream.

850 {
851  psi_arg args[1];
852  SETARG(args,0,"1",sys_stream,MANDATORY);
853  return call_primitive(fflush_internal,NARGS(args),args,0);
854 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
#define MANDATORY
for call_primitive
Definition: def_const.h:818
static long fflush_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
fflush_internal
Definition: sys.c:835
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define NARGS(args)
Definition: def_macro.h:174
static long c_fopen ( )
static

c_fopen

Definition at line 758 of file sys.c.

References call_primitive(), fopen_internal(), NARGS, quoted_string, REQUIRED, and SETARG.

759 {
760  psi_arg args[2];
761  SETARG(args,0, "1" , quoted_string , REQUIRED );
762  SETARG(args,1, "2" , quoted_string , REQUIRED );
763  return call_primitive(fopen_internal,NARGS(args),args,0);
764 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long fopen_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
fopen_internal
Definition: sys.c:739
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_fork ( )
static

c_fork

Definition at line 1655 of file sys.c.

References call_primitive(), fork_internal(), and NULL.

1656 {
1657  return call_primitive(fork_internal,0,NULL,0);
1658 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
static long fork_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
Definition: sys.c:1643
#define NULL
Definition: def_const.h:533
static long c_fseek ( )
static

c_fseek

Definition at line 1185 of file sys.c.

References call_primitive(), fseek_internal(), integer, MANDATORY, NARGS, OPTIONAL, SETARG, and sys_file_stream.

1186 {
1187  psi_arg args[3];
1188  SETARG(args,0,"1",sys_file_stream,MANDATORY);
1189  SETARG(args,1,"2",integer,MANDATORY);
1190  SETARG(args,2,"3",integer,OPTIONAL);
1191  return call_primitive(fseek_internal,NARGS(args),args,0);
1192 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
static long fseek_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
fseek_internal
Definition: sys.c:1169
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
static long c_ftell ( )
static

c_ftell

Definition at line 1144 of file sys.c.

References call_primitive(), ftell_internal(), NARGS, REQUIRED, SETARG, and sys_file_stream.

1145 {
1146  psi_arg args[1];
1147  SETARG(args,0,"1",sys_file_stream,REQUIRED);
1148  return call_primitive(ftell_internal,NARGS(args),args,0);
1149 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long ftell_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
ftell_internal
Definition: sys.c:1128
#define NARGS(args)
Definition: def_macro.h:174
static long c_fwrite ( )
static

c_fwrite

Definition at line 819 of file sys.c.

References call_primitive(), fwrite_internal(), MANDATORY, NARGS, quoted_string, SETARG, and sys_stream.

820 {
821  psi_arg args[2];
822  SETARG(args,0,"1",sys_stream,MANDATORY);
823  SETARG(args,1,"2",quoted_string,MANDATORY);
824  return call_primitive(fwrite_internal,NARGS(args),args,0);
825 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
#define MANDATORY
for call_primitive
Definition: def_const.h:818
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
static long fwrite_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
fwrite_internal
Definition: sys.c:802
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_get_buffer ( )
static

c_get_buffer

Definition at line 885 of file sys.c.

References call_primitive(), get_buffer_internal(), integer, NARGS, REQUIRED, SETARG, and sys_stream.

886 {
887  psi_arg args[2];
888  SETARG(args,0,"1",sys_stream,REQUIRED);
889  SETARG(args,1,"2",integer,REQUIRED);
890  return call_primitive(get_buffer_internal,NARGS(args),args,0);
891 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long get_buffer_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
get_buffer_internal
Definition: sys.c:864
#define NARGS(args)
Definition: def_macro.h:174
static long c_get_code ( )
static

c_get_code

Definition at line 1113 of file sys.c.

References call_primitive(), get_code_internal(), NARGS, REQUIRED, SETARG, and sys_stream.

1114 {
1115  psi_arg args[1];
1116  SETARG(args,0,"1",sys_stream,REQUIRED);
1117  return call_primitive(get_code_internal,NARGS(args),args,0);
1118 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long get_code_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
get_code_internal
Definition: sys.c:1099
#define NARGS(args)
Definition: def_macro.h:174
static long c_get_record ( )
static

c_get_record

Definition at line 1083 of file sys.c.

References call_primitive(), get_record_internal(), NARGS, quoted_string, REQUIRED, SETARG, and sys_stream.

1084 {
1085  psi_arg args[2];
1086  SETARG(args,0,"1",sys_stream,REQUIRED);
1087  SETARG(args,1,"2",quoted_string,REQUIRED);
1088  return call_primitive(get_record_internal,NARGS(args),args,0);
1089 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long get_record_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
get_record_internal
Definition: sys.c:1004
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_gethostname ( )
static

c_gethostname

Definition at line 1901 of file sys.c.

References call_primitive(), gethostname_internal(), and NULL.

1902 {
1904 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define NULL
Definition: def_const.h:533
static long gethostname_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
gethostname_internal
Definition: sys.c:1886
static long c_getpid ( )
static

c_getpid

Definition at line 2157 of file sys.c.

References call_primitive(), and getpid_internal().

2158 {
2159  return call_primitive(getpid_internal,0,0,0);
2160 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
static long getpid_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
getpid_internal
Definition: sys.c:2147
static long c_import_symbol ( )
static

c_import_symbol

C_IMPORT_SYMBOL import a public symbol from another module into the current one, optionally renaming it.

Definition at line 1624 of file sys.c.

References call_primitive(), import_symbol_internal(), MANDATORY, NARGS, NOVALUE, OPTIONAL, SETARG, top, and UNEVALED.

1625 {
1626  psi_arg args[2];
1627  SETARG(args,0,"1",top,MANDATORY|UNEVALED);
1628  SETARG(args,1,"as",top,OPTIONAL|NOVALUE|UNEVALED);
1629  return call_primitive(import_symbol_internal,NARGS(args),args,0);
1630 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long import_symbol_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
import_symbol_internal
Definition: sys.c:1582
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
#define UNEVALED
for call_primitive
Definition: def_const.h:678
static long c_int2stream ( )
static

c_int2stream

Definition at line 723 of file sys.c.

References call_primitive(), int2stream_internal(), integer, NARGS, quoted_string, REQUIRED, and SETARG.

724 {
725  psi_arg args[2];
726  SETARG(args,0,"1",integer,REQUIRED);
727  SETARG(args,1,"2",quoted_string,REQUIRED);
728  return call_primitive(int2stream_internal,NARGS(args),args,0);
729 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long int2stream_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
int2stream_internal
Definition: sys.c:704
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_kill ( )
static

c_kill

Definition at line 1835 of file sys.c.

References call_primitive(), integer, kill_internal(), MANDATORY, NARGS, and SETARG.

1836 {
1837  psi_arg args[2];
1838  SETARG(args,0,"1",integer,MANDATORY);
1839  SETARG(args,1,"2",integer,MANDATORY);
1840  return call_primitive(kill_internal,NARGS(args),args,0);
1841 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long kill_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
kill_internal
Definition: sys.c:1824
#define NARGS(args)
Definition: def_macro.h:174
static long c_lazy_project ( )
static

c_lazy_project

Definition at line 1947 of file sys.c.

References call_primitive(), lazy_project_internal(), NARGS, NOVALUE, REQUIRED, SETARG, and top.

1948 {
1949  psi_arg args[2];
1950  SETARG(args,0,"1",top,REQUIRED|NOVALUE);
1951  SETARG(args,1,"2",top,REQUIRED|NOVALUE);
1952  return call_primitive(lazy_project_internal,NARGS(args),args,0);
1953 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
static long lazy_project_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
lazy_project_internal
Definition: sys.c:1917
static long c_listen ( )
static

c_listen

Definition at line 1460 of file sys.c.

References call_primitive(), integer, listen_internal(), MANDATORY, NARGS, SETARG, and sys_socket_stream.

1461 {
1462  psi_arg args[2];
1463  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1464  SETARG(args,1,"2",integer,MANDATORY);
1465  return call_primitive(listen_internal,NARGS(args),args,0);
1466 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
static long listen_internal(args, result, funct)
Definition: sys.c:1445
static long c_make_bitvector ( )
static

c_make_bitvector

Definition at line 174 of file sys.c.

References call_primitive(), integer, make_bitvector_internal(), NARGS, REQUIRED, and SETARG.

175 {
176  psi_arg args[1];
177  SETARG(args,0, "1" , integer , REQUIRED );
178  return call_primitive(make_bitvector_internal,NARGS(args),args,0);
179 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long make_bitvector_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
make_bitvector_internal
Definition: sys.c:154
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
static long c_my_wait_on_feature ( )
static

c_my_wait_on_feature

Definition at line 2043 of file sys.c.

References call_primitive(), MANDATORY, my_wait_on_feature_internal(), NARGS, NOVALUE, SETARG, top, and UNEVALED.

2044 {
2045  psi_arg args[3];
2046  SETARG(args,0,"1",top,MANDATORY|NOVALUE);
2047  SETARG(args,1,"2",top,MANDATORY|NOVALUE);
2048  SETARG(args,2,"3",top,MANDATORY|NOVALUE|UNEVALED);
2049  return call_primitive(my_wait_on_feature_internal,NARGS(args),args,0);
2050 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
static long my_wait_on_feature_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
my_wait_on_feature_internal
Definition: sys.c:2012
#define UNEVALED
for call_primitive
Definition: def_const.h:678
static long c_regexp_compile ( )
static

c_regexp_compile

Definition at line 554 of file sys.c.

References call_primitive(), NARGS, quoted_string, regexp_compile_internal(), REQUIRED, and SETARG.

555 {
556  psi_arg args[1];
557  SETARG(args,0, "1" , quoted_string , REQUIRED );
558  return call_primitive(regexp_compile_internal,NARGS(args),args,0);
559 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long regexp_compile_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
regexp_compile_internal
Definition: sys.c:514
#define NARGS(args)
Definition: def_macro.h:174
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_regexp_execute ( )
static

c_regexp_execute

Definition at line 648 of file sys.c.

References call_primitive(), integer, NARGS, NOVALUE, OPTIONAL, quoted_string, regexp_execute_internal(), REQUIRED, SETARG, sys_regexp, and top.

649 {
650  psi_arg args[4];
651  SETARG(args,0, "1" , sys_regexp , REQUIRED );
652  SETARG(args,1, "2" , quoted_string , REQUIRED );
653  SETARG(args,2, "3" , top , OPTIONAL|NOVALUE );
654  SETARG(args,3, "offset" , integer , OPTIONAL );
655  return call_primitive(regexp_execute_internal,NARGS(args),args,0);
656 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long regexp_execute_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
regexp_execute_internal
Definition: sys.c:576
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
#define REQUIRED
for call_primitive
Definition: def_const.h:631
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_socket ( )
static

c_socket

Definition at line 1319 of file sys.c.

References call_primitive(), NARGS, OPTIONAL, quoted_string, SETARG, and socket_internal().

1320 {
1321  psi_arg args[2];
1322  SETARG(args,0,"1",quoted_string,OPTIONAL);
1323  SETARG(args,1,"2",quoted_string,OPTIONAL);
1324  return call_primitive(socket_internal,NARGS(args),args,0);
1325 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long socket_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
socket_internal
Definition: sys.c:1269
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long c_stream2sys_stream ( )
static

c_stream2sys_stream

Definition at line 1214 of file sys.c.

References call_primitive(), NARGS, REQUIRED, SETARG, stream, and stream2sys_stream_internal().

1215 {
1216  psi_arg args[1];
1217  SETARG(args,0,"1",stream,REQUIRED);
1218  return call_primitive(stream2sys_stream_internal,NARGS(args),args,0);
1219 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
static long stream2sys_stream_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
stream2sys_stream_internal
Definition: sys.c:1202
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
static long c_sys_stream2stream ( )
static

c_sys_stream2stream

Definition at line 1244 of file sys.c.

References call_primitive(), NARGS, REQUIRED, SETARG, sys_stream, and sys_stream2stream_internal().

1245 {
1246  psi_arg args[1];
1247  SETARG(args,0,"1",sys_stream,REQUIRED);
1248  return call_primitive(sys_stream2stream_internal,NARGS(args),args,0);
1249 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
#define REQUIRED
for call_primitive
Definition: def_const.h:631
static long sys_stream2stream_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
sys_stream2stream_internal
Definition: sys.c:1229
#define NARGS(args)
Definition: def_macro.h:174
static long c_wait ( )
static

c_wait

Definition at line 1782 of file sys.c.

References call_primitive(), NULL, and wait_internal().

1783 {
1784  return call_primitive(wait_internal,0,NULL,0);
1785 }
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define NULL
Definition: def_const.h:533
static long wait_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
wait_internal
Definition: sys.c:1770
static long c_wait_on_feature ( )
static

c_wait_on_feature

Definition at line 1995 of file sys.c.

References call_primitive(), MANDATORY, NARGS, NOVALUE, SETARG, top, UNEVALED, and wait_on_feature_internal().

1996 {
1997  psi_arg args[3];
1998  SETARG(args,0,"1",top,MANDATORY|NOVALUE);
1999  SETARG(args,1,"2",top,MANDATORY|NOVALUE);
2000  SETARG(args,2,"3",top,MANDATORY|NOVALUE|UNEVALED);
2001  return call_primitive(wait_on_feature_internal,NARGS(args),args,0);
2002 }
#define MANDATORY
for call_primitive
Definition: def_const.h:818
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
#define NOVALUE
for call_primitive
Definition: def_const.h:865
static long wait_on_feature_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
wait_on_feature_internal
Definition: sys.c:1966
#define NARGS(args)
Definition: def_macro.h:174
#define UNEVALED
for call_primitive
Definition: def_const.h:678
static long c_waitpid ( )
static

c_waitpid

Definition at line 1808 of file sys.c.

References call_primitive(), integer, NARGS, OPTIONAL, REQUIRED, SETARG, and waitpid_internal().

1809 {
1810  psi_arg args[2];
1811  SETARG(args,0,"1",integer,REQUIRED);
1812  SETARG(args,1,"2",integer,OPTIONAL);
1813  return call_primitive(waitpid_internal,NARGS(args),args,0);
1814 }
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
long call_primitive(long(*fun)(), int num, psi_arg argi[], GENERIC info)
call_primitive
Definition: sys.c:24
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:168
static long waitpid_internal(ptr_psi_term args[], ptr_psi_term result, ptr_psi_term funct)
waitpid_internal
Definition: sys.c:1795
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define NARGS(args)
Definition: def_macro.h:174
#define OPTIONAL
for call_primitive
Definition: def_const.h:584
static long call_once_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

call_once_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

CALL_ONCE

call_once(G) -> T | G,!,T=lf_true;T=lf_false.

Definition at line 2063 of file sys.c.

References choice_stack, DEFRULES, general_cut, lf_false, lf_true, NULL, prove, push_choice_point(), push_goal(), resid_aim, stack_psi_term(), TRUE, wl_psi_term::type, and unify.

2064 {
2065  ptr_psi_term value;
2067  resid_aim=NULL;
2068  value = stack_psi_term(4);
2069  value->type = lf_false;
2070  push_choice_point(unify,result,value,NULL);
2071  value = stack_psi_term(4);
2072  value->type = lf_true;
2073  push_goal(unify,result,value,NULL);
2076  return TRUE;
2077 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
ptr_definition lf_false
symbol in bi module
Definition: def_glob.h:284
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_choice_point
Definition: login.c:638
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define general_cut
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1114
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
ptr_goal resid_aim
Definition: def_glob.h:865
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition lf_true
symbol in bi module
Definition: def_glob.h:410
ptr_definition type
Definition: def_struct.h:181
ptr_choice_point choice_stack
Definition: def_glob.h:1026
long call_primitive ( long(*)()  fun,
int  num,
psi_arg  argi[],
GENERIC  info 
)

call_primitive

Parameters
fun- (long (*fun)(),
num- int num
argi- psi_arg argi[]
info- GENERIC info

Definition at line 24 of file sys.c.

References wl_goal::aaaa_1, aim, ARGNN, wl_psi_term::attr_list, wl_goal::bbbb_1, c_abort(), curry(), wl_node::data, deref, deref_ptr, Errorline(), FALSE, FEATCMP, find(), JUSTFAIL, MANDATORY, NOVALUE, NULL, overlap_type(), POLYTYPE, REQUIRED, residuate(), sub_type(), TRUE, wl_psi_term::type, psi_arg::type, UNEVALED, and wl_psi_term::value_3.

25 {
26  ptr_psi_term funct,arg,result,argo[ARGNN]; /* no more than 10 arguments */
27  ptr_node n;
28  int allargs=1,allvalues=1,i;
29  funct=aim->aaaa_1;
30  deref_ptr(funct);
31  result=aim->bbbb_1;
32  for (i=0;i<num;i++) {
33  n=find(FEATCMP,argi[i].feature,funct->attr_list);
34  /* argument present */
35  if (n) {
36  arg = (ptr_psi_term) n->data;
37  /* in case we don't want to evaluate the argument
38  just follow the chain of corefs and don't do
39  any of the other checks: they'll have do be done
40  by fun; just go on to the next arg */
41  if (argi[i].options&UNEVALED) {
42  deref_ptr(arg);
43  argo[i]=arg;
44  continue; }
45  /* this arg should be evaled */
46  deref(arg);
47  argo[i]=arg;
48  /* arg of admissible type */
49  if (argi[i].options&POLYTYPE) {
50  ptr_definition *type = (ptr_definition *)argi[i].type;
51  while (*type != NULL)
52  if (overlap_type(arg->type,*type))
53  goto admissible;
54  else type++;
55  }
56  else {
57  if (overlap_type(arg->type,argi[i].type))
58  goto admissible;
59  }
60  /* not admissible */
61  if (argi[i].options&JUSTFAIL) return FALSE;
62  Errorline("Illegal argument in %P.\n",funct);
63  return (c_abort());
64  /* admissible */
65  admissible:
66  /* has value */
67  if (arg->value_3) {
68  ptr_definition *type = (ptr_definition *)argi[i].type;
69  /* paranoid check: really correct type */
70  if (argi[i].options&POLYTYPE) {
71  while (*type != NULL)
72  if (sub_type(arg->type,*type))
73  goto correct;
74  else type++;
75  }
76  else {
77  if (sub_type(arg->type,(ptr_definition)type)) goto correct;
78  }
79  /* type incorrect */
80  if (argi[i].options&JUSTFAIL) return FALSE;
81  Errorline("Illegal argument in %P.\n",funct);
82  return (c_abort());
83  /* correct */
84  correct:;
85  }
86  /* missing value - do we need it */
87  else if (!(argi[i].options&NOVALUE)) allvalues=0;
88  }
89  /* argument missing */
90  else {
91  argo[i]=NULL;
92  if (argi[i].options&MANDATORY) {
93  Errorline("Missing argument '%s' in %P.\n",argi[i].feature,funct);
94  return (c_abort());
95  }
96  else if (argi[i].options&REQUIRED) allargs=0;
97  }
98  }
99  if (allargs)
100  if (allvalues) {
101  return fun(argo,result,funct,info);
102  }
103  else {
104  for (i=0;i<num;i++) {
105  /* if arg present and should be evaled but has no value */
106  if (argo[i] && !(argi[i].options&UNEVALED) && !argo[i]->value_3)
107  residuate(argo[i]);
108  }
109  }
110  else curry();
111  return TRUE;
112 }
ptr_psi_term aaaa_1
Definition: def_struct.h:239
#define MANDATORY
for call_primitive
Definition: def_const.h:818
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
long c_abort()
c_abort
Definition: built_ins.c:2247
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
void curry()
curry
Definition: lefun.c:174
#define NULL
Definition: def_const.h:533
long overlap_type(ptr_definition t1, ptr_definition t2)
overlap_type
Definition: types.c:1579
#define JUSTFAIL
for call_primitive
Definition: def_const.h:725
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define deref_ptr(P)
Definition: def_macro.h:100
ptr_definition type
Definition: def_struct.h:365
#define REQUIRED
for call_primitive
Definition: def_const.h:631
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define deref(P)
Definition: def_macro.h:147
GENERIC value_3
Definition: def_struct.h:186
ptr_goal aim
Definition: def_glob.h:1024
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
#define NOVALUE
for call_primitive
Definition: def_const.h:865
ptr_definition type
Definition: def_struct.h:181
ptr_psi_term bbbb_1
Definition: def_struct.h:240
ptr_node attr_list
Definition: def_struct.h:187
#define ARGNN
primitive in sys.c does not allow more than ARGNN (10) arguments
Definition: def_const.h:1387
#define POLYTYPE
for call_primitive
Definition: def_const.h:772
#define UNEVALED
for call_primitive
Definition: def_const.h:678
void check_sys_definitions ( )

check_sys_definitions

Definition at line 2186 of file sys.c.

References check_definition(), sys_bitvector, sys_bytedata, sys_file_stream, sys_process_continued, sys_process_exited, sys_process_no_children, sys_process_signaled, sys_process_stopped, sys_regexp, sys_socket_stream, and sys_stream.

2187 {
2188  check_definition(&sys_bytedata); /* DENYS: BYTEDATA */
2199 #ifdef LIFE_NDBM
2200  check_ndbm_definitions();
2201 #endif
2202 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
ptr_definition sys_process_continued
symbol in sys module
Definition: def_glob.h:650
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
ptr_definition sys_process_no_children
symbol in sys module
Definition: def_glob.h:622
void check_definition(ptr_definition *d)
check_definition
Definition: memory.c:663
ptr_definition sys_process_signaled
symbol in sys module
Definition: def_glob.h:636
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
ptr_definition sys_process_exited
symbol in sys module
Definition: def_glob.h:629
ptr_definition sys_process_stopped
symbol in sys module
Definition: def_glob.h:643
static long cuserid_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

cuserid_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1854 of file sys.c.

References NULL, push_goal(), stack_string(), TRUE, and unify.

1855 {
1856  // char name[L_cuserid+1];
1857  // if (*cuserid(name) == '\0') return FALSE;
1858  // else {
1859  push_goal(unify,result,stack_string(getlogin()),NULL);
1860  return TRUE;
1861  // }
1862 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term stack_string(char *s)
stack_string
Definition: built_ins.c:109
static long errmsg_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

errmsg_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1549 of file sys.c.

References NULL, push_goal(), REAL, stack_string(), TRUE, unify, and wl_psi_term::value_3.

1550 {
1551  long n = args[0]?(long)*(REAL*)args[0]->value_3:errno;
1552  // if (n<0 || n>=sys_nerr) return FALSE;
1553  // else {
1554  push_goal(unify,stack_string(strerror(n)),result,NULL);
1555  return TRUE;
1556  // }
1557 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term stack_string(char *s)
stack_string
Definition: built_ins.c:109
static long errno_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

errno_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1521 of file sys.c.

References NULL, push_goal(), stack_int(), TRUE, and unify.

1522 {
1523  push_goal(unify,stack_int(errno),result,NULL);
1524  return TRUE;
1525 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_int(long n)
stack_int
Definition: built_ins.c:91
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static long fclose_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

fclose_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 774 of file sys.c.

References BYTEDATA_DATA, FALSE, and TRUE.

775 {
776  if (fclose(((ptr_stream)BYTEDATA_DATA(args[0]))->fp) != 0)
777  return FALSE;
778  else
779  return TRUE;
780 }
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
Definition: sys.c:672
static long fflush_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

fflush_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 835 of file sys.c.

References BYTEDATA_DATA, FALSE, a_stream::fp, FP_NONE, a_stream::op, and TRUE.

836 {
837  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
838  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
839  srm->op = FP_NONE;
840  if (fflush(srm->fp)!=0) return FALSE;
841  return TRUE;
842 }
FILE * fp
Definition: sys.c:673
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:668
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
Definition: sys.c:672
int op
Definition: sys.c:674
ptr_psi_term fileptr2stream ( FILE *  fp,
ptr_definition  typ 
)

fileptr2stream

Parameters
fp- FILE *fp
typ- ptr_definition typ removed * DJD = prior to 2.29

Definition at line 688 of file sys.c.

References BYTEDATA_DATA, FP_NONE, and make_bytedata().

689 {
690  ptr_psi_term result = make_bytedata(typ,sizeof(struct a_stream));
691  ((ptr_stream)BYTEDATA_DATA(result))->fp = fp;
692  ((ptr_stream)BYTEDATA_DATA(result))->op = FP_NONE;
693  return result;
694 }
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:668
#define BYTEDATA_DATA(X)
Definition: sys.c:139
Definition: sys.c:672
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
static long fopen_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

fopen_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 739 of file sys.c.

References FALSE, fileptr2stream(), NULL, push_goal(), sys_file_stream, TRUE, and unify.

740 {
741  FILE *fp = fopen((char*)args[0]->value_3,
742  (char*)args[1]->value_3);
743  if (fp==NULL) return FALSE;
744  else {
745  /* ptr_psi_term temp_result = make_bytedata(sys_file_stream,sizeof(fp));
746  *(FILE**)BYTEDATA_DATA(temp_result) = fp;
747  */
748  push_goal(unify,fileptr2stream(fp,sys_file_stream),result,NULL); // added & DJD
749  return TRUE;
750  }
751 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
fileptr2stream
Definition: sys.c:688
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static long fork_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

Definition at line 1643 of file sys.c.

References FALSE, REAL, and unify_real_result().

1644 {
1645  pid_t id = fork();
1646  if (id < 0) return FALSE;
1647  else return unify_real_result(result,(REAL)id);
1648 }
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define FALSE
Standard boolean.
Definition: def_const.h:275
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
static long fseek_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

fseek_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

(FILE**)BYTEDATA_DATA(args[0])

Definition at line 1169 of file sys.c.

References BYTEDATA_DATA, FALSE, a_stream::fp, FP_NONE, a_stream::op, REAL, SEEK_SET, TRUE, and wl_psi_term::value_3.

1170 {
1171  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
1172  srm->op = FP_NONE;
1173  return
1174  (fseek(srm->fp ,
1175  (long)*(REAL*)args[1]->value_3,
1176  args[2]?(long)*(REAL*)args[2]->value_3:SEEK_SET) < 0)
1177  ?FALSE:TRUE;
1178 }
FILE * fp
Definition: sys.c:673
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:668
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
GENERIC value_3
Definition: def_struct.h:186
Definition: sys.c:672
int op
Definition: sys.c:674
#define SEEK_SET
Definition: sys.c:1152
static long ftell_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

ftell_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1128 of file sys.c.

References BYTEDATA_DATA, a_stream::fp, FP_INPUT, FP_NONE, a_stream::op, REAL, and unify_real_result().

1129 {
1130  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
1131  if (srm->op != FP_NONE || srm->op != FP_INPUT) {
1132  fflush(srm->fp);
1133  srm->op = FP_NONE;
1134  }
1135  return unify_real_result(result,(REAL)ftell(srm->fp));
1136  /* *(FILE**)BYTEDATA_DATA(args[0])));*/
1137 }
FILE * fp
Definition: sys.c:673
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:668
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define FP_INPUT
Definition: sys.c:669
Definition: sys.c:672
int op
Definition: sys.c:674
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
static long fwrite_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

fwrite_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 802 of file sys.c.

References BYTEDATA_DATA, FALSE, a_stream::fp, FP_OUTPUT, FP_PREPARE, and TRUE.

803 {
804  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
805  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
806  char* txt = (char*)args[1]->value_3;
807  FP_PREPARE(srm,FP_OUTPUT);
808  if (txt && *txt!='\0' &&
809  fwrite((void*)txt,sizeof(char),strlen(txt),srm->fp)<=0)
810  return FALSE;
811  return TRUE;
812 }
FILE * fp
Definition: sys.c:673
#define FP_OUTPUT
Definition: sys.c:670
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
Definition: sys.c:672
#define FP_PREPARE(s, OP)
Definition: sys.c:677
static long get_buffer_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

get_buffer_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 864 of file sys.c.

References BYTEDATA_DATA, FALSE, a_stream::fp, FP_INPUT, FP_PREPARE, heap_alloc(), NULL, push_goal(), quoted_string, REAL, stack_psi_term(), TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

865 {
866  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
867  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
868  long size = *(REAL*)args[1]->value_3;
870  t->type = quoted_string;
871  t->value_3=(GENERIC)heap_alloc(size+1);
872  bzero((char*)t->value_3,size+1);
873  FP_PREPARE(srm,FP_INPUT);
874  if (fread((void*)t->value_3,sizeof(char),size,srm->fp) <= 0)
875  return FALSE;
876  push_goal(unify,t,result,NULL);
877  return TRUE;
878 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
FILE * fp
Definition: sys.c:673
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
struct a_stream * ptr_stream
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
#define FP_INPUT
Definition: sys.c:669
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
Definition: sys.c:672
#define FP_PREPARE(s, OP)
Definition: sys.c:677
ptr_definition type
Definition: def_struct.h:181
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
static long get_code_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

get_code_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1099 of file sys.c.

References BYTEDATA_DATA, FALSE, a_stream::fp, FP_INPUT, FP_PREPARE, REAL, and unify_real_result().

1100 {
1101  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
1102  int c;
1103  FP_PREPARE(srm,FP_INPUT);
1104  if ((c=getc(srm->fp)) == EOF) return FALSE;
1105  else return unify_real_result(result,(REAL)c);
1106 }
FILE * fp
Definition: sys.c:673
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define FP_INPUT
Definition: sys.c:669
Definition: sys.c:672
#define FP_PREPARE(s, OP)
Definition: sys.c:677
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
char * get_numeric_feature ( long  n)

get_numeric_feature

Parameters
n- long n

Definition at line 1698 of file sys.c.

References heap_copy_string(), one, three, and two.

1699 {
1700  if (n==1) return one;
1701  else if (n==2) return two;
1702  else if (n==3) return three;
1703  else {
1704  char buf[100];
1705  (void)snprintf(buf,100,"%ld",n);
1706  return heap_copy_string(buf);
1707  }
1708 }
char * two
Definition: def_glob.h:892
char * three
Definition: def_glob.h:893
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
char * one
Definition: def_glob.h:891
static long get_record_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

get_record_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1004 of file sys.c.

References BYTEDATA_DATA, text_buffer::data, a_stream::fp, FP_INPUT, FP_PREPARE, heap_alloc(), text_buffer::next, NULL, push_goal(), quoted_string, stack_psi_term(), text_buffer_cmp(), text_buffer_free(), text_buffer_next(), text_buffer_push(), text_buffer::top, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

1005 {
1006  struct text_buffer rootbuf;
1007  struct text_buffer *curbuf = &rootbuf;
1008  struct text_buffer *lastbuf = &rootbuf;
1009  int lastidx = 0,size;
1010  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
1011  FILE *fp = srm->fp; /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
1012  char *sep = (char*)args[1]->value_3;
1013  int c;
1014  ptr_psi_term t;
1015  char *cursep = sep;
1016 
1017  FP_PREPARE(srm,FP_INPUT);
1018  bzero((char*)&rootbuf,sizeof(rootbuf));
1019  if (!sep || !*sep) {
1020  /* no separator: just grab as much as you can */
1021  while ((c=getc(fp)) != EOF)
1022  text_buffer_push(&curbuf,(char)c);
1023  goto PackUpAndLeave;
1024  }
1025 
1026  if (sep[1]=='\0') {
1027  /* only one char in string */
1028  while ((c=getc(fp)) != EOF) {
1029  text_buffer_push(&curbuf,(char)c);
1030  if (c==*sep) break;
1031  }
1032  goto PackUpAndLeave;
1033  }
1034 
1035  /* general case: multicharacter separator */
1036 
1037  WaitForStart:
1038  if ((c=getc(fp)) == EOF) goto PackUpAndLeave;
1039  text_buffer_push(&curbuf,(char)c);
1040  if (c==*sep) {
1041  cursep = sep+1;
1042  lastbuf=curbuf;
1043  lastidx=curbuf->top - 1;
1044  goto MatchNext;
1045  }
1046  else goto WaitForStart;
1047 
1048  MatchNext:
1049  if (!*cursep || (c=getc(fp))==EOF) goto PackUpAndLeave;
1050  text_buffer_push(&curbuf,(char)c);
1051  if (c!=*cursep) goto TryAgain;
1052  cursep++;
1053  goto MatchNext;
1054 
1055  TryAgain:
1056  if (!text_buffer_next(lastbuf,lastidx+1,*sep,&lastbuf,&lastidx))
1057  goto WaitForStart;
1058  if (!(cursep=text_buffer_cmp(lastbuf,lastidx,sep)))
1059  goto TryAgain;
1060  goto MatchNext;
1061 
1062  PackUpAndLeave:
1063  /* compute how much space we need */
1064  for(lastbuf=&rootbuf,size=0;lastbuf!=NULL;lastbuf=lastbuf->next)
1065  size += lastbuf->top;
1066  t=stack_psi_term(0);
1067  t->type=quoted_string;
1068  t->value_3=(GENERIC)heap_alloc(size+1);
1069  for(lastbuf=&rootbuf,sep=(char*)t->value_3;
1070  lastbuf!=NULL;sep+=lastbuf->top,lastbuf=lastbuf->next)
1071  bcopy(lastbuf->data,sep,lastbuf->top);
1072  ((char*)t->value_3)[size]='\0';
1073  text_buffer_free(rootbuf.next);
1074  push_goal(unify,t,result,NULL);
1075  return TRUE;
1076 }
char * text_buffer_cmp(struct text_buffer *buf, int idx, char *str)
text_buffer_cmp
Definition: sys.c:934
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void text_buffer_free(struct text_buffer *buf)
text_buffer_free
Definition: sys.c:986
FILE * fp
Definition: sys.c:673
#define NULL
Definition: def_const.h:533
struct a_stream * ptr_stream
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
int text_buffer_next(struct text_buffer *buf, int idx, char c, struct text_buffer **rbuf, int *ridx)
text_buffer_next
Definition: sys.c:907
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
#define FP_INPUT
Definition: sys.c:669
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
Definition: sys.c:672
#define FP_PREPARE(s, OP)
Definition: sys.c:677
ptr_definition type
Definition: def_struct.h:181
struct text_buffer * next
Definition: def_struct.h:399
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void text_buffer_push(struct text_buffer **buf, char c)
text_buffer_push
Definition: sys.c:961
static long gethostname_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

gethostname_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1886 of file sys.c.

References FALSE, NULL, push_goal(), stack_string(), TRUE, and unify.

1887 {
1888  char name_loc[MAXHOSTNAMELEN+1];
1889  if (gethostname(name_loc,MAXHOSTNAMELEN+1) == 0) {
1890  push_goal(unify,result,stack_string(name_loc),NULL);
1891  return TRUE;
1892  }
1893  else return FALSE;
1894 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_psi_term stack_string(char *s)
stack_string
Definition: built_ins.c:109
static long getpid_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

getpid_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 2147 of file sys.c.

References REAL, and unify_real_result().

2148 {
2149  return unify_real_result(result,(REAL)getpid());
2150 }
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long unify_real_result(ptr_psi_term t, REAL v)
unify_real_result
Definition: built_ins.c:386
static long import_symbol_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

import_symbol_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1582 of file sys.c.

References wl_keyword::combined_name, current_module, wl_keyword::definition, Errorline(), FALSE, hash_insert(), hash_lookup(), HEAP_ALLOC, heap_copy_string(), wl_definition::keyword, make_module_token(), wl_keyword::module, wl_keyword::private_feature, wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_psi_term::type, wl_definition::type_def, and undef_it.

1583 {
1584  ptr_keyword key;
1585 
1586  if (args[1])
1587  key=args[1]->type->keyword;
1588  else
1590  args[0]->type->keyword->symbol);
1591 
1592  if (key)
1593  if (key->definition->type_def != (def_type)undef_it) {
1594  Errorline("symbol %s already defined in %P.",key->combined_name,funct);
1595  return FALSE;
1596  }
1597  else key->definition=args[0]->type;
1598  else {
1599  /* adapted from update_symbol in modules.c */
1600  /* Add 'module#symbol' to the symbol table */
1601  key=HEAP_ALLOC(struct wl_keyword);
1602  key->module=current_module;
1603  /* use same name */
1604  key->symbol=args[0]->type->keyword->symbol;
1605  key->combined_name=(char *)
1607  key->public=FALSE;
1608  key->private_feature=FALSE;
1609  key->definition=args[0]->type; /* use given definition */
1610 
1612  }
1613  return TRUE;
1614 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
HASH_LOOKUP.
Definition: hash_table.c:131
#define undef_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1394
char * combined_name
Definition: def_struct.h:119
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
ptr_definition definition
Definition: def_struct.h:122
def_type type_def
Definition: def_struct.h:153
ptr_hash_table symbol_table
Definition: def_struct.h:110
ptr_keyword keyword
Definition: def_struct.h:147
char * symbol
Definition: def_struct.h:118
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
char * heap_copy_string(char *s)
heap_copy_string
Definition: trees.c:172
void hash_insert(ptr_hash_table table, char *symbol, ptr_keyword keyword)
HASH_INSERT.
Definition: hash_table.c:151
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_module module
Definition: def_struct.h:117
char * make_module_token(ptr_module module, char *str)
make_module_token
Definition: modules.c:191
int private_feature
Definition: def_struct.h:121
ptr_definition type
Definition: def_struct.h:181
#define HEAP_ALLOC(A)
Definition: def_macro.h:20
void insert_sys_builtins ( )

insert_sys_builtins

Definition at line 2209 of file sys.c.

References bi_module, c_accept(), c_apply1(), c_bind(), c_bitvector_and(), c_bitvector_clear(), c_bitvector_count(), c_bitvector_get(), c_bitvector_not(), c_bitvector_or(), c_bitvector_set(), c_bitvector_xor(), c_call_once(), c_connect(), c_cuserid(), c_errmsg(), c_errno(), c_fclose(), c_fflush(), c_fopen(), c_fork(), c_fseek(), c_ftell(), c_fwrite(), c_get_buffer(), c_get_code(), c_get_record(), c_gethostname(), c_getpid(), c_import_symbol(), c_int2stream(), c_kill(), c_lazy_project(), c_listen(), c_make_bitvector(), c_my_wait_on_feature(), c_regexp_compile(), c_regexp_execute(), c_socket(), c_stream2sys_stream(), c_sys_stream2stream(), c_wait(), c_wait_on_feature(), c_waitpid(), current_module, function_it, insert_dbm_builtins(), new_built_in(), predicate_it, set_current_module(), sys_bitvector, sys_bytedata, sys_file_stream, sys_module, sys_process_continued, sys_process_exited, sys_process_no_children, sys_process_signaled, sys_process_stopped, sys_regexp, sys_socket_stream, sys_stream, and update_symbol().

2210 {
2211  ptr_module curmod = current_module;
2213 
2214  sys_bytedata =update_symbol(sys_module,"bytedata"); /* DENYS: BYTEDATA */
2215  sys_bitvector =update_symbol(sys_module,"bitvector");
2216  sys_regexp =update_symbol(sys_module,"regexp");
2217  sys_stream =update_symbol(sys_module,"stream");
2218  sys_file_stream =update_symbol(sys_module,"file_stream");
2219  sys_socket_stream =update_symbol(sys_module,"socket_stream");
2220  sys_process_no_children=update_symbol(sys_module,"process_no_children");
2221  sys_process_exited =update_symbol(sys_module,"process_exited");
2222  sys_process_signaled =update_symbol(sys_module,"process_signaled");
2223  sys_process_stopped =update_symbol(sys_module,"process_stopped");
2224  sys_process_continued =update_symbol(sys_module,"process_continued");
2225 
2226  /* DENYS: BYTEDATA */
2227  /* purely for illustration
2228  new_built_in(sys_module,"string_to_bytedata",(def_type)function_it,c_string_to_bytedata);
2229  new_built_in(sys_module,"bytedata_to_string",(def_type)function_it,c_bytedata_to_string);
2230  */
2273 #ifdef LIFE_DBM
2275 #endif
2276 #ifdef LIFE_NDBM
2277  insert_ndbm_builtins();
2278 #endif
2281  (void)set_current_module(curmod);
2282 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
new_built_in
Definition: built_ins.c:5375
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
#define function_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1408
static long c_make_bitvector()
c_make_bitvector
Definition: sys.c:174
static long c_bitvector_not()
c_bitvector_not
Definition: sys.c:366
static long c_wait()
c_wait
Definition: sys.c:1782
static long c_accept()
c_accept
Definition: sys.c:1503
static long c_fwrite()
c_fwrite
Definition: sys.c:819
static long c_call_once()
c_call_once
Definition: sys.c:2084
ptr_module current_module
The current module for the tokenizer.
Definition: def_glob.h:729
static long c_stream2sys_stream()
c_stream2sys_stream
Definition: sys.c:1214
static long c_ftell()
c_ftell
Definition: sys.c:1144
static long c_regexp_compile()
c_regexp_compile
Definition: sys.c:554
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
static long c_int2stream()
c_int2stream
Definition: sys.c:723
ptr_definition sys_process_continued
symbol in sys module
Definition: def_glob.h:650
static long c_kill()
c_kill
Definition: sys.c:1835
#define predicate_it
was enum (def_type) in extern.h now there is typedef ptr_definition
Definition: def_const.h:1401
static long c_fseek()
c_fseek
Definition: sys.c:1185
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
static long c_get_record()
c_get_record
Definition: sys.c:1083
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
static long c_getpid()
c_getpid
Definition: sys.c:2157
static long c_get_code()
c_get_code
Definition: sys.c:1113
static long c_bitvector_set()
c_bitvector_set
Definition: sys.c:472
static long c_fclose()
c_fclose
Definition: sys.c:787
ptr_definition update_symbol(ptr_module module, char *symbol)
update_symbol
Definition: modules.c:270
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
static long c_apply1()
c_apply1()
Definition: sys.c:2130
ptr_definition sys_process_no_children
symbol in sys module
Definition: def_glob.h:622
static long c_bitvector_xor()
c_bitvector_xor
Definition: sys.c:281
static long c_fflush()
c_fflush
Definition: sys.c:849
static long c_fopen()
c_fopen
Definition: sys.c:758
static long c_connect()
c_connect
Definition: sys.c:1434
static long c_listen()
c_listen
Definition: sys.c:1460
static long c_import_symbol()
c_import_symbol
Definition: sys.c:1624
static long c_waitpid()
c_waitpid
Definition: sys.c:1808
static long c_fork()
c_fork
Definition: sys.c:1655
static long c_bitvector_count()
c_bitvector_count
Definition: sys.c:376
void insert_dbm_builtins()
static long c_wait_on_feature()
c_wait_on_feature
Definition: sys.c:1995
static long c_bind()
c_bind
Definition: sys.c:1419
static long c_errno()
c_errno
Definition: sys.c:1532
ptr_module bi_module
Module for public built-ins.
Definition: def_glob.h:687
static long c_regexp_execute()
c_regexp_execute
Definition: sys.c:648
ptr_module sys_module
Definition: def_glob.h:735
static long c_cuserid()
c_cuserid
Definition: sys.c:1869
static long c_bitvector_or()
c_bitvector_or
Definition: sys.c:271
static long c_socket()
c_socket
Definition: sys.c:1319
ptr_definition sys_process_signaled
symbol in sys module
Definition: def_glob.h:636
static long c_bitvector_and()
c_bitvector_and
Definition: sys.c:261
static long c_lazy_project()
c_lazy_project
Definition: sys.c:1947
static long c_my_wait_on_feature()
c_my_wait_on_feature
Definition: sys.c:2043
static long c_bitvector_get()
c_bitvector_get
Definition: sys.c:462
static long c_bitvector_clear()
c_bitvector_clear
Definition: sys.c:482
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
ptr_definition sys_process_exited
symbol in sys module
Definition: def_glob.h:629
static long c_sys_stream2stream()
c_sys_stream2stream
Definition: sys.c:1244
static long c_gethostname()
c_gethostname
Definition: sys.c:1901
ptr_module set_current_module(ptr_module module)
set_current_module
Definition: modules.c:100
static long c_get_buffer()
c_get_buffer
Definition: sys.c:885
static long c_errmsg()
c_errmsg
Definition: sys.c:1564
ptr_definition sys_process_stopped
symbol in sys module
Definition: def_glob.h:643
static long int2stream_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

int2stream_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 704 of file sys.c.

References FALSE, fileptr2stream(), NULL, push_goal(), REAL, sys_stream, TRUE, and unify.

705 {
706  FILE *fp = fdopen((int)*(REAL*)args[0]->value_3,
707  (char*)args[1]->value_3);
708  if (fp==NULL) return FALSE;
709  else {
710  push_goal(unify,fileptr2stream(fp,sys_stream),result,NULL); // added & DJD
711  /* ptr_psi_term temp_result = make_bytedata(sys_stream,sizeof(fp));
712  *(FILE**)BYTEDATA_DATA(temp_result) = fp;
713  push_goal(unify,temp_result,result,NULL); */
714  return TRUE;
715  }
716 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
fileptr2stream
Definition: sys.c:688
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
int is_ipaddr ( char *  s)

is_ipaddr

Parameters
s- char *s

Definition at line 1333 of file sys.c.

References NULL.

1334 {
1335  if (s==NULL) return 0;
1336  while (*s)
1337  if (!isdigit(*s) && *s!='.') return 0;
1338  else s++;
1339  return 1;
1340 }
#define NULL
Definition: def_const.h:533
static long kill_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

kill_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1824 of file sys.c.

References FALSE, REAL, and TRUE.

1825 {
1826  return (kill((pid_t)*(REAL*)args[0]->value_3,
1827  (int)*(REAL*)args[1]->value_3)==0)?TRUE:FALSE;
1828 }
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
static long lazy_project_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

lazy_project_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1917 of file sys.c.

References wl_node::data, FEATCMP, find(), integer, NULL, push_goal(), quoted_string, REAL, residuate(), sub_type(), top, TRUE, and unify.

1918 {
1919  ptr_node n;
1920  char buffer_loc[100];
1921  if (args[1]->type == top) {
1922  residuate(args[0]);
1923  residuate(args[1]);
1924  return TRUE;
1925  }
1926  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1927  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
1928  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1929  strcpy(buffer_loc,(char*)args[1]->value_3);
1930  else
1931  strcpy(buffer_loc,args[1]->type->keyword->symbol);
1932  n=find(FEATCMP,buffer_loc,args[0]->attr_list);
1933  if (n) push_goal(unify,(ptr_psi_term)n->data,result,NULL);
1934  /* this is all bullshit because projection should residuate
1935  on its 2nd arg until it becomes value. In particular, think
1936  of using `int' as a feature when it is clear that `int' may
1937  subsequently be refined to a particular integer. */
1938  else residuate(args[0]);
1939  return TRUE;
1940 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long listen_internal ( args  ,
  result,
  funct 
)
static

(FILE**)BYTEDATA_DATA(args[0]));

Definition at line 1445 of file sys.c.

References BYTEDATA_DATA, FALSE, REAL, and TRUE.

1447 {
1448  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1449  int n = *(REAL*)args[1]->value_3;
1450 
1451  if (listen(fd,n) < 0) return FALSE;
1452  return TRUE;
1453 }
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
Definition: sys.c:672
static long make_bitvector_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

make_bitvector_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

C_MAKE_BITVECTOR make a bitvector that can hold at least the given number of bits

Definition at line 154 of file sys.c.

References Errorline(), FALSE, make_bytedata(), NULL, push_goal(), REAL, sys_bitvector, TRUE, and unify.

155 {
156  long bits = *(REAL *)args[0]->value_3;
157  if (bits < 0) {
158  Errorline("negative argument in %P.\n",funct);
159  return FALSE; }
160  else {
161  unsigned long bytes = bits / sizeof(char);
162  ptr_psi_term temp_result;
163  if ((bits % sizeof(char)) != 0) bytes++;
164  temp_result = make_bytedata(sys_bitvector,bytes);
165  push_goal(unify,temp_result,result,NULL);
166  return TRUE; }
167 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
static ptr_psi_term make_bytedata ( ptr_definition  sort,
unsigned long  bytes 
)
static

make_bytedata(

Parameters
sort- ptr_definition sort
bytes- unsigned long bytes

MAKE_BYTEDATA construct a psi term of the given sort whose value points to a bytedata block that can hold the given number of bytes

Definition at line 126 of file sys.c.

References heap_alloc(), stack_psi_term(), wl_psi_term::type, and wl_psi_term::value_3.

127 {
128  ptr_psi_term temp_result;
129  char *b = (char *) heap_alloc(bytes+sizeof(bytes));
130  *((long *) b) = bytes;
131  bzero(b+sizeof(bytes),bytes);
132  temp_result=stack_psi_term(0);
133  temp_result->type=sort;
134  temp_result->value_3=(GENERIC)b;
135  return temp_result;
136 }
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
ptr_definition type
Definition: def_struct.h:181
GENERIC heap_alloc(long s)
heap_alloc
Definition: memory.c:1616
void make_sys_type_links ( )

make_sys_type_links

INITIALIZATION FUNCTIONS

Definition at line 2168 of file sys.c.

References built_in, make_type_link(), sys_bitvector, sys_bytedata, sys_file_stream, sys_regexp, sys_socket_stream, and sys_stream.

2169 {
2170 #ifdef LIFE_NDBM
2171  make_ndbm_type_links();
2172 #endif
2178  make_type_link(sys_bytedata ,built_in); /* DENYS: BYTEDATA */
2179 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
ptr_definition sys_bitvector
symbol in sys module
Definition: def_glob.h:571
ptr_definition sys_file_stream
symbol in sys module
Definition: def_glob.h:592
ptr_definition built_in
symbol in bi module
Definition: def_glob.h:199
ptr_definition sys_bytedata
symbol in sys module
Definition: def_glob.h:983
void make_type_link(ptr_definition t1, ptr_definition t2)
make_type_link
Definition: types.c:901
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
static long my_wait_on_feature_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

my_wait_on_feature_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 2012 of file sys.c.

References DEFRULES, FEATCMP, find(), integer, NULL, prove, push_goal(), quoted_string, REAL, residuate(), sub_type(), top, TRUE, and unify_bool_result().

2013 {
2014  char buffer_loc[100];
2015  if (args[1]->type == top) {
2016  residuate(args[0]);
2017  residuate(args[1]);
2018  return TRUE;
2019  }
2020  if (sub_type(args[1]->type,integer) && args[1]->value_3)
2021  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
2022  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
2023  strcpy(buffer_loc,(char*)args[1]->value_3);
2024  else
2025  strcpy(buffer_loc,args[1]->type->keyword->symbol);
2026  if (find(FEATCMP,buffer_loc,args[0]->attr_list)) {
2027  unify_bool_result(result,TRUE);
2029  }
2030  /* this is all bullshit because projection should residuate
2031  on its 2nd arg until it becomes value. In particular, think
2032  of using `int' as a feature when it is clear that `int' may
2033  subsequently be refined to a particular integer. */
2034  else residuate(args[0]);
2035  return TRUE;
2036 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
void regerror ( char *  s)

regerror

Parameters
s- char *s

Definition at line 498 of file sys.c.

499 {
500  fprintf(stderr,"Regexp Error: %s\n",s);
501 }
static long regexp_compile_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

regexp_compile_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

C_REGEXP_COMPILE given a string returns, compiles it into a regexp structure, then copies that structure into a bytedata block on the heap.

Definition at line 514 of file sys.c.

References c_abort(), Errorline(), make_bytedata(), NULL, push_goal(), sys_regexp, TRUE, unify, and wl_psi_term::value_3.

515 {
516  ptr_psi_term temp_result;
517  regexp * re = regcomp((char *)args[0]->value_3);
518  long bytes;
519  if (re == NULL) {
520  Errorline("compilation of regular expression failed in %P.\n",funct);
521  return (c_abort()); }
522  /* compute the size of the regexp stuff. this is essentially the size
523  of the regexp structure + the size of the program (bytecode) including
524  the final END opcode (i.e. 0), hence the + 1, minus the bytes that we
525  have counted twice, i.e. those between the start of the program and
526  the computed end of the regexp structure (i.e. in case a regexp
527  struct is larger, maybe to respect alignment constraints, than it has
528  to be, and also to count the 1 byte of program included in the decl
529  of struct regexp */
530  bytes = last_regsize();
531  temp_result = make_bytedata(sys_regexp,bytes);
532  /* now let's copy the regexp stuff into the bytedata block. The regmust
533  field must be treated specially because it is a pointer into program:
534  we cannot simply change it to reflect the location where the program
535  will be copied to because that may well change over time: the gc may
536  relocate the bytedata block. Instead, we convert regmust into an
537  offset and each time we need to pass it to regexec or regsub we must
538  first convert it back into a pointer then back into an offset when we
539  are done. Note that, if regmust is NULL we must leave it that way */
540  if (re->regmust != NULL)
541  re->regmust = (char *) ((unsigned long) (re->regmust - (char *)re));
542  bcopy((char*)re,((char*)temp_result->value_3)+sizeof(unsigned long),bytes);
543  free(re); /* free the regexp: no longer needed */
544  /* return result */
545  push_goal(unify,temp_result,result,NULL);
546  return TRUE;
547 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition sys_regexp
symbol in sys module
Definition: def_glob.h:578
long c_abort()
c_abort
Definition: built_ins.c:2247
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
GENERIC value_3
Definition: def_struct.h:186
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
make_bytedata(
Definition: sys.c:126
static long regexp_execute_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

regexp_execute_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
functptr_psi_term funct

C_REGEXP_EXECUTE Attempts to match a regexp with a string regexp_execute(RE:regexp,S:string) -> @(0=>(S0,E0),(S1,E1),...) regexp_execute(RE:regexp,S:string,@(N=>(SN,EN),...)) -> boolean 2nd form only instantiates the bounds requested in the mask (3rd arg) and returns a boolean so that it can be used as a predicate. The optional argument "offset" specifies an offset into the string.

Definition at line 576 of file sys.c.

References wl_psi_term::attr_list, c_abort(), wl_node::data, Errorline(), FALSE, FEATCMP, find(), NULL, push_goal(), REAL, stack_insert_copystr(), stack_int(), stack_pair(), stack_psi_term(), top, TRUE, wl_psi_term::type, unify, unify_bool_result(), and wl_psi_term::value_3.

577 {
578  regexp * re = (regexp*)(((char *)args[0]->value_3)+sizeof(unsigned long));
579  char * must = re->regmust;
580  long offset = 0;
581  // long success = TRUE;
582  /* check that args[3] aka "offset" is valid if present */
583  if (args[3]) {
584  offset = *(REAL*)args[3]->value_3;
585  if (offset < 0 || offset > strlen((char*)args[1]->value_3)) {
586  Errorline("Illegal offset in %P.\n",funct);
587  return (c_abort()); }
588  }
589  /* convert regmust from offset into a pointer if not NULL */
590  if (must != NULL)
591  re->regmust = (char*)re+(unsigned long)must;
592  /* perform operation */
593  if (regexec(re,((char *)args[1]->value_3) + offset) == 0) {
594  if (must != NULL) re->regmust = must; /* back into an offset */
595  return FALSE;
596  }
597  else {
598  /* construct result of match */
599  char **sp = re->startp;
600  char **ep = re->endp;
601  int i;
602  char buffer_loc[5]; /* in case NSUBEXP ever gets increased */
603  ptr_node n3;
604  if (must != NULL) re->regmust = must; /* back into an offset */
605  if (args[2]) {
606  /* only instantiate the numeric features present in args[2]
607  then return true */
608  for (i=0;i<NSUBEXP;i++,sp++,ep++) {
609  if (*sp==NULL) break;
610  (void)snprintf(buffer_loc,5,"%d",i);
611  n3=find(FEATCMP,buffer_loc,args[2]->attr_list);
612  if (n3) {
613  ptr_psi_term psi = (ptr_psi_term) n3->data;
614  /* need to add 1 to these offsets because somehow life strings
615  are 1-based rather than 0-based. Who is the moron who made
616  that decision? This isn't Pascal! */
617  ptr_psi_term bounds = stack_pair(stack_int(*sp - (char *)args[1]->value_3 + 1),
618  stack_int(*ep - (char *)args[1]->value_3 + 1));
619  push_goal(unify,psi,bounds,NULL);
620  }
621  }
622  /* return true */
623  unify_bool_result(result,TRUE);
624  }
625  else {
626  /* create a term to represent all the groups and return it */
627  ptr_psi_term psi = stack_psi_term(4);
628  psi->type = top;
629  for (i=0;i<NSUBEXP;i++,sp++,ep++) {
630  if (*sp==NULL) break;
631  (void)snprintf(buffer_loc,5,"%d",i);
632  { ptr_psi_term bounds = stack_pair(stack_int(*sp - (char *)args[1]->value_3 + 1),
633  stack_int(*ep - (char *)args[1]->value_3 + 1));
634  stack_insert_copystr(buffer_loc,&(psi->attr_list),(GENERIC)bounds); }
635  }
636  /* return the new term */
637  push_goal(unify,psi,result,NULL);
638  }
639  return TRUE;
640  }
641 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
void unify_bool_result(ptr_psi_term t, long v)
unify_bool_result
Definition: built_ins.c:344
long c_abort()
c_abort
Definition: built_ins.c:2247
struct wl_psi_term * ptr_psi_term
quotedStackCopy
Definition: def_struct.h:62
GENERIC data
Definition: def_struct.h:201
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_psi_term stack_pair(ptr_psi_term left, ptr_psi_term right)
stack_pair
Definition: built_ins.c:69
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_int(long n)
stack_int
Definition: built_ins.c:91
#define FALSE
Standard boolean.
Definition: def_const.h:275
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
void stack_insert_copystr(char *keystr, ptr_node *tree, GENERIC info)
stack_insert_copystr
Definition: trees.c:301
static long socket_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

socket_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1269 of file sys.c.

References Errorline(), FALSE, fileptr2stream(), NULL, push_goal(), sys_socket_stream, TRUE, and unify.

1270 {
1271  int addr_family=AF_INET,type=SOCK_STREAM,protocol=0;
1272  char *s;
1273  int fd;
1274 
1275  if (args[0]) {
1276  s=(char*)args[0]->value_3;
1277  if (!strcmp(s,"AF_UNIX")) addr_family=AF_UNIX;
1278  else if (!strcmp(s,"AF_INET")) addr_family=AF_INET;
1279  else {
1280  Errorline("Unknown address family in %P.\n",funct);
1281  return FALSE; }
1282  }
1283 
1284  if (args[1]) {
1285  s=(char*)args[1]->value_3;
1286  if (!strcmp(s,"SOCK_STREAM")) type=SOCK_STREAM;
1287  else if (!strcmp(s,"SOCK_DGRAM" )) type=SOCK_DGRAM;
1288  else if (!strcmp(s,"SOCK_RAW" )) {
1289  Errorline("SOCK_RAW not supported in %P.\n",funct);
1290  return FALSE; }
1291  else {
1292  Errorline("Unknown socket type in %P.\n",funct);
1293  return FALSE; }
1294  }
1295 
1296  if ((fd=socket(addr_family,type,protocol))<0)
1297  return FALSE;
1298 
1299  { FILE*fp = fdopen(fd,"r+");
1300  // ptr_psi_term t;
1301 
1302  if (fp==NULL) {
1303  Errorline("fdopen failed on socket in %P.\n",funct);
1304  return FALSE;
1305  }
1306 
1307  /* t = make_bytedata(sys_socket_stream,sizeof(fp));
1308  *(FILE**)BYTEDATA_DATA(t) = fp;*/
1309  push_goal(unify,fileptr2stream(fp,sys_socket_stream),result,NULL); // added & DJD
1310  }
1311  return TRUE;
1312 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
fileptr2stream
Definition: sys.c:688
#define NULL
Definition: def_const.h:533
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define FALSE
Standard boolean.
Definition: def_const.h:275
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition sys_socket_stream
symbol in sys module
Definition: def_glob.h:599
static long stream2sys_stream_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

stream2sys_stream_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1202 of file sys.c.

References fileptr2stream(), NULL, push_goal(), sys_stream, TRUE, and unify.

1203 {
1204  push_goal(unify,fileptr2stream((FILE*)args[0]->value_3,sys_stream),
1205  result,NULL); // added & DJD
1206  return TRUE;
1207 }
ptr_definition sys_stream
symbol in sys module
Definition: def_glob.h:585
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
fileptr2stream
Definition: sys.c:688
#define NULL
Definition: def_const.h:533
#define TRUE
Standard boolean.
Definition: def_const.h:268
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
static long sys_stream2stream_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

sys_stream2stream_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1229 of file sys.c.

References BYTEDATA_DATA, NULL, push_goal(), stack_psi_term(), stream, TRUE, wl_psi_term::type, unify, and wl_psi_term::value_3.

1230 {
1231  ptr_psi_term tmp;
1232  tmp=stack_psi_term(4);
1233  tmp->type=stream;
1234  tmp->value_3=(GENERIC)((ptr_stream)BYTEDATA_DATA(args[0]))->fp;
1235  push_goal(unify,tmp,result,NULL);
1236  return TRUE;
1237 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_definition stream
symbol in bi module
Definition: def_glob.h:382
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
#define BYTEDATA_DATA(X)
Definition: sys.c:139
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
GENERIC value_3
Definition: def_struct.h:186
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
Definition: sys.c:672
ptr_definition type
Definition: def_struct.h:181
char* text_buffer_cmp ( struct text_buffer buf,
int  idx,
char *  str 
)

text_buffer_cmp

Parameters
buf- struct text_buffer *buf
idx- int idx
str- char *str

compare string str with text in buffer buf starting at index idx. if the text to the end matches a prefix of the string, return pointer to remaining suffix of str to be matched, else return 0.

Definition at line 934 of file sys.c.

References text_buffer::data, text_buffer::next, and top.

935 {
936  while (buf) {
937  while (idx<buf->top)
938  if (!*str || buf->data[idx] != *str)
939  return 0;
940  else { idx++; str++; }
941  if (!*str && !buf->next) return str;
942  else {
943  buf=buf->next;
944  idx=0;
945  }
946  }
947  return 0;
948 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_free ( struct text_buffer buf)

text_buffer_free

Parameters
buf- struct text_buffer *buf

free a linked list of buffers

Definition at line 986 of file sys.c.

References text_buffer::next.

987 {
988  struct text_buffer *next;
989  while (buf) {
990  next = buf->next;
991  free(buf);
992  buf=next;
993  }
994 }
struct text_buffer * next
Definition: def_struct.h:399
int text_buffer_next ( struct text_buffer buf,
int  idx,
char  c,
struct text_buffer **  rbuf,
int *  ridx 
)

text_buffer_next

Parameters
buf- struct text_buffer *buf
idx- int idx
c- char c
rbuf- struct text_buffer **rbuf
ridx- int *ridx

find the first match for character c starting from index idx in buffer buf. if found place new buffer and index in rbuf and ridx and return 1, else return 0

Definition at line 907 of file sys.c.

References text_buffer::data, text_buffer::next, and top.

908 {
909  while (buf) {
910  while (idx<buf->top)
911  if (buf->data[idx] == c) {
912  *rbuf=buf;
913  *ridx=idx;
914  return 1;
915  }
916  else idx++;
917  buf=buf->next;
918  idx=0;
919  }
920  return 0;
921 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_push ( struct text_buffer **  buf,
char  c 
)

text_buffer_push

Parameters
buf- struct text_buffer **buf
c- char c

add a character at the end of a buffer. if the buffer is full, allocate a new buffer and link it to the current one, then overwrite the variable holding the pointer to the current buffer with the pointer to the new buffer.

Definition at line 961 of file sys.c.

References text_buffer::next, TEXTBUFSIZE, and text_buffer::top.

962 {
963  if ((*buf)->top < TEXTBUFSIZE)
964  (*buf)->data[(*buf)->top++] = c;
965  else {
966  (*buf)->next = (struct text_buffer *)
967  malloc(sizeof(struct text_buffer));
968  if (!(*buf)->next) {
969  fprintf(stderr,"Fatal error: malloc failed in text_buffer_push\n");
970  exit(EXIT_FAILURE);
971  }
972  bzero((char*)(*buf)->next,sizeof(struct text_buffer));
973  *buf = (*buf)->next;
974  (*buf)->top = 1;
975  (*buf)->data[0]=c;
976  }
977 }
#define TEXTBUFSIZE
Definition: def_struct.h:396
struct text_buffer * next
Definition: def_struct.h:399
static long unify_pterm_result ( ptr_psi_term  t,
ptr_definition  sym,
psi_feature  lst[],
int  n 
)
static

unify_pterm_result

Parameters
t- ptr_psi_term t
sym- ptr_definition sym
lst- psi_feature lst[]
n- int n

Definition at line 1676 of file sys.c.

References wl_psi_term::attr_list, FEATCMP, NULL, push_goal(), stack_insert(), stack_psi_term(), TRUE, wl_psi_term::type, unify, and psi_feature::value_str.

1677 {
1678  ptr_psi_term u;
1679  int i;
1680  if (n<0) {
1681  fprintf(stderr,"unify_pterm_result called with n<0: n=%d\n",n);
1682  exit(EXIT_FAILURE);
1683  }
1684  u=stack_psi_term(4);
1685  u->type=sym;
1686  for(i=0;i<n;i++)
1687  (void)stack_insert(FEATCMP,lst[i].name_str,&(u->attr_list),(GENERIC)lst[i].value_str);
1688  push_goal(unify,t,u,NULL);
1689  return TRUE;
1690 }
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
ptr_psi_term value_str
Definition: sys.c:1662
#define NULL
Definition: def_const.h:533
unsigned long * GENERIC
unsigned long *GENERIC
Definition: def_struct.h:35
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
stack_insert
Definition: trees.c:337
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_psi_term stack_psi_term(long stat)
stack_psi_term
Definition: lefun.c:21
#define unify
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1058
ptr_definition type
Definition: def_struct.h:181
ptr_node attr_list
Definition: def_struct.h:187
static long unify_wait_result ( ptr_psi_term  result,
pid_t  id,
int  status 
)
static

unify_wait_result

Parameters
result- ptr_psi_term result
id- pid_t id
status- int status

Definition at line 1722 of file sys.c.

References Errorline(), FALSE, one, SETFEATURE, stack_int(), sys_process_continued, sys_process_exited, sys_process_no_children, sys_process_signaled, sys_process_stopped, two, and unify_pterm_result().

1723 {
1724  int n=2;
1725  long status2;
1726  ptr_definition sym;
1727  psi_feature lst[2];
1728  SETFEATURE(lst,0,one,stack_int(id));
1729  if (id == -1 || status == -1) {
1730  if (errno==ECHILD) {
1732  n=0;
1733  }
1734  else return FALSE;
1735  }
1736  else if (WIFEXITED(status)) {
1737  SETFEATURE(lst,1,two,stack_int(WEXITSTATUS(status)));
1738  sym = sys_process_exited;
1739  }
1740  else if (WIFSIGNALED(status)) {
1741  SETFEATURE(lst,1,two,stack_int(WTERMSIG(status)));
1742  sym = sys_process_signaled;
1743  }
1744  else if (WIFSTOPPED(status)) {
1745  SETFEATURE(lst,1,two,stack_int(WSTOPSIG(status)));
1746  sym = sys_process_stopped;
1747  }
1748 #ifdef WIFCONTINUED
1749  else if (WIFCONTINUED(status)) {
1750  sym = sys_process_continued;
1751  n=1;
1752  }
1753 #endif
1754  else {
1755  status2 = status;
1756  Errorline("Unexpected wait status: %d",status2);
1757  return FALSE;
1758  }
1759  return unify_pterm_result(result,sym,lst,n);
1760 }
char * two
Definition: def_glob.h:892
ptr_definition sys_process_continued
symbol in sys module
Definition: def_glob.h:650
ptr_definition sys_process_no_children
symbol in sys module
Definition: def_glob.h:622
void Errorline(char *format,...)
Errorline.
Definition: error.c:465
#define SETFEATURE(lst, n, nam, val)
Definition: sys.c:1665
static long unify_pterm_result(ptr_psi_term t, ptr_definition sym, psi_feature lst[], int n)
unify_pterm_result
Definition: sys.c:1676
ptr_psi_term stack_int(long n)
stack_int
Definition: built_ins.c:91
#define FALSE
Standard boolean.
Definition: def_const.h:275
char * one
Definition: def_glob.h:891
ptr_definition sys_process_signaled
symbol in sys module
Definition: def_glob.h:636
ptr_definition sys_process_exited
symbol in sys module
Definition: def_glob.h:629
ptr_definition sys_process_stopped
symbol in sys module
Definition: def_glob.h:643
static long wait_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

wait_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1770 of file sys.c.

References unify_wait_result().

1771 {
1772  int status;
1773  pid_t id = wait(&status);
1774  return unify_wait_result(result,id,status);
1775 }
static long unify_wait_result(ptr_psi_term result, pid_t id, int status)
unify_wait_result
Definition: sys.c:1722
static long wait_on_feature_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

wait_on_feature_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1966 of file sys.c.

References DEFRULES, FEATCMP, find(), integer, NULL, prove, push_goal(), quoted_string, REAL, residuate(), sub_type(), top, and TRUE.

1967 {
1968  char buffer_loc[100];
1969  if (args[1]->type == top) {
1970  residuate(args[0]);
1971  residuate(args[1]);
1972  return TRUE;
1973  }
1974  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1975  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
1976  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1977  strcpy(buffer_loc,(char*)args[1]->value_3);
1978  else
1979  strcpy(buffer_loc,args[1]->type->keyword->symbol);
1980  if (find(FEATCMP,buffer_loc,args[0]->attr_list))
1982  /* this is all bullshit because projection should residuate
1983  on its 2nd arg until it becomes value. In particular, think
1984  of using `int' as a feature when it is clear that `int' may
1985  subsequently be refined to a particular integer. */
1986  else residuate(args[0]);
1987  return TRUE;
1988 }
#define prove
was enum (goal) – but must be long for error.c - now typedef
Definition: def_const.h:1051
#define FEATCMP
indicates to use featcmp for comparison (in trees.c)
Definition: def_const.h:979
void residuate(ptr_psi_term t)
residuate
Definition: lefun.c:125
ptr_definition integer
symbol in bi module
Definition: def_glob.h:312
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
push_goal
Definition: login.c:600
#define DEFRULES
Must be different from NULL, a built-in index, and a pointer Used to indicate that the rules of the d...
Definition: def_const.h:302
#define NULL
Definition: def_const.h:533
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
long sub_type(ptr_definition t1, ptr_definition t2)
sub_type
Definition: types.c:1642
#define TRUE
Standard boolean.
Definition: def_const.h:268
ptr_node find(long comp, char *keystr, ptr_node tree)
find
Definition: trees.c:394
ptr_definition top
symbol in syntax module
Definition: def_glob.h:403
ptr_definition quoted_string
symbol in bi module
Definition: def_glob.h:368
static long waitpid_internal ( ptr_psi_term  args[],
ptr_psi_term  result,
ptr_psi_term  funct 
)
static

waitpid_internal

Parameters
args- ptr_psi_term args[]
result- ptr_psi_term result
funct- ptr_psi_term funct

Definition at line 1795 of file sys.c.

References REAL, and unify_wait_result().

1796 {
1797  int status;
1798  pid_t id = waitpid((pid_t)(long)*(REAL*)args[0]->value_3,&status,
1799  args[1]?(int)(long)*(REAL*)args[1]->value_3:0);
1800  return unify_wait_result(result,id,status);
1801 }
#define REAL
Which C type to use to represent reals and integers in Wild_Life.
Definition: def_const.h:132
static long unify_wait_result(ptr_psi_term result, pid_t id, int status)
unify_wait_result
Definition: sys.c:1722