Patch title: Release 87 bulk changes
Abstract:
File: /pliant/language/os/dump.c
Key:
    Removed line
    Added line
   
// Copyright  Hubert Tonneau  hubert.tonneau@pliant.cx
//
// This program is free software; you can redistribute it an
// modify it under the terms of the GNU General Public Licen
// as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be u
// but WITHOUT ANY WARRANTY; without even the implied warran
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// version 2 along with this program; if not, write to the F
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA


FUNCTION Bool process_restore(Int debugging_level,Char *plia
  Char buffer[256]; struct Str temp; Any handle;
  struct PliantSignature s;
  struct MemoryPool *pool; Int i;
  struct PliantArea a; Int red;
  Arrow *r; struct DelayedAction *da;
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R1\r",3);
  #endif
  G.debugging_level=debugging_level;
  G.pliant_root_path.chars=pliant_path; G.pliant_root_path.l
  if(!build_full_br_name(filename,buffer,&temp)) return fals
  handle=file_open(&temp,file_in); if(handle==-1) return fal
  file_read(handle,(Address)&s,sizeof(s));
  #if defined(_DLL_)
    if(s.signature!=0x738F5EC1 || s.c_level!=c_debugging_lev
  #else
    if(s.signature!=0x738F5EC1 || s.c_level!=c_debugging_lev
  #endif
    file_close(handle);
// Copyright  Hubert Tonneau  hubert.tonneau@pliant.cx
//
// This program is free software; you can redistribute it an
// modify it under the terms of the GNU General Public Licen
// as published by the Free Software Foundation.
// 
// This program is distributed in the hope that it will be u
// but WITHOUT ANY WARRANTY; without even the implied warran
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public
// version 2 along with this program; if not, write to the F
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA


FUNCTION Bool process_restore(Int debugging_level,Char *plia
  Char buffer[256]; struct Str temp; Any handle;
  struct PliantSignature s;
  struct MemoryPool *pool; Int i;
  struct PliantArea a; Int red;
  Arrow *r; struct DelayedAction *da;
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R1\r",3);
  #endif
  G.debugging_level=debugging_level;
  G.pliant_root_path.chars=pliant_path; G.pliant_root_path.l
  if(!build_full_br_name(filename,buffer,&temp)) return fals
  handle=file_open(&temp,file_in); if(handle==-1) return fal
  file_read(handle,(Address)&s,sizeof(s));
  #if defined(_DLL_)
    if(s.signature!=0x738F5EC1 || s.c_level!=c_debugging_lev
  #else
    if(s.signature!=0x738F5EC1 || s.c_level!=c_debugging_lev
  #endif
    file_close(handle);
    consolen(Z,"File ",S,filename,Z," is not compatible with
    // consolen(Z,"File ",S,filename,Z," is not compatible with your configuration !\nPlease rebuild it.",EOL);
    return false; }
  file_read(handle,(Address)&G,sizeof(G));
  G.memory_current_consumed=0;
  G.memory_maximum_consumed=0;
  G.execution_phase=phase_restore;
  for(pool=&G.memory_pool; pool!=null; pool=pool->next)
    for(i=0; i<pool->nb_area; i++) {
      a.address=memory_page_reserve(pool->areas[i].address,p
      if(a.address!=pool->areas[i].address) {
        consolen(Z,"Failed to restore memory from ",S,filena
        process_exit(error_id_restore); } }
  for(;;) {
    a.address=null; file_read(handle,(Address)&a,sizeof(a));
    memory_page_commit(a.address,a.size);
    red=file_read(handle,a.address,a.size);
    if(red!=a.size) {
      consolen(Z,"File ",S,filename,Z," is corrupted !",EOL)
      file_close(handle);
      handle=file_open(&temp,file_out);
      s.signature=0;
      file_write(handle,(Address)&s,sizeof(s));
      file_close(handle);
      process_exit(error_id_restore); } }
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R2\r",3);
  #endif
  #ifndef _STATIC_
    restore_externals();
  #endif
  for(r=List_first(G.restore_actions); r!=G.null_constant; r
    check(entry_type(*r)==G.type_DelayedAction);
    da=(struct DelayedAction *)*r;
    ((RestoreActionPrototype)da->function->exe)(da->paramete
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R3\r",3);
  #endif
  file_close(handle);
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"  \r",3);
  #endif
  G.execution_phase=phase_wakeup;
  for(r=List_first(G.wakeup_actions); r!=G.null_constant; r=
    check(entry_type(*r)==G.type_DelayedAction);
    da=(struct DelayedAction *)*r;
    ((WakeupActionPrototype)da->function->exe)(da->parameter
  G.execution_phase=phase_run;
  return true; }
    return false; }
  file_read(handle,(Address)&G,sizeof(G));
  G.memory_current_consumed=0;
  G.memory_maximum_consumed=0;
  G.execution_phase=phase_restore;
  for(pool=&G.memory_pool; pool!=null; pool=pool->next)
    for(i=0; i<pool->nb_area; i++) {
      a.address=memory_page_reserve(pool->areas[i].address,p
      if(a.address!=pool->areas[i].address) {
        consolen(Z,"Failed to restore memory from ",S,filena
        process_exit(error_id_restore); } }
  for(;;) {
    a.address=null; file_read(handle,(Address)&a,sizeof(a));
    memory_page_commit(a.address,a.size);
    red=file_read(handle,a.address,a.size);
    if(red!=a.size) {
      consolen(Z,"File ",S,filename,Z," is corrupted !",EOL)
      file_close(handle);
      handle=file_open(&temp,file_out);
      s.signature=0;
      file_write(handle,(Address)&s,sizeof(s));
      file_close(handle);
      process_exit(error_id_restore); } }
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R2\r",3);
  #endif
  #ifndef _STATIC_
    restore_externals();
  #endif
  for(r=List_first(G.restore_actions); r!=G.null_constant; r
    check(entry_type(*r)==G.type_DelayedAction);
    da=(struct DelayedAction *)*r;
    ((RestoreActionPrototype)da->function->exe)(da->paramete
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"R3\r",3);
  #endif
  file_close(handle);
  #if defined(_LINUX_API_) && defined(_CHECK_) && defined(_V
    write(1,"  \r",3);
  #endif
  G.execution_phase=phase_wakeup;
  for(r=List_first(G.wakeup_actions); r!=G.null_constant; r=
    check(entry_type(*r)==G.type_DelayedAction);
    da=(struct DelayedAction *)*r;
    ((WakeupActionPrototype)da->function->exe)(da->parameter
  G.execution_phase=phase_run;
  return true; }