⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 olecod.c

📁 excel to html
💻 C
📖 第 1 页 / 共 3 页
字号:
  /* 3. update Input entry of Root */  /*            update blocks size of Root (need Root->size updated) */  *(Root->blocks) = size2blocks (Root->size, 0x0200);   /* 4. update Input entry of BDepot */  /*            update blocks size of BDepot (need blocks size of Root updated */  *(BDepot->blocks) = size2blocks (sum_block_list (BDepot) * sizeof (U32), 0x0200);  return 0;}/* reviewed when processing streams */static intadd_stream_to_sbfile_and_SDepot (U32 size, char *name, U32 ppsnumber){  U32 entry_number;  U32 * new_entry_SDepot;  MY_FILE * new_entry_sbfile;  verbose ("calling: add_stream_to_sbfile_and_SDepot ()");  /* must be called only by process streams */  /* 1. add entries in SDepot and sbfile */  /*    add in SDepot */  entry_number = add_MY_FILE_entry (SDepot, size);  test_exitf (entry_number != 0xffffffffUL, 10, dummy ());  new_entry_SDepot = SDepot->file.block_list + entry_number;  /*    add in sbfile */  entry_number = add_MY_FILE_entry (sbfile, size);  test_exitf (entry_number != 0xffffffffUL, 10, dummy ());  new_entry_sbfile = sbfile->file.MY_FILE_list + entry_number;  /* 2. write info about the new stream in the new entry in SDepot */  /*    write info in new entry (info related with parameter size) */  /*          write blocks size of stream added */  *new_entry_SDepot = size2blocks (size, 0x40); /* 0x40 because is small stream */  /* 3. update Input entry of SDepot */  /*            update blocks size of SDepot (need info in new_entry_SDepot written) */  *(SDepot->blocks) = size2blocks (sum_block_list (SDepot) * sizeof (U32), 0x0200);  /* 4. write info about the new stream in the new entry in sbfile */  /*    write info in new entry (info related with parameter size */  /*                             and block size depot) */  /*           write size of stream added */  /*                 and write blocks size link of stream added */  init_MY_FILE_real (new_entry_sbfile, real, size, new_entry_SDepot, name, ppsnumber);  /* 5. update Input entry of sbfile */  /*            update blocks size of sbfile (need info in new_entry_sbfile->size */  /*                   and new_entry_sbfile->blocks written) */  *(sbfile->blocks) = size2blocks (sum_blocks_MY_FILE_list (sbfile) * 0x40, 0x0200);  /* 6. update Input entry of BDepot */  /*            update blocks size of BDepot (need blocks size of */  /*                   SDepot and sbfile updated */  *(BDepot->blocks) = size2blocks (sum_block_list (BDepot) * sizeof (U32), 0x0200);  return 0;}/* reviewed when processing streams */static intadd_stream_to_Input_and_BDepot (U32 size, char *name, U32 ppsnumber){  U32 entry_number;  MY_FILE * new_entry_Input;  U32 * new_entry_BDepot;  verbose ("calling: add_stream_to_Input_and_BDepot ()");  /* must be called only by process streams */  /* 1. add entries in BDepot and Input */  /*    add in BDepot */  entry_number = add_MY_FILE_entry (BDepot, size);  test_exitf (entry_number != 0xffffffffUL, 10, dummy ());  new_entry_BDepot = BDepot->file.block_list + entry_number;  /*    add in Input */  entry_number = add_MY_FILE_entry (&Input, size);  test_exitf (entry_number != 0xffffffffUL, 10, dummy ());  new_entry_Input = Input.file.MY_FILE_list + entry_number;  /* 2. write info about the new stream in the new entry in BDepot */  /*    write info in new entry (info related with parameter size) */  /*          write blocks size of stream added */  *new_entry_BDepot = size2blocks (size, 0x0200); /* 0x0200 because is big stream */  /* 3. update Input entry of BDepot */  /*            update blocks size of BDepot (need info in new_entry_BDepot written) */  *(BDepot->blocks) = size2blocks (sum_block_list (BDepot) * sizeof (U32), 0x0200);  /* 4. write info about the new stream in the new entry in Input */  /*    write info in new entry (info related with parameter size */  /*                             and block size depot) */  /*           write size of stream added */  /*                 and write blocks size link of stream added */  init_MY_FILE_real (new_entry_Input, real, size, new_entry_BDepot, name, ppsnumber);  /* 5. ?? update Input entry of Input ?? */  /*    this seems to be not aplicable here, not needed */  /* 6. update Input entry of BDepot */  /*            update blocks size of BDepot (need blocks size of */  /*                   BbDepot and ?? Input ?? updated */  *(BDepot->blocks) = size2blocks (sum_block_list (BDepot) * sizeof (U32), 0x0200);  return 0;}/* reviewed all conditions */static U32 add_MY_FILE_entry (MY_FILE * list, U32 size){#if __GNUC__ == 2  static char cff[] = "cole2357";#define nextff(var) static void * nextff_##var = (&nextff_##var); \nextff_##var=&##var;nextff (cff);#endif  verbose ("calling: add_MY_FILE_entry ()");#ifdef VERBOSE  if (list == &Input)    {      verbose_wonl ("add_MY_FILE_entry: list = &Input, ");    }  else if (list == sbfile)    {      verbose_wonl ("add_MY_FILE_entry: list = sbfile, ");    }  else if (list == SDepot)    {      verbose_wonl ("add_MY_FILE_entry: list = SDepot, ");    }  else if (list == BDepot)    {      verbose_wonl ("add_MY_FILE_entry: list = BDepot, ");    }  else if (list == bbd_list)    {      verbose_wonl ("add_MY_FILE_entry: list = bbd_list, ");    }  else if (list == Root)    {      verbose_wonl ("add_MY_FILE_entry: list = Root, ");    }  else    {      verbose_wonl ("add_MY_FILE_entry: list = UNKNOWN (ERROR!), ");    }  verboseU32 (size);#endif  assert (list != NULL);  switch (list->type)    {/* reviewed when adding to sbfile *//* reviewed when adding to Input */    case MY_FILE_list: {      MY_FILE *new_MY_FILE_list;      U32 new_entry;      assert (list == sbfile || list == &Input);      /* actually add */      list->size = list->size + sizeof (MY_FILE);      new_MY_FILE_list = realloc (list->file.MY_FILE_list, list->size);      list->file.MY_FILE_list = new_MY_FILE_list;      test_exitf (new_MY_FILE_list != NULL, 0xffffffffUL, dummy ());      new_entry = list->size / sizeof (MY_FILE) - 1;      reset_links ();      return new_entry;    }/* reviewed when adding to SDepot *//* reviewed when adding to BDepot */    case block_list: {      U32 *new_block_list;      U32 new_entry;      assert (list == SDepot || list == BDepot);      /* actually add */      list->size = list->size + sizeof (U32);      new_block_list = realloc (list->file.block_list, list->size);      list->file.block_list = new_block_list;      test_exitf (new_block_list != NULL, 0xffffffffUL, dummy ());      new_entry = list->size / sizeof (U32) - 1;      reset_links ();      return new_entry;    }/* reviewed when adding to Root */    case root_list: {	 U32 new_entry;      U8 *new_root_list;      assert (list == Root);      /* actually add */      list->size = list->size + 0x80;      new_root_list = realloc (list->file.root_list, list->size);      list->file.root_list = new_root_list;      test_exitf (new_root_list != NULL, 0xffffffffUL, dummy ());      new_entry = list->size / 0x80 - 1;      reset_links ();      return new_entry;    }    default:	if (SDepot->file.block_list!=NULL)      {		verboseU32Array (SDepot->file.block_list, SDepot->size / sizeof(U32));		verboseU32 (Root->size);		verboseU32Array (BDepot->file.block_list, BDepot->size / sizeof(U32));		verboseU32 (*(bbd_list->file.block_list));      }      assert ("list->type UNKNOWN in add_MY_FILE_entry" == NULL);      return 0;    }}/* reviewed when adding to Root */static intpps2root (U8 pps[0x80], pps_entry * node, U32 start_block){  U16 i;  U16 size_of_name;  /* next vars are constant, should it be static for performance? */  U8 U8magiczero = 0x00;  U32 U32magiczero = 0x00000000UL;  U32 U32magic1 = 0x00020900UL;  U32 U32magic2 = 0x46000000UL;  verbose ("calling: pps2root ()");  verboseU32 (node->ppsnumber);  verboseU32 ((U32) (pps - Root->file.root_list));  assert (node->ppsnumber == (U32)(pps - Root->file.root_list)/0x80);  clean_block (pps, 0x80);  /* name and its size */  size_of_name = (U16)(2 * (strlen (node->name) + 1));  /* 2 * because zero follow each char */  for (i = 0; i < size_of_name; i++)    *(pps + i) = (U8)(i % 2 ? 0x00 : *(node->name + (i / 2)));  fil_swriteU16 (pps + 0x40, &size_of_name);  /* other variables */  *(pps + 0x42) = node->type;  fil_swriteU32 (pps + 0x44, &node->previous);  fil_swriteU32 (pps + 0x48, &node->next);  fil_swriteU32 (pps + 0x4c, &node->dir);  fil_swriteU32 (pps + 0x64, &node->seconds1);  fil_swriteU32 (pps + 0x68, &node->days1);  fil_swriteU32 (pps + 0x6c, &node->seconds2);  fil_swriteU32 (pps + 0x70, &node->days1);  fil_swriteU32 (pps + 0x74, &start_block);  fil_swriteU32 (pps + 0x78, &node->size);  /* constant magic numbers */  *(pps + 0x43) = U8magiczero;  fil_swriteU32 (pps + 0x50, &U32magic1);  fil_swriteU32 (pps + 0x54, &U32magiczero);  fil_swriteU32 (pps + 0x58, &U32magiczero);  fil_swriteU32 (pps + 0x5c, &U32magic2);  fil_swriteU32 (pps + 0x60, &U32magiczero);  fil_swriteU32 (pps + 0x7c, &U32magiczero);  verboseU8Array (pps, 1, 0x80);  return 0;}static U32 sum_block_list (MY_FILE * list){  U32 sum = 0;  U32 *block;  /*verbose ("calling: sum_block_list ()");*/  assert (list != NULL);  assert (list->type == block_list);  for (block = list->file.block_list;       (U32)(((U8 *) block - (U8 *) list->file.block_list)) < list->size;       block++)    sum += *block;  return sum;}/*static U32 sum_MY_FILE_list (MY_FILE * list){  U32 sum = 0;  MY_FILE *file;  verbose ("calling: sum_MY_FILE_list ()");  assert (list != NULL);  assert (list->type == MY_FILE_list);  for (file = list->file.MY_FILE_list;       ((U8 *) file - (U8 *) list->file.MY_FILE_list) < list->size;       file++)    sum += file->size;  return sum;}*/static U32 sum_blocks_MY_FILE_list (MY_FILE * list){  U32 sum = 0;  MY_FILE *file;  /*verbose ("calling: sum_blocks_MY_FILE_list ()");*/  assert (list != NULL);  assert (list->type == MY_FILE_list);  for (file = list->file.MY_FILE_list;       (U32)((U8 *) file - (U8 *) list->file.MY_FILE_list) < list->size;       file++)    if (file->blocks != NULL)      sum += *(file->blocks);  return sum;}static void reset_links_in_Input (void){  verbose ("calling: reset_links_in_Input ()");  sbfile = Input.file.MY_FILE_list + 4;  SDepot = Input.file.MY_FILE_list + 3;  BDepot = Input.file.MY_FILE_list + 1;  bbd_list = Input.file.MY_FILE_list;  Root = Input.file.MY_FILE_list + 2;}static void reset_links_in_BDepot (void){  U32 i;  verbose ("calling: reset_links_in_BDepot ()");  sbfile->blocks = BDepot->file.block_list;  SDepot->blocks = BDepot->file.block_list + 1;  Root->blocks = BDepot->file.block_list + 2;  /* relink big streams block sizes in Input with BDepot entries */  for (i = 0; i < (Input.size / sizeof (MY_FILE)) - 5; i++)    Input.file.MY_FILE_list[i + 5].blocks = BDepot->file.block_list + i + 3;}static void reset_links_in_SDepot (void){  U32 i;  verbose ("calling: reset_links_in_SDepot ()");  /* relink small streams block sizes in sbfile with SDepot entries */  for (i = 0; i < sbfile->size / sizeof (MY_FILE); i++)    sbfile->file.MY_FILE_list[i].blocks = SDepot->file.block_list + i;}static int generate_ole2_file (const char *filename, int trunc){  verbose ("calling: generate_ole2_file ()");  if (!trunc)    {      output_file = fopen (filename, "r");      test_exitf (output_file == NULL, 2, ends ());    }  output_file = fopen (filename, "wb");  test_exitf (output_file != NULL, 3, ends ());  test_call (generate_header (), int);  test_call (generate_recursive (&Input), int);  /* some tricky here: if there are only small streams, no big streams,     next line wich is in generate_real_file will never be executed.     so we do it here, if only is correct is harmless calling it here */  write_until_output_block_boundary (1);  test_call (generate_SDepot (), int);  test_call (generate_Root (), int);  test_call (generate_BDepot (), int);  fclose (output_file);  return 0;}static int generate_header (void){  U32 identifier1 = 0xe011cfd0UL;  U32 identifier2 = 0xe11ab1a1UL;  U32 U32magiczero = 0x00000000UL;  U32 U32magic1 = 0x0003003bUL;  U32 U32magic2 = 0x0009fffeUL;  U32 U32magic3 = 0x00000006UL;  U32 U32magic4 = 0x00001000UL;  U32 U32magic5 = 0x00000001UL;  U32 U32magic6 = 0xfffffffeUL;  verbose ("calling: generate_header ()");  calculate_blocks ();  fil_swriteU32 (output_block + 0x30, &Root_start_block);  fil_swriteU32 (output_block + 0x3c, &SDepot_start_block);  fil_swriteU32 (output_block + 0x2c, &BDepot_blocks);  /* constant magic numbers */  fil_swriteU32 (output_block + 0x00, &identifier1);  fil_swriteU32 (output_block + 0x04, &identifier2);  fil_swriteU32 (output_block + 0x08, &U32magiczero);  fil_swriteU32 (output_block + 0x0c, &U32magiczero);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -