PIPS
database.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "genC.h"
#include "database.h"
+ Include dependency graph for database.c:

Go to the source code of this file.

Functions

database copy_database (database p)
 DATABASE. More...
 
void free_database (database p)
 
database check_database (database p)
 
bool database_consistent_p (database p)
 
bool database_defined_p (database p)
 
list gen_database_cons (database p, list l)
 
void database_assign_contents (database r, database v)
 
void database_non_recursive_free (database p)
 
void write_database (FILE *f, database p)
 
database read_database (FILE *f)
 
database make_database (string a1, string a2, list a3)
 
resource copy_resource (resource p)
 RESOURCE. More...
 
void free_resource (resource p)
 
resource check_resource (resource p)
 
bool resource_consistent_p (resource p)
 
bool resource_defined_p (resource p)
 
list gen_resource_cons (resource p, list l)
 
void resource_assign_contents (resource r, resource v)
 
void resource_non_recursive_free (resource p)
 
void write_resource (FILE *f, resource p)
 
resource read_resource (FILE *f)
 
resource make_resource (string a1, string a2, status a3, intptr_t a4, intptr_t a5)
 
status copy_status (status p)
 STATUS. More...
 
void free_status (status p)
 
status check_status (status p)
 
bool status_consistent_p (status p)
 
bool status_defined_p (status p)
 
list gen_status_cons (status p, list l)
 
void status_assign_contents (status r, status v)
 
void status_non_recursive_free (status p)
 
void write_status (FILE *f, status p)
 
status read_status (FILE *f)
 
string status_tag_as_string (enum status_utype tag)
 
status make_status (enum status_utype tag, void *val)
 
status make_status_memory (string _field_)
 
status make_status_file (string _field_)
 

Function Documentation

◆ check_database()

database check_database ( database  p)

Definition at line 22 of file database.c.

22  {
24 }
#define database_domain
Definition: database.h:10
gen_chunk * gen_check(gen_chunk *obj, int t)
GEN_CHECK checks that the gen_chunk received OBJ is of the appropriate TYPE.
Definition: genClib.c:2356
A gen_chunk is used to store every object.
Definition: genC.h:58

References database_domain, and gen_check().

Referenced by database_assign_contents(), and database_consistent_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_resource()

resource check_resource ( resource  p)

Definition at line 64 of file database.c.

64  {
66 }
#define resource_domain
newgen_database_domain_defined
Definition: database.h:18

References gen_check(), and resource_domain.

Referenced by resource_assign_contents(), and resource_consistent_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check_status()

status check_status ( status  p)

Definition at line 106 of file database.c.

106  {
107  return (status) gen_check((gen_chunk*) p, status_domain);
108 }
#define status_domain
newgen_resource_domain_defined
Definition: database.h:26

References gen_check(), and status_domain.

Referenced by status_assign_contents(), and status_consistent_p().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ copy_database()

database copy_database ( database  p)

DATABASE.

Definition at line 16 of file database.c.

16  {
17  return (database) gen_copy_tree((gen_chunk*) p);
18 }
gen_chunk * gen_copy_tree(gen_chunk *obj)
Definition: genClib.c:1429

References gen_copy_tree().

+ Here is the call graph for this function:

◆ copy_resource()

resource copy_resource ( resource  p)

RESOURCE.

Definition at line 58 of file database.c.

58  {
59  return (resource) gen_copy_tree((gen_chunk*) p);
60 }

References gen_copy_tree().

+ Here is the call graph for this function:

◆ copy_status()

status copy_status ( status  p)

STATUS.

Definition at line 100 of file database.c.

100  {
101  return (status) gen_copy_tree((gen_chunk*) p);
102 }

References gen_copy_tree().

+ Here is the call graph for this function:

◆ database_assign_contents()

void database_assign_contents ( database  r,
database  v 
)

Definition at line 35 of file database.c.

35  {
36  check_database(r);
37  check_database(v);
38  message_assert("defined references to domain database",
40  memcpy(r, v, sizeof(struct _newgen_struct_database_));
41 }
bool database_defined_p(database p)
Definition: database.c:29
database check_database(database p)
Definition: database.c:22
#define message_assert(msg, ex)
Definition: newgen_assert.h:47

References check_database(), database_defined_p(), and message_assert.

+ Here is the call graph for this function:

◆ database_consistent_p()

bool database_consistent_p ( database  p)

Definition at line 25 of file database.c.

25  {
26  check_database(p);
27  return gen_consistent_p((gen_chunk*) p);
28 }
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
Definition: genClib.c:2398

References check_database(), and gen_consistent_p().

+ Here is the call graph for this function:

◆ database_defined_p()

bool database_defined_p ( database  p)

Definition at line 29 of file database.c.

29  {
30  return gen_defined_p((gen_chunk*) p);
31 }
int gen_defined_p(gen_chunk *obj)
Definition: genClib.c:2438

References gen_defined_p().

Referenced by database_assign_contents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ database_non_recursive_free()

void database_non_recursive_free ( database  p)

Definition at line 42 of file database.c.

42  {
43  // should clear up contents...
44  free(p);
45 }
void free(void *)

References free().

+ Here is the call graph for this function:

◆ free_database()

void free_database ( database  p)

Definition at line 19 of file database.c.

19  {
20  gen_free((gen_chunk*) p);
21 }
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992

References gen_free().

+ Here is the call graph for this function:

◆ free_resource()

void free_resource ( resource  p)

Definition at line 61 of file database.c.

61  {
62  gen_free((gen_chunk*) p);
63 }

References gen_free().

+ Here is the call graph for this function:

◆ free_status()

void free_status ( status  p)

Definition at line 103 of file database.c.

103  {
104  gen_free((gen_chunk*) p);
105 }

References gen_free().

+ Here is the call graph for this function:

◆ gen_database_cons()

list gen_database_cons ( database  p,
list  l 
)

Definition at line 32 of file database.c.

32  {
34 }
#define DATABASE_NEWGEN_DOMAIN
Definition: database.h:13
list gen_typed_cons(_int type, const void *item, const list next)
CONS a list with minimal type checking this cannot be done within the CONS macro because possible fun...
Definition: list.c:900

References DATABASE_NEWGEN_DOMAIN, and gen_typed_cons().

+ Here is the call graph for this function:

◆ gen_resource_cons()

list gen_resource_cons ( resource  p,
list  l 
)

Definition at line 74 of file database.c.

74  {
76 }
#define RESOURCE_NEWGEN_DOMAIN
Definition: database.h:21

References gen_typed_cons(), and RESOURCE_NEWGEN_DOMAIN.

+ Here is the call graph for this function:

◆ gen_status_cons()

list gen_status_cons ( status  p,
list  l 
)

Definition at line 116 of file database.c.

116  {
117  return gen_typed_cons(STATUS_NEWGEN_DOMAIN, p, l);
118 }
#define STATUS_NEWGEN_DOMAIN
Definition: database.h:29

References gen_typed_cons(), and STATUS_NEWGEN_DOMAIN.

+ Here is the call graph for this function:

◆ make_database()

database make_database ( string  a1,
string  a2,
list  a3 
)

Definition at line 52 of file database.c.

52  {
53  return (database) gen_alloc(4*sizeof(gen_chunk), GEN_CHECK_ALLOC, database_domain, a1, a2, a3);
54 }
#define GEN_CHECK_ALLOC
Definition: genC.h:307
gen_chunk * gen_alloc(int size, int gen_check_p, int dom,...)
allocates something in newgen.
Definition: genClib.c:298

References database_domain, gen_alloc(), and GEN_CHECK_ALLOC.

+ Here is the call graph for this function:

◆ make_resource()

resource make_resource ( string  a1,
string  a2,
status  a3,
intptr_t  a4,
intptr_t  a5 
)

Definition at line 94 of file database.c.

94  {
95  return (resource) gen_alloc(6*sizeof(gen_chunk), GEN_CHECK_ALLOC, resource_domain, a1, a2, a3, a4, a5);
96 }

References gen_alloc(), GEN_CHECK_ALLOC, and resource_domain.

+ Here is the call graph for this function:

◆ make_status()

status make_status ( enum status_utype  tag,
void *  val 
)

Definition at line 143 of file database.c.

143  {
144  return (status) gen_alloc(3*sizeof(gen_chunk), GEN_CHECK_ALLOC, status_domain, tag, val);
145 }
int tag
TAG.
Definition: newgen_types.h:92

References gen_alloc(), GEN_CHECK_ALLOC, and status_domain.

Referenced by make_status_file(), and make_status_memory().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_status_file()

status make_status_file ( string  _field_)

Definition at line 149 of file database.c.

149  {
150  return make_status(is_status_file, (void*)(intptr_t) _field_);
151 }
status make_status(enum status_utype tag, void *val)
Definition: database.c:143
@ is_status_file
Definition: database.h:142
#define intptr_t
Definition: stdint.in.h:294

References intptr_t, is_status_file, and make_status().

+ Here is the call graph for this function:

◆ make_status_memory()

status make_status_memory ( string  _field_)

Definition at line 146 of file database.c.

146  {
147  return make_status(is_status_memory, (void*)(intptr_t) _field_);
148 }
@ is_status_memory
Definition: database.h:141

References intptr_t, is_status_memory, and make_status().

+ Here is the call graph for this function:

◆ read_database()

database read_database ( FILE *  f)

Definition at line 49 of file database.c.

49  {
50  return (database) gen_read(f);
51 }
gen_chunk * gen_read(FILE *file)
GEN_READ reads any object from the FILE stream.
Definition: genClib.c:2323
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15

References f(), and gen_read().

+ Here is the call graph for this function:

◆ read_resource()

resource read_resource ( FILE *  f)

Definition at line 91 of file database.c.

91  {
92  return (resource) gen_read(f);
93 }

References f(), and gen_read().

+ Here is the call graph for this function:

◆ read_status()

status read_status ( FILE *  f)

Definition at line 133 of file database.c.

133  {
134  return (status) gen_read(f);
135 }

References f(), and gen_read().

+ Here is the call graph for this function:

◆ resource_assign_contents()

void resource_assign_contents ( resource  r,
resource  v 
)

Definition at line 77 of file database.c.

77  {
78  check_resource(r);
79  check_resource(v);
80  message_assert("defined references to domain resource",
82  memcpy(r, v, sizeof(struct _newgen_struct_resource_));
83 }
bool resource_defined_p(resource p)
Definition: database.c:71
resource check_resource(resource p)
Definition: database.c:64

References check_resource(), message_assert, and resource_defined_p().

+ Here is the call graph for this function:

◆ resource_consistent_p()

bool resource_consistent_p ( resource  p)

Definition at line 67 of file database.c.

67  {
68  check_resource(p);
69  return gen_consistent_p((gen_chunk*) p);
70 }

References check_resource(), and gen_consistent_p().

+ Here is the call graph for this function:

◆ resource_defined_p()

bool resource_defined_p ( resource  p)

Definition at line 71 of file database.c.

71  {
72  return gen_defined_p((gen_chunk*) p);
73 }

References gen_defined_p().

Referenced by resource_assign_contents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resource_non_recursive_free()

void resource_non_recursive_free ( resource  p)

Definition at line 84 of file database.c.

84  {
85  // should clear up contents...
86  free(p);
87 }

References free().

+ Here is the call graph for this function:

◆ status_assign_contents()

void status_assign_contents ( status  r,
status  v 
)

Definition at line 119 of file database.c.

119  {
120  check_status(r);
121  check_status(v);
122  message_assert("defined references to domain status",
124  memcpy(r, v, sizeof(struct _newgen_struct_status_));
125 }
bool status_defined_p(status p)
Definition: database.c:113
status check_status(status p)
Definition: database.c:106

References check_status(), message_assert, and status_defined_p().

+ Here is the call graph for this function:

◆ status_consistent_p()

bool status_consistent_p ( status  p)

Definition at line 109 of file database.c.

109  {
110  check_status(p);
111  return gen_consistent_p((gen_chunk*) p);
112 }

References check_status(), and gen_consistent_p().

+ Here is the call graph for this function:

◆ status_defined_p()

bool status_defined_p ( status  p)

Definition at line 113 of file database.c.

113  {
114  return gen_defined_p((gen_chunk*) p);
115 }

References gen_defined_p().

Referenced by status_assign_contents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ status_non_recursive_free()

void status_non_recursive_free ( status  p)

Definition at line 126 of file database.c.

126  {
127  // should clear up contents...
128  free(p);
129 }

References free().

+ Here is the call graph for this function:

◆ status_tag_as_string()

string status_tag_as_string ( enum status_utype  tag)

Definition at line 136 of file database.c.

136  {
137  switch (tag) {
138  case is_status_memory: return "memory";
139  case is_status_file: return "file";
140  default: return string_undefined;
141  }
142 }
#define string_undefined
Definition: newgen_types.h:40

References is_status_file, is_status_memory, and string_undefined.

◆ write_database()

void write_database ( FILE *  f,
database  p 
)

Definition at line 46 of file database.c.

46  {
47  gen_write(f, (gen_chunk*) p);
48 }
void gen_write(FILE *fd, gen_chunk *obj)
GEN_WRITE writes the OBJect on the stream FD.
Definition: genClib.c:1745

References f(), and gen_write().

+ Here is the call graph for this function:

◆ write_resource()

void write_resource ( FILE *  f,
resource  p 
)

Definition at line 88 of file database.c.

88  {
89  gen_write(f, (gen_chunk*) p);
90 }

References f(), and gen_write().

+ Here is the call graph for this function:

◆ write_status()

void write_status ( FILE *  f,
status  p 
)

Definition at line 130 of file database.c.

130  {
131  gen_write(f, (gen_chunk*) p);
132 }

References f(), and gen_write().

+ Here is the call graph for this function: