fixes
[henge/apc.git] / src / ir.c
index ac47a85..c59441a 100644 (file)
--- a/src/ir.c
+++ b/src/ir.c
@@ -44,13 +44,14 @@ struct ir_classld_t
 };\r
 struct ir_setld_t\r
 { struct ir_classld_t*  classld;\r
-  long long             ref;\r
+  uint32_t              ref;\r
   struct ir_namelist_t* namelist, * namelist_head;\r
 };\r
 struct ir_setdata_header_t\r
 { enum dtype          type;\r
   uint8_t*            src_filename, * data_name;\r
   union ir_setdata_t* nextsib;\r
+  long                filepos;\r
 };\r
 struct ir_framedata_t\r
 { struct ir_setdata_header_t header;\r
@@ -80,6 +81,7 @@ struct ir_class_t
 { struct ir_class_t* nextchild, * nextsib;\r
   struct ir_set_t*   root_set;\r
   uint8_t*           name;\r
+  long               filepos;\r
 };\r
 struct ir_set_t\r
 { struct ir_set_t*      nextchild, * nextsib;\r
@@ -88,7 +90,7 @@ struct ir_set_t
   struct ir_framebox_t* frameboxes;\r
   struct ir_simplex_t*  audio;\r
   struct ir_link_t*     links;\r
-  long filepos;\r
+  long                  filepos;\r
 };\r
 /* Functions */\r
 static inline\r
@@ -220,6 +222,11 @@ struct ir_set_t* ir_class_addset
   return iter->nextsib;\r
 }\r
 \r
+/* Get the root set of the class */\r
+struct ir_set_t* ir_class_rootset\r
+( struct ir_class_t* class )\r
+{ return class->root_set; }\r
+\r
 struct ir_set_t* ir_set_from_ref\r
 ( uint32_t ref )\r
 { uint16_t hash;\r
@@ -328,6 +335,55 @@ int classnames_identical
   return (ca == cb);\r
 }\r
 \r
+/* Return the name of the set */\r
+uint8_t* ir_set_name\r
+( struct ir_set_t* set)\r
+{ return set->name; }\r
+\r
+/* Return the next sib of the class */\r
+struct ir_class_t* ir_class_nextsib\r
+( struct ir_class_t* class )\r
+{ return class->nextsib; }\r
+\r
+/* Return the next sib of the class */\r
+struct ir_class_t* ir_class_nextchild\r
+( struct ir_class_t* class )\r
+{ return class->nextchild; }\r
+\r
+/* Get the file position of the class */\r
+long ir_class_fpos\r
+( struct ir_class_t* class )\r
+{ return class->filepos; }\r
+\r
+/* Set the file position of the class */\r
+void ir_class_assign_fpos\r
+( struct ir_class_t* class,\r
+  long               newpos\r
+)\r
+{ class->filepos = newpos; }\r
+\r
+/* Get the next sibling of the provided set */\r
+struct ir_set_t* ir_set_nextsib\r
+( struct ir_set_t* set )\r
+{ return set->nextsib; }\r
+\r
+/* Get the next child of the provided set */\r
+struct ir_set_t* ir_set_nextchild\r
+( struct ir_set_t* set )\r
+{ return set->nextchild; }\r
+\r
+/* Get the file position of the class */\r
+long ir_set_fpos\r
+( struct ir_set_t* set )\r
+{ return set->filepos; }\r
+\r
+/* Set the file position of the class */\r
+void ir_set_assign_fpos\r
+( struct ir_set_t* set,\r
+  long             newpos\r
+)\r
+{ set->filepos = newpos; }\r
+\r
 /* Assign Setdata to Set  */\r
 void ir_set_assign_data\r
 ( struct ir_set_t*      set,\r
@@ -544,7 +600,93 @@ union ir_setdata_t* ir_link
   return (union ir_setdata_t*) link;\r
 }\r
 \r
+/* Return a set's root framebox */\r
+union ir_setdata_t* ir_set_framebox\r
+( struct ir_set_t* set )\r
+{ return (union ir_setdata_t*) set->frameboxes; }\r
+\r
+/* Return a set's root audio data */\r
+union ir_setdata_t* ir_set_audio\r
+( struct ir_set_t* set )\r
+{ return (union ir_setdata_t*) set->audio; }\r
+\r
+/* Return a set's root link data */\r
+union ir_setdata_t* ir_set_link\r
+( struct ir_set_t* set )\r
+{ return (union ir_setdata_t*) set->links; }\r
+\r
+/* Return the link type */\r
+enum ltype ir_linkdata_type\r
+( union ir_setdata_t* linkdata )\r
+{ if (linkdata->header.type != LDAT)\r
+    eprintf("Data %s is not a link\n", linkdata->header.data_name);\r
+  return linkdata->link.type;\r
+}\r
+\r
+/* Return the link type */\r
+uint32_t ir_linkdata_ref\r
+( union ir_setdata_t* linkdata )\r
+{ if (linkdata->header.type != LDAT)\r
+    eprintf("Data %s is not a link\n", linkdata->header.data_name);\r
+  return linkdata->link.setld->ref;\r
+}\r
+\r
+/* Get a setdata's next sibling */\r
+union ir_setdata_t* ir_setdata_nextsib\r
+( union ir_setdata_t* setdata )\r
+{ return setdata->header.nextsib; }\r
+\r
+/* Get a setdata's name */\r
+uint8_t* ir_setdata_name\r
+( union ir_setdata_t* setdata )\r
+{ return setdata->header.data_name; }\r
+\r
+/* Get a setdata's filename */\r
+uint8_t* ir_setdata_filename\r
+( union ir_setdata_t* setdata )\r
+{ return setdata->header.src_filename; }\r
+\r
+/* Get a setdata's file position */\r
+long ir_setdata_fpos\r
+( union ir_setdata_t* setdata )\r
+{ return setdata->header.filepos; }\r
+\r
+/* Set a setdata's file position */\r
+void ir_setdata_assign_fpos\r
+( union ir_setdata_t* setdata,\r
+  long                newpos\r
+)\r
+{ setdata->header.filepos = newpos; }\r
+\r
+/* Return a framebox's specified framesheet */\r
+union ir_setdata_t* ir_framebox_framesheet\r
+( union ir_setdata_t* fbox,\r
+  apc_facing          facing\r
+)\r
+{ if (fbox->header.type != FBDAT)\r
+    eprintf("Data %s is not a framebox\n", fbox->header.data_name);\r
+  return (union ir_setdata_t*) &fbox->framebox.framesheets[facing];\r
+}\r
+\r
+/* Return a framebox's specified mapsheet */\r
+union ir_setdata_t* ir_framebox_mapsheet\r
+( union ir_setdata_t* fbox,\r
+  apc_facing          facing\r
+)\r
+{ if (fbox->header.type != FBDAT)\r
+    eprintf("Data %s is not a framebox\n", fbox->header.data_name);\r
+  return (union ir_setdata_t*) &fbox->framebox.mapsheets[facing];\r
+}\r
+\r
+/* Return a framedata's frame info */\r
+struct ir_frameinfo_t* ir_framedata_mapsheet\r
+( union ir_setdata_t* framedata )\r
+{ if (framedata->header.type != MSDAT && framedata->header.type != FSDAT)\r
+    eprintf("Data %s is not a framedata\n", framedata->header.data_name);\r
+  return &framedata->mapsheet.frameinfo;\r
+}\r
 \r
+/** Allocators **/\r
 static\r
 uint8_t* name_alloc\r
 ( const uint8_t* name_src )\r
@@ -586,13 +728,15 @@ uint8_t* classname_alloc
 static void crawl_class(struct ir_class_t*);\r
 static void crawl_set(struct ir_set_t*,int);\r
 \r
+extern\r
+int binout_init(ir_class);\r
 void     ir_test(void)\r
 { uprintf("IR From Directory: %s\n",getcwd(NULL,255));\r
   crawl_class(&root_class);\r
   if (root_class.root_set != NULL)\r
     crawl_set(root_class.root_set, 0);\r
   uprintf("starting binaryout \n");\r
-  ir_binout_init(&root_class);\r
+  binout_init(&root_class);\r
 }\r
 \r
 \r