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

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

Variables

ptr_definition sys_process_no_children
 
ptr_definition sys_process_exited
 
ptr_definition sys_process_signaled
 
ptr_definition sys_process_stopped
 
ptr_definition sys_process_continued
 

Macro Definition Documentation

#define BV_AND   0

Definition at line 162 of file sys.c.

#define BV_CLEAR   2

Definition at line 321 of file sys.c.

#define BV_COUNT   1

Definition at line 244 of file sys.c.

#define BV_GET   0

Definition at line 319 of file sys.c.

#define BV_NOT   0

Definition at line 243 of file sys.c.

#define BV_OR   1

Definition at line 163 of file sys.c.

#define BV_SET   1

Definition at line 320 of file sys.c.

#define BV_XOR   2

Definition at line 164 of file sys.c.

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

Definition at line 128 of file sys.c.

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

Definition at line 127 of file sys.c.

#define FP_INPUT   1

Definition at line 559 of file sys.c.

#define FP_NONE   0

Definition at line 558 of file sys.c.

#define FP_OUTPUT   2

Definition at line 560 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:558

Definition at line 567 of file sys.c.

#define SEEK_CUR   1

Definition at line 935 of file sys.c.

#define SEEK_END   2

Definition at line 938 of file sys.c.

#define SEEK_SET   0

Definition at line 932 of file sys.c.

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

Definition at line 1336 of file sys.c.

Typedef Documentation

typedef struct a_stream * ptr_stream

Function Documentation

static long accept_internal ( args  ,
  result,
  funct 
)
static

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

Definition at line 1188 of file sys.c.

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

1190 {
1191  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1192  int s;
1193 
1194  if ((s=accept(fd,NULL,NULL)) < 0) return FALSE;
1195  else {
1196  FILE * fp = fdopen(s,"r+");
1197  // ptr_psi_term t;
1198 
1199  if (fp==NULL) {
1200  Errorline("fdopen failed on socket in %P.\n",funct);
1201  return FALSE;
1202  }
1203 
1204 /* t = make_bytedata(sys_socket_stream,sizeof(fp));
1205  *(FILE**)BYTEDATA_DATA(t) = fp;*/
1206  push_goal(unify,fileptr2stream(fp,sys_socket_stream),result,NULL); // added & DJD
1207  return TRUE;
1208  }
1209 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
Definition: sys.c:571
#define NULL
Definition: def_const.h:203
void Errorline(char *format,...)
Definition: error.c:414
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
Definition: sys.c:562
ptr_definition sys_socket_stream
Definition: def_glob.h:134
static long apply1_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1670 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.

1672 {
1673  long success=TRUE;
1674  if (args[0]->type==top) residuate(args[0]);
1675  else if (args[0]->type->type_def!=(def_type)function_it) {
1676  Errorline("1st arg not a function in %P.\n",funct);
1677  success=FALSE;
1678  }
1679  else {
1680  // char buffer_loc[1000];
1681  char * feat;
1682  ptr_psi_term fun;
1683  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1684  feat = get_numeric_feature((long)*(REAL*)args[1]->value_3);
1685  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1686  feat = (char *)args[1]->value_3;
1687  else
1688  feat = (char *)heap_copy_string(args[1]->type->keyword->symbol);
1689  clear_copy();
1690  fun=distinct_copy(args[0]);
1691  (void)stack_insert(FEATCMP,(char *)feat,&(fun->attr_list),(GENERIC)args[2]);
1692  push_goal(eval,fun,result,(GENERIC)fun->type->rule);
1693  }
1694  return success;
1695 }
#define function_it
Definition: def_const.h:362
#define FEATCMP
Definition: def_const.h:257
void clear_copy()
Definition: copy.c:52
void residuate(ptr_psi_term t)
Definition: lefun.c:113
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_definition top
Definition: def_glob.h:106
#define REAL
Definition: def_const.h:72
char * get_numeric_feature(long n)
Definition: sys.c:1360
#define eval
Definition: def_const.h:278
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
void Errorline(char *format,...)
Definition: error.c:414
char * heap_copy_string(char *s)
Definition: trees.c:147
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
ptr_psi_term distinct_copy(ptr_psi_term t)
Definition: copy.c:358
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
static long bind_or_connect_internal ( args  ,
  result,
  funct,
void*  info 
)
static

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

Definition at line 1079 of file sys.c.

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

1082 {
1083  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1084  int do_bind = info==NULL;
1085 
1086  if (args[1] || args[2]) {
1087  /* bind or connect in the internet domain */
1088  struct sockaddr_in name_loc;
1089  char* hostname = args[1]?(char*)args[1]->value_3:NULL;
1090  // int port;
1091  if (!args[2]) {
1092  Errorline("Missing port number in %P.\n",funct);
1093  return FALSE;
1094  }
1095 
1096  bzero((char*)&name_loc,sizeof(name_loc));
1097  name_loc.sin_family = AF_INET;
1098  name_loc.sin_port = htons((unsigned short)*(REAL*)args[2]->value_3);
1099 
1100  if (!hostname || *hostname=='\0' || !strcasecmp(hostname,"localhost"))
1101  name_loc.sin_addr.s_addr = INADDR_ANY;
1102  else {
1103  struct hostent * h;
1104  int ipaddr;
1105  if ((ipaddr=is_ipaddr(hostname))) {
1106  int i = inet_addr(hostname);
1107  h = gethostbyaddr((char*)&i,sizeof(i),AF_INET);
1108  } else h = gethostbyname(hostname);
1109  if (h==NULL) {
1110  Errorline("%s failed for %P.\n",
1111  ipaddr?"gethostbyaddr":"gethostbyname",funct);
1112  return FALSE;
1113  }
1114  bcopy(h->h_addr,(char*)&(name_loc.sin_addr.s_addr),h->h_length);
1115  }
1116  if ((do_bind?
1117  bind(fd,(struct sockaddr *)&name_loc,sizeof(name_loc)):
1118  connect(fd,(struct sockaddr *)&name_loc,sizeof(name_loc))) < 0) {
1119  Errorline("%s failed in %P.\n",do_bind?"bind":"connect",funct);
1120  return FALSE;
1121  }
1122  }
1123  else if (args[3]) {
1124  /* bind in the unix domain */
1125  struct sockaddr_un name_loc;
1126  char* path = (char*)args[3]->value_3;
1127 
1128  name_loc.sun_family = AF_UNIX;
1129  strcpy(name_loc.sun_path,path);
1130 
1131  if ((do_bind?
1132  bind(fd,(struct sockaddr *)&name_loc,sizeof(name_loc)):
1133  connect(fd,(struct sockaddr *)&name_loc,sizeof(name_loc))) < 0) {
1134  Errorline("%s failed in %P.\n",do_bind?"bind":"connect",funct);
1135  return FALSE;
1136  }
1137  }
1138  else {
1139  Errorline("Too few arguments in %P.\n",funct);
1140  return FALSE;
1141  }
1142  return TRUE;
1143 }
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
void Errorline(char *format,...)
Definition: error.c:414
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
int is_ipaddr(char *s)
Definition: sys.c:1068
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
static long bitvector_binop ( long  op)
static

Definition at line 216 of file sys.c.

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

218 {
219  psi_arg args[2];
220  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
221  SETARG(args,1, "2" , sys_bitvector , REQUIRED );
222  return call_primitive(bitvector_binop_internal,NARGS(args),args,(GENERIC)op);
223 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long bitvector_binop_internal(ptr_psi_term *args, ptr_psi_term result, ptr_psi_term funct, GENERIC op)
Definition: sys.c:206
#define REQUIRED
Definition: def_const.h:215
ptr_definition sys_bitvector
Definition: def_glob.h:130
#define NARGS(args)
Definition: def_macro.h:169
unsigned long * GENERIC
Definition: def_struct.h:17
static long bitvector_binop_code ( unsigned long *  bv1,
unsigned long*  bv2,
ptr_psi_term  result,
GENERIC  op 
)
static

Definition at line 167 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.

171 {
172  unsigned long size1 = *bv1;
173  unsigned long size2 = *bv2;
174  unsigned long size3 = (size1>size2)?size1:size2;
175  ptr_psi_term temp_result = make_bytedata(sys_bitvector,size3);
176  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
177  unsigned char *s2 = ((unsigned char*)bv2)+sizeof(size2);
178  unsigned char *s3 = ((unsigned char *) temp_result->value_3) + sizeof(size3);
179  unsigned long i;
180  switch ((long)op) { // added cast DJD 2.16
181  case BV_AND:
182  for(i=0;i<size3;i++) s3[i] = s1[i] & s2[i];
183  if (size1<size2) for(;i<size2;i++) s3[i] = 0;
184  else for(;i<size1;i++) s3[i] = 0;
185  break;
186  case BV_OR:
187  for(i=0;i<size3;i++) s3[i] = s1[i] | s2[i];
188  if (size1<size2) for(;i<size2;i++) s3[i] = s2[i];
189  else for(;i<size1;i++) s3[i] = s1[i];
190  break;
191  case BV_XOR:
192  for(i=0;i<size3;i++) s3[i] = s1[i] ^ s2[i];
193  if (size1<size2) for(;i<size2;i++) s3[i] = (unsigned char) 0 ^ s2[i];
194  else for(;i<size1;i++) s3[i] = s1[i] ^ (unsigned char) 0;
195  break;
196  default: return (c_abort());
197  }
198  push_goal(unify,temp_result,result,NULL);
199  return TRUE;
200 }
#define BV_OR
Definition: sys.c:163
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define BV_XOR
Definition: sys.c:164
long c_abort()
Definition: built_ins.c:2117
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
ptr_definition sys_bitvector
Definition: def_glob.h:130
GENERIC value_3
Definition: def_struct.h:170
#define BV_AND
Definition: sys.c:162
#define unify
Definition: def_const.h:274
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
static long bitvector_binop_internal ( ptr_psi_term args,
ptr_psi_term  result,
ptr_psi_term  funct,
GENERIC  op 
)
static

Definition at line 206 of file sys.c.

References bitvector_binop_code().

209 {
210  return bitvector_binop_code((unsigned long *)args[0]->value_3,
211  (unsigned long *)args[1]->value_3,
212  result,(GENERIC)op);
213 }
static long bitvector_binop_code(unsigned long *bv1, unsigned long *bv2, ptr_psi_term result, GENERIC op)
Definition: sys.c:167
unsigned long * GENERIC
Definition: def_struct.h:17
static long bitvector_bit ( long  op)
static

Definition at line 371 of file sys.c.

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

373 {
374  psi_arg args[2];
375  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
376  SETARG(args,1, "2" , integer , REQUIRED );
377  return call_primitive(bitvector_bit_internal,NARGS(args),args,(GENERIC)op);
378 }
static long bitvector_bit_internal(args, result, funct, GENERIC op)
Definition: sys.c:361
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
#define REQUIRED
Definition: def_const.h:215
ptr_definition sys_bitvector
Definition: def_glob.h:130
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
unsigned long * GENERIC
Definition: def_struct.h:17
static long bitvector_bit_code ( unsigned long *  bv1,
long  idx,
ptr_psi_term  result,
int  op,
ptr_psi_term  funct 
)
static

Definition at line 324 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.

329 {
330  unsigned long size1 = *bv1;
331  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
332  unsigned long i = idx / sizeof(char);
333  int j = idx % sizeof(char);
334  ptr_psi_term temp_result;
335  unsigned char *s2;
336  if (idx<0 || idx>=size1) {
337  Errorline("Index out of bound in %P.\n",funct);
338  return FALSE; }
339  switch (op) {
340  case BV_GET:
341  return unify_real_result(result,(REAL)((s1[i] & (1<<j))?1:0));
342  break;
343  case BV_SET:
344  temp_result = make_bytedata(sys_bitvector,size1);
345  s2 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
346  bcopy(s1,s2,size1);
347  s2[i] |= 1<<j;
348  break;
349  case BV_CLEAR:
350  temp_result = make_bytedata(sys_bitvector,size1);
351  s2 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
352  bcopy(s1,s2,size1);
353  s2[i] &= ~ (1<<j);
354  break;
355  }
356  push_goal(unify,temp_result,result,NULL);
357  return TRUE;
358 }
#define BV_CLEAR
Definition: sys.c:321
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define BV_SET
Definition: sys.c:320
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
void Errorline(char *format,...)
Definition: error.c:414
#define BV_GET
Definition: sys.c:319
#define TRUE
Definition: def_const.h:127
ptr_definition sys_bitvector
Definition: def_glob.h:130
#define FALSE
Definition: def_const.h:128
GENERIC value_3
Definition: def_struct.h:170
#define unify
Definition: def_const.h:274
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
static long bitvector_bit_internal ( args  ,
  result,
  funct,
GENERIC  op 
)
static

Definition at line 361 of file sys.c.

References bitvector_bit_code(), and REAL.

364 {
365  return bitvector_bit_code((unsigned long *)args[0]->value_3,
366  (long)*((REAL*)args[1]->value_3),
367  result,(GENERIC)op,funct);
368 }
static long bitvector_bit_code(unsigned long *bv1, long idx, ptr_psi_term result, int op, ptr_psi_term funct)
Definition: sys.c:324
#define REAL
Definition: def_const.h:72
unsigned long * GENERIC
Definition: def_struct.h:17
static long bitvector_unop ( long  op)
static

Definition at line 299 of file sys.c.

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

301 {
302  psi_arg args[1];
303  SETARG(args,0, "1" , sys_bitvector , REQUIRED );
304  return call_primitive(bitvector_unop_internal,NARGS(args),args,(GENERIC)op);
305 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long bitvector_unop_internal(args, result, funct, GENERIC op)
Definition: sys.c:290
#define REQUIRED
Definition: def_const.h:215
ptr_definition sys_bitvector
Definition: def_glob.h:130
#define NARGS(args)
Definition: def_macro.h:169
unsigned long * GENERIC
Definition: def_struct.h:17
static long bitvector_unop_code ( unsigned long *  bv1,
ptr_psi_term  result,
int  op 
)
static

Definition at line 247 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.

251 {
252  unsigned long size1 = *bv1;
253  unsigned char *s1 = ((unsigned char*)bv1)+sizeof(size1);
254  unsigned long i;
255  ptr_psi_term temp_result;
256  unsigned char *s3;
257  switch (op) {
258  case BV_NOT:
259  temp_result = make_bytedata(sys_bitvector,size1);
260  s3 = ((unsigned char *) temp_result->value_3) + sizeof(size1);
261  for(i=0;i<size1;i++) s3[i] = ~(s1[i]);
262  break;
263  case BV_COUNT:
264  {
265  int cnt = 0;
266  register unsigned char c;
267  for(i=0;i<size1;i++) {
268  c=s1[i];
269  if (c & 1<<0) cnt++;
270  if (c & 1<<1) cnt++;
271  if (c & 1<<2) cnt++;
272  if (c & 1<<3) cnt++;
273  if (c & 1<<4) cnt++;
274  if (c & 1<<5) cnt++;
275  if (c & 1<<6) cnt++;
276  if (c & 1<<7) cnt++; }
277  return unify_real_result(result,(REAL) cnt);
278  }
279  break;
280  default: return (c_abort());
281  }
282  push_goal(unify,temp_result,result,NULL);
283  return TRUE;
284 }
#define BV_NOT
Definition: sys.c:243
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
long c_abort()
Definition: built_ins.c:2117
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
#define TRUE
Definition: def_const.h:127
ptr_definition sys_bitvector
Definition: def_glob.h:130
GENERIC value_3
Definition: def_struct.h:170
#define unify
Definition: def_const.h:274
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
#define BV_COUNT
Definition: sys.c:244
static long bitvector_unop_internal ( args  ,
  result,
  funct,
GENERIC  op 
)
static

Definition at line 290 of file sys.c.

References bitvector_unop_code().

293 {
294  return bitvector_unop_code((unsigned long *)args[0]->value_3,
295  result,(GENERIC) op);
296 }
static long bitvector_unop_code(unsigned long *bv1, ptr_psi_term result, int op)
Definition: sys.c:247
unsigned long * GENERIC
Definition: def_struct.h:17
static long c_accept ( )
static

Definition at line 1212 of file sys.c.

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

1213 {
1214  psi_arg args[1];
1215  SETARG(args,0,"1",sys_socket_stream,REQUIRED);
1216  return call_primitive(accept_internal,NARGS(args),args,0);
1217 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long accept_internal(args, result, funct)
Definition: sys.c:1188
#define REQUIRED
Definition: def_const.h:215
ptr_definition sys_socket_stream
Definition: def_glob.h:134
#define NARGS(args)
Definition: def_macro.h:169
static long c_apply1 ( )
static

Definition at line 1698 of file sys.c.

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

1699 {
1700  psi_arg args[3];
1701  SETARG(args,0,"1",top,REQUIRED|NOVALUE);
1702  SETARG(args,1,"2",top,REQUIRED|NOVALUE);
1703  SETARG(args,2,"3",top,REQUIRED|NOVALUE);
1704  return call_primitive(apply1_internal,NARGS(args),args,0);
1705 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define REQUIRED
Definition: def_const.h:215
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
static long apply1_internal(args, result, funct)
Definition: sys.c:1670
static long c_bind ( )
static

Definition at line 1146 of file sys.c.

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

1147 {
1148  psi_arg args[4];
1149  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1150  SETARG(args,1,"host",quoted_string,OPTIONAL);
1151  SETARG(args,2,"port",integer,OPTIONAL);
1152  SETARG(args,3,"path",quoted_string,OPTIONAL);
1154 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
#define NULL
Definition: def_const.h:203
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_definition sys_socket_stream
Definition: def_glob.h:134
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long bind_or_connect_internal(args, result, funct, void *info)
Definition: sys.c:1079
static long c_bitvector_and ( )
static

Definition at line 226 of file sys.c.

References bitvector_binop(), and BV_AND.

227 {
228  return bitvector_binop(BV_AND);
229 }
static long bitvector_binop(long op)
Definition: sys.c:216
#define BV_AND
Definition: sys.c:162
static long c_bitvector_clear ( )
static

Definition at line 393 of file sys.c.

References bitvector_bit(), and BV_CLEAR.

394 {
395  return bitvector_bit(BV_CLEAR);
396 }
#define BV_CLEAR
Definition: sys.c:321
static long bitvector_bit(long op)
Definition: sys.c:371
static long c_bitvector_count ( )
static

Definition at line 314 of file sys.c.

References bitvector_unop(), and BV_COUNT.

315 {
316  return bitvector_unop(BV_COUNT);
317 }
static long bitvector_unop(long op)
Definition: sys.c:299
#define BV_COUNT
Definition: sys.c:244
static long c_bitvector_get ( )
static

Definition at line 381 of file sys.c.

References bitvector_bit(), and BV_GET.

382 {
383  return bitvector_bit(BV_GET);
384 }
static long bitvector_bit(long op)
Definition: sys.c:371
#define BV_GET
Definition: sys.c:319
static long c_bitvector_not ( )
static

Definition at line 308 of file sys.c.

References bitvector_unop(), and BV_NOT.

309 {
310  return bitvector_unop(BV_NOT);
311 }
static long bitvector_unop(long op)
Definition: sys.c:299
#define BV_NOT
Definition: sys.c:243
static long c_bitvector_or ( )
static

Definition at line 232 of file sys.c.

References bitvector_binop(), and BV_OR.

233 {
234  return bitvector_binop(BV_OR);
235 }
#define BV_OR
Definition: sys.c:163
static long bitvector_binop(long op)
Definition: sys.c:216
static long c_bitvector_set ( )
static

Definition at line 387 of file sys.c.

References bitvector_bit(), and BV_SET.

388 {
389  return bitvector_bit(BV_SET);
390 }
#define BV_SET
Definition: sys.c:320
static long bitvector_bit(long op)
Definition: sys.c:371
static long c_bitvector_xor ( )
static

Definition at line 238 of file sys.c.

References bitvector_binop(), and BV_XOR.

239 {
240  return bitvector_binop(BV_XOR);
241 }
#define BV_XOR
Definition: sys.c:164
static long bitvector_binop(long op)
Definition: sys.c:216
static long c_call_once ( )
static

Definition at line 1662 of file sys.c.

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

1663 {
1664  psi_arg args[1];
1665  SETARG(args,0,"1",top,MANDATORY|NOVALUE|UNEVALED);
1666  return call_primitive(call_once_internal,NARGS(args),args,0);
1667 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
static long call_once_internal(args, result, funct)
Definition: sys.c:1644
#define UNEVALED
Definition: def_const.h:216
static long c_connect ( )
static

Definition at line 1157 of file sys.c.

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

1158 {
1159  psi_arg args[4];
1160  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1161  SETARG(args,1,"host",quoted_string,OPTIONAL);
1162  SETARG(args,2,"port",integer,OPTIONAL);
1163  SETARG(args,3,"path",quoted_string,OPTIONAL);
1164  return call_primitive(bind_or_connect_internal,NARGS(args),args,(GENERIC)1);
1165 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_definition sys_socket_stream
Definition: def_glob.h:134
#define NARGS(args)
Definition: def_macro.h:169
unsigned long * GENERIC
Definition: def_struct.h:17
#define OPTIONAL
Definition: def_const.h:214
static long bind_or_connect_internal(args, result, funct, void *info)
Definition: sys.c:1079
static long c_cuserid ( )
static

Definition at line 1494 of file sys.c.

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

1495 {
1496  return call_primitive(cuserid_internal,0,NULL,0);
1497 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define NULL
Definition: def_const.h:203
static long cuserid_internal(args, result, funct)
Definition: sys.c:1482
static long c_errmsg ( )
static

Definition at line 1253 of file sys.c.

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

1254 {
1255  psi_arg args[1];
1256  SETARG(args,0, "1" , integer , OPTIONAL );
1257  return call_primitive(errmsg_internal,NARGS(args),args,0);
1258 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long errmsg_internal(args, result, funct)
Definition: sys.c:1241
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long c_errno ( )
static

Definition at line 1231 of file sys.c.

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

1232 {
1233  return call_primitive(errno_internal,0,NULL,0);
1234 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define NULL
Definition: def_const.h:203
static long errno_internal(args, result, funct)
Definition: sys.c:1223
static long c_fclose ( )
static

Definition at line 642 of file sys.c.

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

643 {
644  psi_arg args[1];
645  SETARG(args,0, "1" , sys_stream , REQUIRED );
646  return call_primitive(fclose_internal,NARGS(args),args,0);
647 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
#define REQUIRED
Definition: def_const.h:215
static long fclose_internal(args, result, funct)
Definition: sys.c:632
#define NARGS(args)
Definition: def_macro.h:169
static long c_fflush ( )
static

Definition at line 684 of file sys.c.

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

685 {
686  psi_arg args[1];
687  SETARG(args,0,"1",sys_stream,MANDATORY);
688  return call_primitive(fflush_internal,NARGS(args),args,0);
689 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
static long fflush_internal(args, result, funct)
Definition: sys.c:673
#define NARGS(args)
Definition: def_macro.h:169
static long c_fopen ( )
static

Definition at line 623 of file sys.c.

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

624 {
625  psi_arg args[2];
626  SETARG(args,0, "1" , quoted_string , REQUIRED );
627  SETARG(args,1, "2" , quoted_string , REQUIRED );
628  return call_primitive(fopen_internal,NARGS(args),args,0);
629 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long fopen_internal(args, result, funct)
Definition: sys.c:607
#define REQUIRED
Definition: def_const.h:215
ptr_definition quoted_string
Definition: def_glob.h:101
#define NARGS(args)
Definition: def_macro.h:169
static long c_fork ( )
static

Definition at line 1326 of file sys.c.

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

1327 {
1328  return call_primitive(fork_internal,0,NULL,0);
1329 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define NULL
Definition: def_const.h:203
static long fork_internal(args, result, funct)
Definition: sys.c:1317
static long c_fseek ( )
static

Definition at line 955 of file sys.c.

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

956 {
957  psi_arg args[3];
958  SETARG(args,0,"1",sys_file_stream,MANDATORY);
959  SETARG(args,1,"2",integer,MANDATORY);
960  SETARG(args,2,"3",integer,OPTIONAL);
961  return call_primitive(fseek_internal,NARGS(args),args,0);
962 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_file_stream
Definition: def_glob.h:133
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long fseek_internal(args, result, funct)
Definition: sys.c:942
static long c_ftell ( )
static

Definition at line 924 of file sys.c.

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

925 {
926  psi_arg args[1];
927  SETARG(args,0,"1",sys_file_stream,REQUIRED);
928  return call_primitive(ftell_internal,NARGS(args),args,0);
929 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_file_stream
Definition: def_glob.h:133
#define REQUIRED
Definition: def_const.h:215
static long ftell_internal(args, result, funct)
Definition: sys.c:911
#define NARGS(args)
Definition: def_macro.h:169
static long c_fwrite ( )
static

Definition at line 664 of file sys.c.

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

665 {
666  psi_arg args[2];
667  SETARG(args,0,"1",sys_stream,MANDATORY);
668  SETARG(args,1,"2",quoted_string,MANDATORY);
669  return call_primitive(fwrite_internal,NARGS(args),args,0);
670 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long fwrite_internal(args, result, funct)
Definition: sys.c:650
ptr_definition sys_stream
Definition: def_glob.h:132
ptr_definition quoted_string
Definition: def_glob.h:101
#define NARGS(args)
Definition: def_macro.h:169
static long c_get_buffer ( )
static

Definition at line 710 of file sys.c.

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

711 {
712  psi_arg args[2];
713  SETARG(args,0,"1",sys_stream,REQUIRED);
714  SETARG(args,1,"2",integer,REQUIRED);
715  return call_primitive(get_buffer_internal,NARGS(args),args,0);
716 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
static long get_buffer_internal(args, result, funct)
Definition: sys.c:692
#define REQUIRED
Definition: def_const.h:215
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
static long c_get_code ( )
static

Definition at line 903 of file sys.c.

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

904 {
905  psi_arg args[1];
906  SETARG(args,0,"1",sys_stream,REQUIRED);
907  return call_primitive(get_code_internal,NARGS(args),args,0);
908 }
static long get_code_internal(args, result, funct)
Definition: sys.c:892
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
#define REQUIRED
Definition: def_const.h:215
#define NARGS(args)
Definition: def_macro.h:169
static long c_get_record ( )
static

Definition at line 883 of file sys.c.

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

884 {
885  psi_arg args[2];
886  SETARG(args,0,"1",sys_stream,REQUIRED);
887  SETARG(args,1,"2",quoted_string,REQUIRED);
888  return call_primitive(get_record_internal,NARGS(args),args,0);
889 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
#define REQUIRED
Definition: def_const.h:215
ptr_definition quoted_string
Definition: def_glob.h:101
static long get_record_internal(args, result, funct)
Definition: sys.c:807
#define NARGS(args)
Definition: def_macro.h:169
static long c_gethostname ( )
static

Definition at line 1516 of file sys.c.

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

1517 {
1519 }
static long gethostname_internal(args, result, funct)
Definition: sys.c:1504
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define NULL
Definition: def_const.h:203
static long c_getpid ( )
static

Definition at line 1715 of file sys.c.

References call_primitive(), and getpid_internal().

1716 {
1717  return call_primitive(getpid_internal,0,0,0);
1718 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
static long getpid_internal(args, result, funct)
Definition: sys.c:1708
static long c_import_symbol ( )
static

Definition at line 1305 of file sys.c.

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

1306 {
1307  psi_arg args[2];
1308  SETARG(args,0,"1",top,MANDATORY|UNEVALED);
1309  SETARG(args,1,"as",top,OPTIONAL|NOVALUE|UNEVALED);
1310  return call_primitive(import_symbol_internal,NARGS(args),args,0);
1311 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
static long import_symbol_internal(args, result, funct)
Definition: sys.c:1269
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
#define UNEVALED
Definition: def_const.h:216
static long c_int2stream ( )
static

Definition at line 598 of file sys.c.

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

599 {
600  psi_arg args[2];
601  SETARG(args,0,"1",integer,REQUIRED);
602  SETARG(args,1,"2",quoted_string,REQUIRED);
603  return call_primitive(int2stream_internal,NARGS(args),args,0);
604 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long int2stream_internal(args, result, funct)
Definition: sys.c:582
#define REQUIRED
Definition: def_const.h:215
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
#define NARGS(args)
Definition: def_macro.h:169
static long c_kill ( )
static

Definition at line 1470 of file sys.c.

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

1471 {
1472  psi_arg args[2];
1473  SETARG(args,0,"1",integer,MANDATORY);
1474  SETARG(args,1,"2",integer,MANDATORY);
1475  return call_primitive(kill_internal,NARGS(args),args,0);
1476 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long kill_internal(args, result, funct)
Definition: sys.c:1462
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
static long c_lazy_project ( )
static

Definition at line 1552 of file sys.c.

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

1553 {
1554  psi_arg args[2];
1555  SETARG(args,0,"1",top,REQUIRED|NOVALUE);
1556  SETARG(args,1,"2",top,REQUIRED|NOVALUE);
1557  return call_primitive(lazy_project_internal,NARGS(args),args,0);
1558 }
static long lazy_project_internal(args, result, funct)
Definition: sys.c:1525
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define REQUIRED
Definition: def_const.h:215
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
static long c_listen ( )
static

Definition at line 1179 of file sys.c.

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

1180 {
1181  psi_arg args[2];
1182  SETARG(args,0,"1",sys_socket_stream,MANDATORY);
1183  SETARG(args,1,"2",integer,MANDATORY);
1184  return call_primitive(listen_internal,NARGS(args),args,0);
1185 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition integer
Definition: def_glob.h:93
ptr_definition sys_socket_stream
Definition: def_glob.h:134
#define NARGS(args)
Definition: def_macro.h:169
static long listen_internal(args, result, funct)
Definition: sys.c:1168
static long c_make_bitvector ( )
static

Definition at line 155 of file sys.c.

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

156 {
157  psi_arg args[1];
158  SETARG(args,0, "1" , integer , REQUIRED );
159  return call_primitive(make_bitvector_internal,NARGS(args),args,0);
160 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
#define REQUIRED
Definition: def_const.h:215
ptr_definition integer
Definition: def_glob.h:93
static long make_bitvector_internal(args, result, funct)
Definition: sys.c:138
#define NARGS(args)
Definition: def_macro.h:169
static long c_my_wait_on_feature ( )
static

Definition at line 1628 of file sys.c.

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

1629 {
1630  psi_arg args[3];
1631  SETARG(args,0,"1",top,MANDATORY|NOVALUE);
1632  SETARG(args,1,"2",top,MANDATORY|NOVALUE);
1633  SETARG(args,2,"3",top,MANDATORY|NOVALUE|UNEVALED);
1634  return call_primitive(my_wait_on_feature_internal,NARGS(args),args,0);
1635 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
static long my_wait_on_feature_internal(args, result, funct)
Definition: sys.c:1600
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
#define UNEVALED
Definition: def_const.h:216
static long c_regexp_compile ( )
static

Definition at line 453 of file sys.c.

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

454 {
455  psi_arg args[1];
456  SETARG(args,0, "1" , quoted_string , REQUIRED );
457  return call_primitive(regexp_compile_internal,NARGS(args),args,0);
458 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long regexp_compile_internal(args, result, funct)
Definition: sys.c:416
#define REQUIRED
Definition: def_const.h:215
ptr_definition quoted_string
Definition: def_glob.h:101
#define NARGS(args)
Definition: def_macro.h:169
static long c_regexp_execute ( )
static

Definition at line 538 of file sys.c.

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

539 {
540  psi_arg args[4];
541  SETARG(args,0, "1" , sys_regexp , REQUIRED );
542  SETARG(args,1, "2" , quoted_string , REQUIRED );
543  SETARG(args,2, "3" , top , OPTIONAL|NOVALUE );
544  SETARG(args,3, "offset" , integer , OPTIONAL );
545  return call_primitive(regexp_execute_internal,NARGS(args),args,0);
546 }
ptr_definition sys_regexp
Definition: def_glob.h:131
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define REQUIRED
Definition: def_const.h:215
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
#define NOVALUE
Definition: def_const.h:220
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long regexp_execute_internal(args, result, funct)
Definition: sys.c:469
static long c_socket ( )
static

Definition at line 1059 of file sys.c.

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

1060 {
1061  psi_arg args[2];
1062  SETARG(args,0,"1",quoted_string,OPTIONAL);
1063  SETARG(args,1,"2",quoted_string,OPTIONAL);
1064  return call_primitive(socket_internal,NARGS(args),args,0);
1065 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long socket_internal(args, result, funct)
Definition: sys.c:1012
ptr_definition quoted_string
Definition: def_glob.h:101
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long c_stream2sys_stream ( )
static

Definition at line 974 of file sys.c.

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

975 {
976  psi_arg args[1];
977  SETARG(args,0,"1",stream,REQUIRED);
978  return call_primitive(stream2sys_stream_internal,NARGS(args),args,0);
979 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition stream
Definition: def_glob.h:103
#define REQUIRED
Definition: def_const.h:215
#define NARGS(args)
Definition: def_macro.h:169
static long stream2sys_stream_internal(args, result, funct)
Definition: sys.c:965
static long c_sys_stream2stream ( )
static

Definition at line 994 of file sys.c.

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

995 {
996  psi_arg args[1];
997  SETARG(args,0,"1",sys_stream,REQUIRED);
998  return call_primitive(sys_stream2stream_internal,NARGS(args),args,0);
999 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition sys_stream
Definition: def_glob.h:132
#define REQUIRED
Definition: def_const.h:215
static long sys_stream2stream_internal(args, result, funct)
Definition: sys.c:982
#define NARGS(args)
Definition: def_macro.h:169
static long c_wait ( )
static

Definition at line 1437 of file sys.c.

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

1438 {
1439  return call_primitive(wait_internal,0,NULL,0);
1440 }
static long wait_internal(args, result, funct)
Definition: sys.c:1428
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define NULL
Definition: def_const.h:203
static long c_wait_on_feature ( )
static

Definition at line 1590 of file sys.c.

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

1591 {
1592  psi_arg args[3];
1593  SETARG(args,0,"1",top,MANDATORY|NOVALUE);
1594  SETARG(args,1,"2",top,MANDATORY|NOVALUE);
1595  SETARG(args,2,"3",top,MANDATORY|NOVALUE|UNEVALED);
1596  return call_primitive(wait_on_feature_internal,NARGS(args),args,0);
1597 }
#define MANDATORY
Definition: def_const.h:219
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
ptr_definition top
Definition: def_glob.h:106
#define NOVALUE
Definition: def_const.h:220
static long wait_on_feature_internal(args, result, funct)
Definition: sys.c:1564
#define NARGS(args)
Definition: def_macro.h:169
#define UNEVALED
Definition: def_const.h:216
static long c_waitpid ( )
static

Definition at line 1453 of file sys.c.

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

1454 {
1455  psi_arg args[2];
1456  SETARG(args,0,"1",integer,REQUIRED);
1457  SETARG(args,1,"2",integer,OPTIONAL);
1458  return call_primitive(waitpid_internal,NARGS(args),args,0);
1459 }
long call_primitive(long(*fun)(), int num, argi, GENERIC info)
Definition: sys.c:12
#define SETARG(args, i, the_feature, the_type, the_options)
Definition: def_macro.h:163
static long waitpid_internal(args, result, funct)
Definition: sys.c:1443
#define REQUIRED
Definition: def_const.h:215
ptr_definition integer
Definition: def_glob.h:93
#define NARGS(args)
Definition: def_macro.h:169
#define OPTIONAL
Definition: def_const.h:214
static long call_once_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1644 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.

1646 {
1647  ptr_psi_term value;
1649  resid_aim=NULL;
1650  value = stack_psi_term(4);
1651  value->type = lf_false;
1652  push_choice_point(unify,result,value,NULL);
1653  value = stack_psi_term(4);
1654  value->type = lf_true;
1655  push_goal(unify,result,value,NULL);
1658  return TRUE;
1659 }
#define prove
Definition: def_const.h:273
void push_choice_point(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:591
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define general_cut
Definition: def_const.h:282
#define DEFRULES
Definition: def_const.h:138
#define NULL
Definition: def_const.h:203
ptr_goal resid_aim
Definition: def_glob.h:220
#define TRUE
Definition: def_const.h:127
ptr_definition lf_true
Definition: def_glob.h:107
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
ptr_definition lf_false
Definition: def_glob.h:89
#define unify
Definition: def_const.h:274
ptr_definition type
Definition: def_struct.h:165
ptr_choice_point choice_stack
Definition: def_glob.h:51
long call_primitive ( long (*)()  fun,
int  num,
argi  ,
GENERIC  info 
)

Definition at line 12 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.

17 {
18  ptr_psi_term funct,arg,result,argo[ARGNN]; /* no more than 10 arguments */
19  ptr_node n;
20  int allargs=1,allvalues=1,i;
21  funct=aim->aaaa_1;
22  deref_ptr(funct);
23  result=aim->bbbb_1;
24  for (i=0;i<num;i++) {
25  n=find(FEATCMP,argi[i].feature,funct->attr_list);
26  /* argument present */
27  if (n) {
28  arg = (ptr_psi_term) n->data;
29  /* in case we don't want to evaluate the argument
30  just follow the chain of corefs and don't do
31  any of the other checks: they'll have do be done
32  by fun; just go on to the next arg */
33  if (argi[i].options&UNEVALED) {
34  deref_ptr(arg);
35  argo[i]=arg;
36  continue; }
37  /* this arg should be evaled */
38  deref(arg);
39  argo[i]=arg;
40  /* arg of admissible type */
41  if (argi[i].options&POLYTYPE) {
42  ptr_definition *type = (ptr_definition *)argi[i].type;
43  while (*type != NULL)
44  if (overlap_type(arg->type,*type))
45  goto admissible;
46  else type++;
47  }
48  else {
49  if (overlap_type(arg->type,argi[i].type))
50  goto admissible;
51  }
52  /* not admissible */
53  if (argi[i].options&JUSTFAIL) return FALSE;
54  Errorline("Illegal argument in %P.\n",funct);
55  return (c_abort());
56  /* admissible */
57  admissible:
58  /* has value */
59  if (arg->value_3) {
60  ptr_definition *type = (ptr_definition *)argi[i].type;
61  /* paranoid check: really correct type */
62  if (argi[i].options&POLYTYPE) {
63  while (*type != NULL)
64  if (sub_type(arg->type,*type))
65  goto correct;
66  else type++;
67  }
68  else {
69  if (sub_type(arg->type,(ptr_definition)type)) goto correct;
70  }
71  /* type incorrect */
72  if (argi[i].options&JUSTFAIL) return FALSE;
73  Errorline("Illegal argument in %P.\n",funct);
74  return (c_abort());
75  /* correct */
76  correct:;
77  }
78  /* missing value - do we need it */
79  else if (!(argi[i].options&NOVALUE)) allvalues=0;
80  }
81  /* argument missing */
82  else {
83  argo[i]=NULL;
84  if (argi[i].options&MANDATORY) {
85  Errorline("Missing argument '%s' in %P.\n",argi[i].feature,funct);
86  return (c_abort());
87  }
88  else if (argi[i].options&REQUIRED) allargs=0;
89  }
90  }
91  if (allargs)
92  if (allvalues) {
93  return fun(argo,result,funct,info);
94  }
95  else {
96  for (i=0;i<num;i++) {
97  /* if arg present and should be evaled but has no value */
98  if (argo[i] && !(argi[i].options&UNEVALED) && !argo[i]->value_3)
99  residuate(argo[i]);
100  }
101  }
102  else curry();
103  return TRUE;
104 }
ptr_psi_term aaaa_1
Definition: def_struct.h:224
#define MANDATORY
Definition: def_const.h:219
#define FEATCMP
Definition: def_const.h:257
void residuate(ptr_psi_term t)
Definition: lefun.c:113
long c_abort()
Definition: built_ins.c:2117
GENERIC data
Definition: def_struct.h:185
void curry()
Definition: lefun.c:157
#define NULL
Definition: def_const.h:203
long overlap_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1486
#define JUSTFAIL
Definition: def_const.h:217
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
void Errorline(char *format,...)
Definition: error.c:414
#define deref_ptr(P)
Definition: def_macro.h:95
#define REQUIRED
Definition: def_const.h:215
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define deref(P)
Definition: def_macro.h:142
GENERIC value_3
Definition: def_struct.h:170
ptr_goal aim
Definition: def_glob.h:49
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
#define NOVALUE
Definition: def_const.h:220
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_node attr_list
Definition: def_struct.h:171
#define ARGNN
Definition: def_const.h:347
#define POLYTYPE
Definition: def_const.h:218
#define UNEVALED
Definition: def_const.h:216
void check_sys_definitions ( )

Definition at line 1740 of file sys.c.

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

1741 {
1742  check_definition(&sys_bytedata); /* DENYS: BYTEDATA */
1753 #ifdef LIFE_NDBM
1754  check_ndbm_definitions();
1755 #endif
1756 }
ptr_definition sys_regexp
Definition: def_glob.h:131
ptr_definition sys_file_stream
Definition: def_glob.h:133
ptr_definition sys_stream
Definition: def_glob.h:132
ptr_definition sys_process_signaled
Definition: sys.c:1379
ptr_definition sys_bitvector
Definition: def_glob.h:130
ptr_definition sys_process_stopped
Definition: sys.c:1380
ptr_definition sys_process_continued
Definition: sys.c:1381
void check_definition(ptr_definition *d)
Definition: memory.c:612
ptr_definition sys_bytedata
Definition: def_glob.h:336
ptr_definition sys_socket_stream
Definition: def_glob.h:134
ptr_definition sys_process_exited
Definition: sys.c:1378
ptr_definition sys_process_no_children
Definition: sys.c:1377
static long cuserid_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1482 of file sys.c.

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

1484 {
1485  // char name[L_cuserid+1];
1486  // if (*cuserid(name) == '\0') return FALSE;
1487  // else {
1488  push_goal(unify,result,stack_string(getlogin()),NULL);
1489  return TRUE;
1490  // }
1491 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
#define unify
Definition: def_const.h:274
ptr_psi_term stack_string(char *s)
Definition: built_ins.c:102
static long errmsg_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1241 of file sys.c.

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

1243 {
1244  long n = args[0]?(long)*(REAL*)args[0]->value_3:errno;
1245  // if (n<0 || n>=sys_nerr) return FALSE;
1246  // else {
1247  push_goal(unify,stack_string(strerror(n)),result,NULL);
1248  return TRUE;
1249  // }
1250 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
#define TRUE
Definition: def_const.h:127
#define unify
Definition: def_const.h:274
ptr_psi_term stack_string(char *s)
Definition: built_ins.c:102
static long errno_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1223 of file sys.c.

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

1225 {
1226  push_goal(unify,stack_int(errno),result,NULL);
1227  return TRUE;
1228 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
ptr_psi_term stack_int(long n)
Definition: built_ins.c:87
#define unify
Definition: def_const.h:274
static long fclose_internal ( args  ,
  result,
  funct 
)
static

Definition at line 632 of file sys.c.

References BYTEDATA_DATA, FALSE, and TRUE.

634 {
635  if (fclose(((ptr_stream)BYTEDATA_DATA(args[0]))->fp) != 0)
636  return FALSE;
637  else
638  return TRUE;
639 }
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
static long fflush_internal ( args  ,
  result,
  funct 
)
static

Definition at line 673 of file sys.c.

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

675 {
676  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
677  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
678  srm->op = FP_NONE;
679  if (fflush(srm->fp)!=0) return FALSE;
680  return TRUE;
681 }
FILE * fp
Definition: sys.c:563
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:558
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
int op
Definition: sys.c:564
ptr_psi_term fileptr2stream ( FILE*  fp,
ptr_definition  typ 
)

Definition at line 571 of file sys.c.

References BYTEDATA_DATA, FP_NONE, and make_bytedata().

574 {
575  ptr_psi_term result = make_bytedata(typ,sizeof(struct a_stream));
576  ((ptr_stream)BYTEDATA_DATA(result))->fp = fp;
577  ((ptr_stream)BYTEDATA_DATA(result))->op = FP_NONE;
578  return result;
579 }
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:558
#define BYTEDATA_DATA(X)
Definition: sys.c:128
Definition: sys.c:562
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
static long fopen_internal ( args  ,
  result,
  funct 
)
static

Definition at line 607 of file sys.c.

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

609 {
610  FILE *fp = fopen((char*)args[0]->value_3,
611  (char*)args[1]->value_3);
612  if (fp==NULL) return FALSE;
613  else {
614 /* ptr_psi_term temp_result = make_bytedata(sys_file_stream,sizeof(fp));
615  *(FILE**)BYTEDATA_DATA(temp_result) = fp;
616 */
617  push_goal(unify,fileptr2stream(fp,sys_file_stream),result,NULL); // added & DJD
618  return TRUE;
619  }
620 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_definition sys_file_stream
Definition: def_glob.h:133
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
Definition: sys.c:571
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
static long fork_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1317 of file sys.c.

References FALSE, REAL, and unify_real_result().

1319 {
1320  pid_t id = fork();
1321  if (id < 0) return FALSE;
1322  else return unify_real_result(result,(REAL)id);
1323 }
#define REAL
Definition: def_const.h:72
#define FALSE
Definition: def_const.h:128
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
static long fseek_internal ( args  ,
  result,
  funct 
)
static

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

Definition at line 942 of file sys.c.

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

944 {
945  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
946  srm->op = FP_NONE;
947  return
948  (fseek(srm->fp ,
949  (long)*(REAL*)args[1]->value_3,
950  args[2]?(long)*(REAL*)args[2]->value_3:SEEK_SET) < 0)
951  ?FALSE:TRUE;
952 }
FILE * fp
Definition: sys.c:563
#define REAL
Definition: def_const.h:72
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:558
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
int op
Definition: sys.c:564
#define SEEK_SET
Definition: sys.c:932
static long ftell_internal ( args  ,
  result,
  funct 
)
static

Definition at line 911 of file sys.c.

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

913 {
914  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
915  if (srm->op != FP_NONE || srm->op != FP_INPUT) {
916  fflush(srm->fp);
917  srm->op = FP_NONE;
918  }
919  return unify_real_result(result,(REAL)ftell(srm->fp));
920 /* *(FILE**)BYTEDATA_DATA(args[0])));*/
921 }
FILE * fp
Definition: sys.c:563
#define REAL
Definition: def_const.h:72
struct a_stream * ptr_stream
#define FP_NONE
Definition: sys.c:558
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define FP_INPUT
Definition: sys.c:559
Definition: sys.c:562
int op
Definition: sys.c:564
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
static long fwrite_internal ( args  ,
  result,
  funct 
)
static

Definition at line 650 of file sys.c.

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

652 {
653  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
654  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
655  char* txt = (char*)args[1]->value_3;
656  FP_PREPARE(srm,FP_OUTPUT);
657  if (txt && *txt!='\0' &&
658  fwrite((void*)txt,sizeof(char),strlen(txt),srm->fp)<=0)
659  return FALSE;
660  return TRUE;
661 }
FILE * fp
Definition: sys.c:563
#define FP_OUTPUT
Definition: sys.c:560
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
#define FP_PREPARE(s, OP)
Definition: sys.c:567
static long get_buffer_internal ( args  ,
  result,
  funct 
)
static

Definition at line 692 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.

694 {
695  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
696  /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
697  long size = *(REAL*)args[1]->value_3;
699  t->type = quoted_string;
700  t->value_3=(GENERIC)heap_alloc(size+1);
701  bzero((char*)t->value_3,size+1);
702  FP_PREPARE(srm,FP_INPUT);
703  if (fread((void*)t->value_3,sizeof(char),size,srm->fp) <= 0)
704  return FALSE;
705  push_goal(unify,t,result,NULL);
706  return TRUE;
707 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
FILE * fp
Definition: sys.c:563
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
#define FP_INPUT
Definition: sys.c:559
#define unify
Definition: def_const.h:274
Definition: sys.c:562
#define FP_PREPARE(s, OP)
Definition: sys.c:567
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
GENERIC heap_alloc(long s)
Definition: memory.c:1518
static long get_code_internal ( args  ,
  result,
  funct 
)
static

Definition at line 892 of file sys.c.

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

894 {
895  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
896  int c;
897  FP_PREPARE(srm,FP_INPUT);
898  if ((c=getc(srm->fp)) == EOF) return FALSE;
899  else return unify_real_result(result,(REAL)c);
900 }
FILE * fp
Definition: sys.c:563
#define REAL
Definition: def_const.h:72
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define FALSE
Definition: def_const.h:128
#define FP_INPUT
Definition: sys.c:559
Definition: sys.c:562
#define FP_PREPARE(s, OP)
Definition: sys.c:567
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
char* get_numeric_feature ( long  n)

Definition at line 1360 of file sys.c.

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

1362 {
1363  if (n==1) return one;
1364  else if (n==2) return two;
1365  else if (n==3) return three;
1366  else {
1367  char buf[100];
1368  (void)snprintf(buf,100,"%ld",n);
1369  return heap_copy_string(buf);
1370  }
1371 }
char * two
Definition: def_glob.h:251
char * three
Definition: def_glob.h:252
char * heap_copy_string(char *s)
Definition: trees.c:147
char * one
Definition: def_glob.h:250
static long get_record_internal ( args  ,
  result,
  funct 
)
static

Definition at line 807 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.

809 {
810  struct text_buffer rootbuf;
811  struct text_buffer *curbuf = &rootbuf;
812  struct text_buffer *lastbuf = &rootbuf;
813  int lastidx = 0,size;
814  ptr_stream srm = (ptr_stream)BYTEDATA_DATA(args[0]);
815  FILE *fp = srm->fp; /*FILE* fp = *(FILE**)BYTEDATA_DATA(args[0]);*/
816  char *sep = (char*)args[1]->value_3;
817  int c;
818  ptr_psi_term t;
819  char *cursep = sep;
820 
821  FP_PREPARE(srm,FP_INPUT);
822  bzero((char*)&rootbuf,sizeof(rootbuf));
823  if (!sep || !*sep) {
824  /* no separator: just grab as much as you can */
825  while ((c=getc(fp)) != EOF)
826  text_buffer_push(&curbuf,(char)c);
827  goto PackUpAndLeave;
828  }
829 
830  if (sep[1]=='\0') {
831  /* only one char in string */
832  while ((c=getc(fp)) != EOF) {
833  text_buffer_push(&curbuf,(char)c);
834  if (c==*sep) break;
835  }
836  goto PackUpAndLeave;
837  }
838 
839  /* general case: multicharacter separator */
840 
841  WaitForStart:
842  if ((c=getc(fp)) == EOF) goto PackUpAndLeave;
843  text_buffer_push(&curbuf,(char)c);
844  if (c==*sep) {
845  cursep = sep+1;
846  lastbuf=curbuf;
847  lastidx=curbuf->top - 1;
848  goto MatchNext;
849  }
850  else goto WaitForStart;
851 
852  MatchNext:
853  if (!*cursep || (c=getc(fp))==EOF) goto PackUpAndLeave;
854  text_buffer_push(&curbuf,(char)c);
855  if (c!=*cursep) goto TryAgain;
856  cursep++;
857  goto MatchNext;
858 
859  TryAgain:
860  if (!text_buffer_next(lastbuf,lastidx+1,*sep,&lastbuf,&lastidx))
861  goto WaitForStart;
862  if (!(cursep=text_buffer_cmp(lastbuf,lastidx,sep)))
863  goto TryAgain;
864  goto MatchNext;
865 
866  PackUpAndLeave:
867  /* compute how much space we need */
868  for(lastbuf=&rootbuf,size=0;lastbuf!=NULL;lastbuf=lastbuf->next)
869  size += lastbuf->top;
870  t=stack_psi_term(0);
871  t->type=quoted_string;
872  t->value_3=(GENERIC)heap_alloc(size+1);
873  for(lastbuf=&rootbuf,sep=(char*)t->value_3;
874  lastbuf!=NULL;sep+=lastbuf->top,lastbuf=lastbuf->next)
875  bcopy(lastbuf->data,sep,lastbuf->top);
876  ((char*)t->value_3)[size]='\0';
877  text_buffer_free(rootbuf.next);
878  push_goal(unify,t,result,NULL);
879  return TRUE;
880 }
char * text_buffer_cmp(struct text_buffer *buf, int idx, char *str)
Definition: sys.c:748
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
void text_buffer_free(struct text_buffer *buf)
Definition: sys.c:795
FILE * fp
Definition: sys.c:563
#define NULL
Definition: def_const.h:203
struct a_stream * ptr_stream
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
int text_buffer_next(struct text_buffer *buf, int idx, char c, struct text_buffer **rbuf, int *ridx)
Definition: sys.c:724
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
#define FP_INPUT
Definition: sys.c:559
#define unify
Definition: def_const.h:274
Definition: sys.c:562
#define FP_PREPARE(s, OP)
Definition: sys.c:567
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
struct text_buffer * next
Definition: def_struct.h:399
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void text_buffer_push(struct text_buffer **buf, char c)
Definition: sys.c:773
static long gethostname_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1504 of file sys.c.

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

1506 {
1507  char name_loc[MAXHOSTNAMELEN+1];
1508  if (gethostname(name_loc,MAXHOSTNAMELEN+1) == 0) {
1509  push_goal(unify,result,stack_string(name_loc),NULL);
1510  return TRUE;
1511  }
1512  else return FALSE;
1513 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
ptr_psi_term stack_string(char *s)
Definition: built_ins.c:102
static long getpid_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1708 of file sys.c.

References REAL, and unify_real_result().

1710 {
1711  return unify_real_result(result,(REAL)getpid());
1712 }
#define REAL
Definition: def_const.h:72
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
static long import_symbol_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1269 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(), make_module_token(), wl_keyword::module, wl_keyword::private_feature, wl_keyword::public, wl_keyword::symbol, wl_module::symbol_table, TRUE, wl_definition::type_def, and undef.

1271 {
1272  ptr_keyword key;
1273 
1274  if (args[1])
1275  key=args[1]->type->keyword;
1276  else
1278  args[0]->type->keyword->symbol);
1279 
1280  if (key)
1281  if (key->definition->type_def != (def_type)undef) {
1282  Errorline("symbol %s already defined in %P.",key->combined_name,funct);
1283  return FALSE;
1284  }
1285  else key->definition=args[0]->type;
1286  else {
1287  /* adapted from update_symbol in modules.c */
1288  /* Add 'module#symbol' to the symbol table */
1289  key=HEAP_ALLOC(struct wl_keyword);
1290  key->module=current_module;
1291  /* use same name */
1292  key->symbol=args[0]->type->keyword->symbol;
1293  key->combined_name=(char *)
1295  key->public=FALSE;
1296  key->private_feature=FALSE;
1297  key->definition=args[0]->type; /* use given definition */
1298 
1300  }
1301  return TRUE;
1302 }
ptr_keyword hash_lookup(ptr_hash_table table, char *symbol)
Definition: hash_table.c:133
char * combined_name
Definition: def_struct.h:92
ptr_module current_module
Definition: def_glob.h:161
char * make_module_token(ptr_module module, char *str)
Definition: modules.c:185
#define undef
Definition: def_const.h:360
ptr_definition definition
Definition: def_struct.h:96
def_type type_def
Definition: def_struct.h:133
ptr_hash_table symbol_table
Definition: def_struct.h:79
char * symbol
Definition: def_struct.h:91
void Errorline(char *format,...)
Definition: error.c:414
char * heap_copy_string(char *s)
Definition: trees.c:147
void hash_insert(ptr_hash_table table, char *symbol, ptr_keyword keyword)
Definition: hash_table.c:155
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
ptr_module module
Definition: def_struct.h:90
int private_feature
Definition: def_struct.h:95
int public
Definition: def_struct.h:94
#define HEAP_ALLOC(A)
Definition: def_macro.h:15
void insert_sys_builtins ( )

Definition at line 1760 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, set_current_module(), sys_bitvector, sys_bytedata, sys_file_stream, sys_module, sys_regexp, sys_socket_stream, sys_stream, and update_symbol().

1761 {
1762  ptr_module curmod = current_module;
1764 
1765  sys_bytedata =update_symbol(sys_module,"bytedata"); /* DENYS: BYTEDATA */
1766  sys_bitvector =update_symbol(sys_module,"bitvector");
1767  sys_regexp =update_symbol(sys_module,"regexp");
1768  sys_stream =update_symbol(sys_module,"stream");
1769  sys_file_stream =update_symbol(sys_module,"file_stream");
1770  sys_socket_stream =update_symbol(sys_module,"socket_stream");
1771  sys_process_no_children=update_symbol(sys_module,"process_no_children");
1772  sys_process_exited =update_symbol(sys_module,"process_exited");
1773  sys_process_signaled =update_symbol(sys_module,"process_signaled");
1774  sys_process_stopped =update_symbol(sys_module,"process_stopped");
1775  sys_process_continued =update_symbol(sys_module,"process_continued");
1776 
1777  /* DENYS: BYTEDATA */
1778  /* purely for illustration
1779  new_built_in(sys_module,"string_to_bytedata",(def_type)function_it,c_string_to_bytedata);
1780  new_built_in(sys_module,"bytedata_to_string",(def_type)function_it,c_bytedata_to_string);
1781  */
1824 #ifdef LIFE_DBM
1826 #endif
1827 #ifdef LIFE_NDBM
1828  insert_ndbm_builtins();
1829 #endif
1832  (void)set_current_module(curmod);
1833 }
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
Definition: built_ins.c:5054
#define predicate
Definition: def_const.h:361
#define function_it
Definition: def_const.h:362
ptr_definition sys_regexp
Definition: def_glob.h:131
static long c_make_bitvector()
Definition: sys.c:155
static long c_bitvector_not()
Definition: sys.c:308
static long c_wait()
Definition: sys.c:1437
ptr_module current_module
Definition: def_glob.h:161
static long c_accept()
Definition: sys.c:1212
static long c_fwrite()
Definition: sys.c:664
static long c_call_once()
Definition: sys.c:1662
static long c_stream2sys_stream()
Definition: sys.c:974
static long c_ftell()
Definition: sys.c:924
static long c_regexp_compile()
Definition: sys.c:453
static long c_int2stream()
Definition: sys.c:598
static long c_kill()
Definition: sys.c:1470
ptr_definition sys_file_stream
Definition: def_glob.h:133
static long c_fseek()
Definition: sys.c:955
static long c_get_record()
Definition: sys.c:883
ptr_definition sys_stream
Definition: def_glob.h:132
static long c_getpid()
Definition: sys.c:1715
static long c_get_code()
Definition: sys.c:903
static long c_bitvector_set()
Definition: sys.c:387
static long c_fclose()
Definition: sys.c:642
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
static long c_apply1()
Definition: sys.c:1698
static long c_bitvector_xor()
Definition: sys.c:238
static long c_fflush()
Definition: sys.c:684
static long c_fopen()
Definition: sys.c:623
static long c_connect()
Definition: sys.c:1157
static long c_listen()
Definition: sys.c:1179
static long c_import_symbol()
Definition: sys.c:1305
static long c_waitpid()
Definition: sys.c:1453
ptr_definition sys_process_signaled
Definition: sys.c:1379
ptr_definition sys_bitvector
Definition: def_glob.h:130
static long c_fork()
Definition: sys.c:1326
ptr_definition sys_process_stopped
Definition: sys.c:1380
ptr_definition sys_process_continued
Definition: sys.c:1381
static long c_bitvector_count()
Definition: sys.c:314
void insert_dbm_builtins()
static long c_wait_on_feature()
Definition: sys.c:1590
static long c_bind()
Definition: sys.c:1146
static long c_errno()
Definition: sys.c:1231
static long c_regexp_execute()
Definition: sys.c:538
ptr_module sys_module
Definition: def_glob.h:162
static long c_cuserid()
Definition: sys.c:1494
static long c_bitvector_or()
Definition: sys.c:232
static long c_socket()
Definition: sys.c:1059
ptr_definition sys_bytedata
Definition: def_glob.h:336
ptr_definition sys_socket_stream
Definition: def_glob.h:134
ptr_definition sys_process_exited
Definition: sys.c:1378
static long c_bitvector_and()
Definition: sys.c:226
static long c_lazy_project()
Definition: sys.c:1552
static long c_my_wait_on_feature()
Definition: sys.c:1628
static long c_bitvector_get()
Definition: sys.c:381
static long c_bitvector_clear()
Definition: sys.c:393
ptr_module bi_module
Definition: def_glob.h:155
static long c_sys_stream2stream()
Definition: sys.c:994
static long c_gethostname()
Definition: sys.c:1516
ptr_module set_current_module(ptr_module module)
Definition: modules.c:95
static long c_get_buffer()
Definition: sys.c:710
ptr_definition sys_process_no_children
Definition: sys.c:1377
static long c_errmsg()
Definition: sys.c:1253
static long int2stream_internal ( args  ,
  result,
  funct 
)
static

Definition at line 582 of file sys.c.

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

584 {
585  FILE *fp = fdopen((int)*(REAL*)args[0]->value_3,
586  (char*)args[1]->value_3);
587  if (fp==NULL) return FALSE;
588  else {
589  push_goal(unify,fileptr2stream(fp,sys_stream),result,NULL); // added & DJD
590 /* ptr_psi_term temp_result = make_bytedata(sys_stream,sizeof(fp));
591  *(FILE**)BYTEDATA_DATA(temp_result) = fp;
592  push_goal(unify,temp_result,result,NULL); */
593  return TRUE;
594  }
595 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
Definition: sys.c:571
ptr_definition sys_stream
Definition: def_glob.h:132
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
int is_ipaddr ( char*  s)

Definition at line 1068 of file sys.c.

References NULL.

1070 {
1071  if (s==NULL) return 0;
1072  while (*s)
1073  if (!isdigit(*s) && *s!='.') return 0;
1074  else s++;
1075  return 1;
1076 }
#define NULL
Definition: def_const.h:203
static long kill_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1462 of file sys.c.

References FALSE, REAL, and TRUE.

1464 {
1465  return (kill((pid_t)*(REAL*)args[0]->value_3,
1466  (int)*(REAL*)args[1]->value_3)==0)?TRUE:FALSE;
1467 }
#define REAL
Definition: def_const.h:72
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
static long lazy_project_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1525 of file sys.c.

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

1527 {
1528  ptr_node n;
1529  char buffer_loc[100];
1530  if (args[1]->type == top) {
1531  residuate(args[0]);
1532  residuate(args[1]);
1533  return TRUE;
1534  }
1535  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1536  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
1537  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1538  strcpy(buffer_loc,(char*)args[1]->value_3);
1539  else
1540  strcpy(buffer_loc,args[1]->type->keyword->symbol);
1541  n=find(FEATCMP,buffer_loc,args[0]->attr_list);
1542  if (n) push_goal(unify,(ptr_psi_term)n->data,result,NULL);
1543  /* this is all bullshit because projection should residuate
1544  on its 2nd arg until it becomes value. In particular, think
1545  of using `int' as a feature when it is clear that `int' may
1546  subsequently be refined to a particular integer. */
1547  else residuate(args[0]);
1548  return TRUE;
1549 }
#define FEATCMP
Definition: def_const.h:257
void residuate(ptr_psi_term t)
Definition: lefun.c:113
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
GENERIC data
Definition: def_struct.h:185
ptr_definition top
Definition: def_glob.h:106
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
#define unify
Definition: def_const.h:274
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
static long listen_internal ( args  ,
  result,
  funct 
)
static

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

Definition at line 1168 of file sys.c.

References BYTEDATA_DATA, FALSE, REAL, and TRUE.

1170 {
1171  int fd = fileno(((ptr_stream)BYTEDATA_DATA(args[0]))->fp);
1172  int n = *(REAL*)args[1]->value_3;
1173 
1174  if (listen(fd,n) < 0) return FALSE;
1175  return TRUE;
1176 }
#define REAL
Definition: def_const.h:72
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
Definition: sys.c:562
static long make_bitvector_internal ( args  ,
  result,
  funct 
)
static

Definition at line 138 of file sys.c.

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

140 {
141  long bits = *(REAL *)args[0]->value_3;
142  if (bits < 0) {
143  Errorline("negative argument in %P.\n",funct);
144  return FALSE; }
145  else {
146  unsigned long bytes = bits / sizeof(char);
147  ptr_psi_term temp_result;
148  if ((bits % sizeof(char)) != 0) bytes++;
149  temp_result = make_bytedata(sys_bitvector,bytes);
150  push_goal(unify,temp_result,result,NULL);
151  return TRUE; }
152 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
void Errorline(char *format,...)
Definition: error.c:414
#define TRUE
Definition: def_const.h:127
ptr_definition sys_bitvector
Definition: def_glob.h:130
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
static ptr_psi_term make_bytedata ( ptr_definition  sort,
unsigned long  bytes 
)
static

Definition at line 113 of file sys.c.

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

116 {
117  ptr_psi_term temp_result;
118  char *b = (char *) heap_alloc(bytes+sizeof(bytes));
119  *((long *) b) = bytes;
120  bzero(b+sizeof(bytes),bytes);
121  temp_result=stack_psi_term(0);
122  temp_result->type=sort;
123  temp_result->value_3=(GENERIC)b;
124  return temp_result;
125 }
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
GENERIC heap_alloc(long s)
Definition: memory.c:1518
void make_sys_type_links ( )

Definition at line 1726 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.

1727 {
1728 #ifdef LIFE_NDBM
1729  make_ndbm_type_links();
1730 #endif
1736  make_type_link(sys_bytedata ,built_in); /* DENYS: BYTEDATA */
1737 }
ptr_definition sys_regexp
Definition: def_glob.h:131
ptr_definition sys_file_stream
Definition: def_glob.h:133
ptr_definition sys_stream
Definition: def_glob.h:132
ptr_definition sys_bitvector
Definition: def_glob.h:130
ptr_definition built_in
Definition: def_glob.h:75
void make_type_link(ptr_definition t1, ptr_definition t2)
Definition: types.c:848
ptr_definition sys_bytedata
Definition: def_glob.h:336
ptr_definition sys_socket_stream
Definition: def_glob.h:134
static long my_wait_on_feature_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1600 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().

1602 {
1603  char buffer_loc[100];
1604  if (args[1]->type == top) {
1605  residuate(args[0]);
1606  residuate(args[1]);
1607  return TRUE;
1608  }
1609  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1610  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
1611  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1612  strcpy(buffer_loc,(char*)args[1]->value_3);
1613  else
1614  strcpy(buffer_loc,args[1]->type->keyword->symbol);
1615  if (find(FEATCMP,buffer_loc,args[0]->attr_list)) {
1616  unify_bool_result(result,TRUE);
1618  }
1619  /* this is all bullshit because projection should residuate
1620  on its 2nd arg until it becomes value. In particular, think
1621  of using `int' as a feature when it is clear that `int' may
1622  subsequently be refined to a particular integer. */
1623  else residuate(args[0]);
1624  return TRUE;
1625 }
#define prove
Definition: def_const.h:273
#define FEATCMP
Definition: def_const.h:257
void residuate(ptr_psi_term t)
Definition: lefun.c:113
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
#define DEFRULES
Definition: def_const.h:138
ptr_definition top
Definition: def_glob.h:106
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
void regerror ( char*  s)

Definition at line 404 of file sys.c.

406 {
407  fprintf(stderr,"Regexp Error: %s\n",s);
408 }
static long regexp_compile_internal ( args  ,
  result,
  funct 
)
static

Definition at line 416 of file sys.c.

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

418 {
419  ptr_psi_term temp_result;
420  regexp * re = regcomp((char *)args[0]->value_3);
421  long bytes;
422  if (re == NULL) {
423  Errorline("compilation of regular expression failed in %P.\n",funct);
424  return (c_abort()); }
425  /* compute the size of the regexp stuff. this is essentially the size
426  of the regexp structure + the size of the program (bytecode) including
427  the final END opcode (i.e. 0), hence the + 1, minus the bytes that we
428  have counted twice, i.e. those between the start of the program and
429  the computed end of the regexp structure (i.e. in case a regexp
430  struct is larger, maybe to respect alignment constraints, than it has
431  to be, and also to count the 1 byte of program included in the decl
432  of struct regexp */
433  bytes = last_regsize();
434  temp_result = make_bytedata(sys_regexp,bytes);
435  /* now let's copy the regexp stuff into the bytedata block. The regmust
436  field must be treated specially because it is a pointer into program:
437  we cannot simply change it to reflect the location where the program
438  will be copied to because that may well change over time: the gc may
439  relocate the bytedata block. Instead, we convert regmust into an
440  offset and each time we need to pass it to regexec or regsub we must
441  first convert it back into a pointer then back into an offset when we
442  are done. Note that, if regmust is NULL we must leave it that way */
443  if (re->regmust != NULL)
444  re->regmust = (char *) ((unsigned long) (re->regmust - (char *)re));
445  bcopy((char*)re,((char*)temp_result->value_3)+sizeof(unsigned long),bytes);
446  free(re); /* free the regexp: no longer needed */
447  /* return result */
448  push_goal(unify,temp_result,result,NULL);
449  return TRUE;
450 }
ptr_definition sys_regexp
Definition: def_glob.h:131
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
long c_abort()
Definition: built_ins.c:2117
#define NULL
Definition: def_const.h:203
void Errorline(char *format,...)
Definition: error.c:414
#define TRUE
Definition: def_const.h:127
GENERIC value_3
Definition: def_struct.h:170
#define unify
Definition: def_const.h:274
static ptr_psi_term make_bytedata(ptr_definition sort, unsigned long bytes)
Definition: sys.c:113
static long regexp_execute_internal ( args  ,
  result,
  funct 
)
static

Definition at line 469 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, and unify_bool_result().

471 {
472  regexp * re = (regexp*)(((char *)args[0]->value_3)+sizeof(unsigned long));
473  char * must = re->regmust;
474  long offset = 0;
475  // long success = TRUE;
476  /* check that args[3] aka "offset" is valid if present */
477  if (args[3]) {
478  offset = *(REAL*)args[3]->value_3;
479  if (offset < 0 || offset > strlen((char*)args[1]->value_3)) {
480  Errorline("Illegal offset in %P.\n",funct);
481  return (c_abort()); }
482  }
483  /* convert regmust from offset into a pointer if not NULL */
484  if (must != NULL)
485  re->regmust = (char*)re+(unsigned long)must;
486  /* perform operation */
487  if (regexec(re,((char *)args[1]->value_3) + offset) == 0) {
488  if (must != NULL) re->regmust = must; /* back into an offset */
489  return FALSE;
490  }
491  else {
492  /* construct result of match */
493  char **sp = re->startp;
494  char **ep = re->endp;
495  int i;
496  char buffer_loc[5]; /* in case NSUBEXP ever gets increased */
497  ptr_node n3;
498  if (must != NULL) re->regmust = must; /* back into an offset */
499  if (args[2]) {
500  /* only instantiate the numeric features present in args[2]
501  then return true */
502  for (i=0;i<NSUBEXP;i++,sp++,ep++) {
503  if (*sp==NULL) break;
504  (void)snprintf(buffer_loc,5,"%d",i);
505  n3=find(FEATCMP,buffer_loc,args[2]->attr_list);
506  if (n3) {
507  ptr_psi_term psi = (ptr_psi_term) n3->data;
508  /* need to add 1 to these offsets because somehow life strings
509  are 1-based rather than 0-based. Who is the moron who made
510  that decision? This isn't Pascal! */
511  ptr_psi_term bounds = stack_pair(stack_int(*sp - (char *)args[1]->value_3 + 1),
512  stack_int(*ep - (char *)args[1]->value_3 + 1));
513  push_goal(unify,psi,bounds,NULL);
514  }
515  }
516  /* return true */
517  unify_bool_result(result,TRUE);
518  }
519  else {
520  /* create a term to represent all the groups and return it */
521  ptr_psi_term psi = stack_psi_term(4);
522  psi->type = top;
523  for (i=0;i<NSUBEXP;i++,sp++,ep++) {
524  if (*sp==NULL) break;
525  (void)snprintf(buffer_loc,5,"%d",i);
526  { ptr_psi_term bounds = stack_pair(stack_int(*sp - (char *)args[1]->value_3 + 1),
527  stack_int(*ep - (char *)args[1]->value_3 + 1));
528  stack_insert_copystr(buffer_loc,&(psi->attr_list),(GENERIC)bounds); }
529  }
530  /* return the new term */
531  push_goal(unify,psi,result,NULL);
532  }
533  return TRUE;
534  }
535 }
#define FEATCMP
Definition: def_const.h:257
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
void unify_bool_result(ptr_psi_term t, long v)
Definition: built_ins.c:329
long c_abort()
Definition: built_ins.c:2117
GENERIC data
Definition: def_struct.h:185
ptr_definition top
Definition: def_glob.h:106
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
void Errorline(char *format,...)
Definition: error.c:414
ptr_psi_term stack_pair(ptr_psi_term left, ptr_psi_term right)
Definition: built_ins.c:67
#define TRUE
Definition: def_const.h:127
ptr_psi_term stack_int(long n)
Definition: built_ins.c:87
#define FALSE
Definition: def_const.h:128
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
#define unify
Definition: def_const.h:274
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
void stack_insert_copystr(char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:260
static long socket_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1012 of file sys.c.

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

1014 {
1015  int addr_family=AF_INET,type=SOCK_STREAM,protocol=0;
1016  char *s;
1017  int fd;
1018 
1019  if (args[0]) {
1020  s=(char*)args[0]->value_3;
1021  if (!strcmp(s,"AF_UNIX")) addr_family=AF_UNIX;
1022  else if (!strcmp(s,"AF_INET")) addr_family=AF_INET;
1023  else {
1024  Errorline("Unknown address family in %P.\n",funct);
1025  return FALSE; }
1026  }
1027 
1028  if (args[1]) {
1029  s=(char*)args[1]->value_3;
1030  if (!strcmp(s,"SOCK_STREAM")) type=SOCK_STREAM;
1031  else if (!strcmp(s,"SOCK_DGRAM" )) type=SOCK_DGRAM;
1032  else if (!strcmp(s,"SOCK_RAW" )) {
1033  Errorline("SOCK_RAW not supported in %P.\n",funct);
1034  return FALSE; }
1035  else {
1036  Errorline("Unknown socket type in %P.\n",funct);
1037  return FALSE; }
1038  }
1039 
1040  if ((fd=socket(addr_family,type,protocol))<0)
1041  return FALSE;
1042 
1043  { FILE*fp = fdopen(fd,"r+");
1044  // ptr_psi_term t;
1045 
1046  if (fp==NULL) {
1047  Errorline("fdopen failed on socket in %P.\n",funct);
1048  return FALSE;
1049  }
1050 
1051 /* t = make_bytedata(sys_socket_stream,sizeof(fp));
1052  *(FILE**)BYTEDATA_DATA(t) = fp;*/
1053  push_goal(unify,fileptr2stream(fp,sys_socket_stream),result,NULL); // added & DJD
1054  }
1055  return TRUE;
1056 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
Definition: sys.c:571
#define NULL
Definition: def_const.h:203
void Errorline(char *format,...)
Definition: error.c:414
#define TRUE
Definition: def_const.h:127
#define FALSE
Definition: def_const.h:128
#define unify
Definition: def_const.h:274
ptr_definition sys_socket_stream
Definition: def_glob.h:134
static long stream2sys_stream_internal ( args  ,
  result,
  funct 
)
static

Definition at line 965 of file sys.c.

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

967 {
968  push_goal(unify,fileptr2stream((FILE*)args[0]->value_3,sys_stream),
969  result,NULL); // added & DJD
970  return TRUE;
971 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_psi_term fileptr2stream(FILE *fp, ptr_definition typ)
Definition: sys.c:571
ptr_definition sys_stream
Definition: def_glob.h:132
#define NULL
Definition: def_const.h:203
#define TRUE
Definition: def_const.h:127
#define unify
Definition: def_const.h:274
static long sys_stream2stream_internal ( args  ,
  result,
  funct 
)
static

Definition at line 982 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.

984 {
985  ptr_psi_term tmp;
986  tmp=stack_psi_term(4);
987  tmp->type=stream;
988  tmp->value_3=(GENERIC)((ptr_stream)BYTEDATA_DATA(args[0]))->fp;
989  push_goal(unify,tmp,result,NULL);
990  return TRUE;
991 }
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
ptr_definition stream
Definition: def_glob.h:103
#define NULL
Definition: def_const.h:203
#define BYTEDATA_DATA(X)
Definition: sys.c:128
#define TRUE
Definition: def_const.h:127
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
GENERIC value_3
Definition: def_struct.h:170
#define unify
Definition: def_const.h:274
Definition: sys.c:562
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
char* text_buffer_cmp ( struct text_buffer buf,
int  idx,
char *  str 
)

Definition at line 748 of file sys.c.

References text_buffer::next, and top.

752 {
753  while (buf) {
754  while (idx<buf->top)
755  if (!*str || buf->data[idx] != *str)
756  return 0;
757  else { idx++; str++; }
758  if (!*str && !buf->next) return str;
759  else {
760  buf=buf->next;
761  idx=0;
762  }
763  }
764  return 0;
765 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
Definition: def_glob.h:106
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_free ( struct text_buffer buf)

Definition at line 795 of file sys.c.

References text_buffer::next.

797 {
798  struct text_buffer *next;
799  while (buf) {
800  next = buf->next;
801  free(buf);
802  buf=next;
803  }
804 }
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 
)

Definition at line 724 of file sys.c.

References text_buffer::next, and top.

728 {
729  while (buf) {
730  while (idx<buf->top)
731  if (buf->data[idx] == c) {
732  *rbuf=buf;
733  *ridx=idx;
734  return 1;
735  }
736  else idx++;
737  buf=buf->next;
738  idx=0;
739  }
740  return 0;
741 }
char data[TEXTBUFSIZE]
Definition: def_struct.h:401
ptr_definition top
Definition: def_glob.h:106
struct text_buffer * next
Definition: def_struct.h:399
void text_buffer_push ( struct text_buffer **  buf,
char  c 
)

Definition at line 773 of file sys.c.

References text_buffer::data, and TEXTBUFSIZE.

776 {
777  if ((*buf)->top < TEXTBUFSIZE)
778  (*buf)->data[(*buf)->top++] = c;
779  else {
780  (*buf)->next = (struct text_buffer *)
781  malloc(sizeof(struct text_buffer));
782  if (!(*buf)->next) {
783  fprintf(stderr,"Fatal error: malloc failed in text_buffer_push\n");
784  exit(EXIT_FAILURE);
785  }
786  bzero((char*)(*buf)->next,sizeof(struct text_buffer));
787  *buf = (*buf)->next;
788  (*buf)->top = 1;
789  (*buf)->data[0]=c;
790  }
791 }
#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,
lst  ,
int  n 
)
static

Definition at line 1339 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.

1344 {
1345  ptr_psi_term u;
1346  int i;
1347  if (n<0) {
1348  fprintf(stderr,"unify_pterm_result called with n<0: n=%d\n",n);
1349  exit(EXIT_FAILURE);
1350  }
1351  u=stack_psi_term(4);
1352  u->type=sym;
1353  for(i=0;i<n;i++)
1354  (void)stack_insert(FEATCMP,lst[i].name_str,&(u->attr_list),(GENERIC)lst[i].value_str);
1355  push_goal(unify,t,u,NULL);
1356  return TRUE;
1357 }
#define FEATCMP
Definition: def_const.h:257
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define NULL
Definition: def_const.h:203
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
#define TRUE
Definition: def_const.h:127
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
#define unify
Definition: def_const.h:274
ptr_definition type
Definition: def_struct.h:165
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_node attr_list
Definition: def_struct.h:171
static long unify_wait_result ( ptr_psi_term  result,
pid_t  id,
int  status 
)
static

Definition at line 1384 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().

1388 {
1389  int n=2;
1390  long status2;
1391  ptr_definition sym;
1392  psi_feature lst[2];
1393  SETFEATURE(lst,0,one,stack_int(id));
1394  if (id == -1 || status == -1) {
1395  if (errno==ECHILD) {
1397  n=0;
1398  }
1399  else return FALSE;
1400  }
1401  else if (WIFEXITED(status)) {
1402  SETFEATURE(lst,1,two,stack_int(WEXITSTATUS(status)));
1403  sym = sys_process_exited;
1404  }
1405  else if (WIFSIGNALED(status)) {
1406  SETFEATURE(lst,1,two,stack_int(WTERMSIG(status)));
1407  sym = sys_process_signaled;
1408  }
1409  else if (WIFSTOPPED(status)) {
1410  SETFEATURE(lst,1,two,stack_int(WSTOPSIG(status)));
1411  sym = sys_process_stopped;
1412  }
1413 #ifdef WIFCONTINUED
1414  else if (WIFCONTINUED(status)) {
1415  sym = sys_process_continued;
1416  n=1;
1417  }
1418 #endif
1419  else {
1420  status2 = status;
1421  Errorline("Unexpected wait status: %d",status2);
1422  return FALSE;
1423  }
1424  return unify_pterm_result(result,sym,lst,n);
1425 }
static long unify_pterm_result(ptr_psi_term t, ptr_definition sym, lst, int n)
Definition: sys.c:1339
char * two
Definition: def_glob.h:251
void Errorline(char *format,...)
Definition: error.c:414
#define SETFEATURE(lst, n, nam, val)
Definition: sys.c:1336
ptr_definition sys_process_signaled
Definition: sys.c:1379
ptr_psi_term stack_int(long n)
Definition: built_ins.c:87
#define FALSE
Definition: def_const.h:128
ptr_definition sys_process_stopped
Definition: sys.c:1380
ptr_definition sys_process_continued
Definition: sys.c:1381
char * one
Definition: def_glob.h:250
ptr_definition sys_process_exited
Definition: sys.c:1378
ptr_definition sys_process_no_children
Definition: sys.c:1377
static long wait_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1428 of file sys.c.

References unify_wait_result().

1430 {
1431  int status;
1432  pid_t id = wait(&status);
1433  return unify_wait_result(result,id,status);
1434 }
static long unify_wait_result(ptr_psi_term result, pid_t id, int status)
Definition: sys.c:1384
static long wait_on_feature_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1564 of file sys.c.

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

1566 {
1567  char buffer_loc[100];
1568  if (args[1]->type == top) {
1569  residuate(args[0]);
1570  residuate(args[1]);
1571  return TRUE;
1572  }
1573  if (sub_type(args[1]->type,integer) && args[1]->value_3)
1574  snprintf(buffer_loc,100,"%ld",(long)*(REAL*)args[1]->value_3);
1575  else if (sub_type(args[1]->type,quoted_string) && args[1]->value_3)
1576  strcpy(buffer_loc,(char*)args[1]->value_3);
1577  else
1578  strcpy(buffer_loc,args[1]->type->keyword->symbol);
1579  if (find(FEATCMP,buffer_loc,args[0]->attr_list))
1581  /* this is all bullshit because projection should residuate
1582  on its 2nd arg until it becomes value. In particular, think
1583  of using `int' as a feature when it is clear that `int' may
1584  subsequently be refined to a particular integer. */
1585  else residuate(args[0]);
1586  return TRUE;
1587 }
#define prove
Definition: def_const.h:273
#define FEATCMP
Definition: def_const.h:257
void residuate(ptr_psi_term t)
Definition: lefun.c:113
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define DEFRULES
Definition: def_const.h:138
ptr_definition top
Definition: def_glob.h:106
#define NULL
Definition: def_const.h:203
#define REAL
Definition: def_const.h:72
long sub_type(ptr_definition t1, ptr_definition t2)
Definition: types.c:1544
#define TRUE
Definition: def_const.h:127
ptr_definition integer
Definition: def_glob.h:93
ptr_definition quoted_string
Definition: def_glob.h:101
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
static long waitpid_internal ( args  ,
  result,
  funct 
)
static

Definition at line 1443 of file sys.c.

References REAL, and unify_wait_result().

1445 {
1446  int status;
1447  pid_t id = waitpid((pid_t)(long)*(REAL*)args[0]->value_3,&status,
1448  args[1]?(int)(long)*(REAL*)args[1]->value_3:0);
1449  return unify_wait_result(result,id,status);
1450 }
#define REAL
Definition: def_const.h:72
static long unify_wait_result(ptr_psi_term result, pid_t id, int status)
Definition: sys.c:1384

Variable Documentation

ptr_definition sys_process_continued

Definition at line 1381 of file sys.c.

ptr_definition sys_process_exited

Definition at line 1378 of file sys.c.

ptr_definition sys_process_no_children

Definition at line 1377 of file sys.c.

ptr_definition sys_process_signaled

Definition at line 1379 of file sys.c.

ptr_definition sys_process_stopped

Definition at line 1380 of file sys.c.