Ejemplo n.º 1
0
dmz::Boolean
dmz::NetModulePacketCodecBasic::encode_object (
      const Handle ObjectHandle,
      Marshal &outData) {

   return _write_object (ObjectHandle, NetObjectUpdate, outData);
}
Ejemplo n.º 2
0
dmz::Boolean
dmz::NetModulePacketCodecBasic::register_object (
      const Handle ObjectHandle,
      const ObjectType &Type,
      Marshal &outData) {

   Boolean result (False);

   _objTable.remove (ObjectHandle);

   ObjectType current (Type);

   EncodeObjectStruct *eos (0);

   do {

      eos = _objTypeTable.lookup (current.get_handle ());
      current.become_parent ();

   } while (current && !eos);

   if (ObjectHandle && eos && _objTable.store (ObjectHandle, eos)) {

      result = _write_object (ObjectHandle, NetObjectActivate, outData);
   }

   return result;
}
Ejemplo n.º 3
0
dmz::Boolean
dmz::NetModulePacketCodecBasic::release_object (
      const Handle ObjectHandle,
      Marshal &outData) {

   _write_object (ObjectHandle, NetObjectDeactivate, outData);

   return _objTable.remove (ObjectHandle) != 0;
}
Ejemplo n.º 4
0
/* _output_btoc:
 * Sorts all the buffered tocs read so far and frees their memory after
 * writting them to the file. Can be safely called at any moment, as long
 * as the pointer to num_btoc is meaningfull and contains the number of
 * buffered tocs in the btoc table. Note that btoc_prev is NOT sorted.
 */
static void _output_btoc(FILE *file, BTOC *btoc, int *btoc_prev, int *num_btoc)
{
   int num;

   assert(btoc);
   assert(num_btoc);
   assert(btoc_prev);

   qsort(btoc, *num_btoc, sizeof(BTOC), _qsort_btoc_helper);

   for(num = 0; num < *num_btoc; num++) {
      if (btoc_prev[num] == PREV_SUB)
	 fprintf(file, "</li>\n");
      if (btoc_prev[num] == PREV_ROOT)
	 fprintf(file, "<ul>\n");

      _write_object(file, btoc[num].name, btoc[num].local);
      free(btoc[num].local);
   }
   *num_btoc = 0;
}
Ejemplo n.º 5
0
/* _write_toc:
 * Outputs a .hhc or .hhk file which are needed by the HTML Help compiler
 * (along with a .hhp and the standard HTML docs) to generate the CHM docs.
 * is_index is a boolean, and tells if the output file should be a chm
 * index file. The main difference is that the internal structure is
 * slightly different, and it doesn't need toc sorting.
 */
static int _write_toc(const char *filename, int is_index)
{
   BTOC btoc[TOC_SIZE];
   FILE *file = fopen(filename, "wt");
   TOC *toc;
   int btoc_prev[TOC_SIZE];
   int section_number = -1, prev = 0, num_btoc = 0;
   int in_chapter = 0;
   
   if (!file)
      return 1;

   fprintf(file, "<html>\n");
   fprintf(file, "<head>\n");
   fprintf(file, "<title>\n");
   if (is_index)
      fprintf(file, "Index\n");
   else
      fprintf(file, "Contents\n");
   fprintf(file, "</title>\n");
   fprintf(file, "</head>\n");

   fprintf(file, "<body>\n");
   fprintf(file, "<ul>\n");

   toc = tochead;
   if (toc)
      toc = toc->next;

   for (; toc; toc = toc->next) {
      char name[256];

      if (toc->htmlable) {
	 if (toc->root) {

	    if (is_index) {
	       fprintf(file, "</li>\n");
	    }
	    else {
	       _output_btoc(file, btoc, btoc_prev, &num_btoc);
	       if (prev == PREV_SUB)
		  fprintf(file, "</li></ul></li>\n");
	       if (prev == PREV_ROOT)
		  fprintf(file, "</li>\n");
	    }

	    if (toc->otherfile) {
	       sprintf(name, "%s.%s", toc->text, html_extension);
	    }
	    else {
	       section_number++;
	       get_section_filename(name, filename, section_number);
	    }

	    prev = PREV_ROOT;

	    _write_object(file, ALT_TEXT(toc), mystrlwr(name));
	 }
	 else {

	    if (is_index) {
	       fprintf(file, "</li>\n");
	    }
	    else {
	       btoc_prev[num_btoc] = prev;
	    }

	    get_section_filename(name, filename, section_number);
	    strcat(name, "#");
	    strcat(name, toc->text);

	    prev = PREV_SUB;
	    if(!is_index) {
	       /* Buffer toc for posterior output */
	       btoc[num_btoc].local = m_strdup(mystrlwr(name));
	       btoc[num_btoc++].name = ALT_TEXT(toc);
	    }
	    else
	       _write_object(file, ALT_TEXT(toc), name);
	 }
      }
      else if ((toc->root == 2 || toc->root == 3) && !is_index) {
         _output_btoc(file, btoc, btoc_prev, &num_btoc);
	 if (prev == PREV_SUB)
	    fprintf(file, "</li></ul></li>\n");
         if (prev == PREV_ROOT)
	    fprintf(file, "</li>\n");
         if (in_chapter) {
            fprintf(file, "</ul>\n");
            in_chapter = 0;
         }
         if (toc->root == 2) {
            fprintf(file, "<li><object type=\"text/sitemap\">\n");
            fprintf(file, "<param name=\"Name\" value=\"%s\">\n", ALT_TEXT(toc));
            fprintf(file, "</object>\n</li>\n");
            fprintf(file, "<ul>\n");
            in_chapter = 1;
         }
         prev = 0;
      }
   }

   if (in_chapter) {
      fprintf(file, "</ul>\n");
   }

   _output_btoc(file, btoc, btoc_prev, &num_btoc);
   if (prev == PREV_SUB)
      fprintf(file, "</li></ul></li>\n");
   if (prev == PREV_ROOT)
      fprintf(file, "</li>\n");

   fprintf(file, "</ul>\n");

   fprintf(file, "</body>\n");
   fprintf(file, "</html>\n");

   fclose(file);

   return 0;
}