static void parse_boot(struct uae_prefs *p, xmlNode *node)
{
  for(xmlNode *curr_node = node; curr_node; curr_node = curr_node->next) 
  {
    if (curr_node->type == XML_ELEMENT_NODE && strcmp((const char *)curr_node->name, _T("boot")) == 0) 
    {
      xmlChar *attr = xmlGetProp(curr_node, (const xmlChar *) _T("type"));
      if(attr != NULL) 
      {
        if(strcmp((const char *) attr, "hdf") == 0)
        {
          // Build-in hdf required
          xmlChar *content = xmlNodeGetContent(curr_node);
          if(content != NULL)
          {
            char target_file[MAX_DPATH];
            fetch_rp9path(target_file, MAX_DPATH);
            strncat(target_file, "workbench-", MAX_DPATH);
            strncat(target_file, (const char *)content, MAX_DPATH);
            strncat(target_file, ".hdf", MAX_DPATH);
            FILE *f = fopen(target_file, "rb");
            if(f != NULL)
            {
              char dhx[8];
              struct uaedev_config_info *uci;
              int readonly = 0;
              
              fclose(f);
              
              xmlChar *ro = xmlGetProp(curr_node, (const xmlChar *) _T("readonly"));
              if(ro != NULL)
              {
                if(strcmp((const char *) ro, "true") == 0)
                  readonly = 1;
                xmlFree(ro);
              }

              sprintf(dhx, "DH%d", add_HDF_DHnum);
              ++add_HDF_DHnum;
              if(hardfile_testrdb (target_file))                        
                uci = add_filesys_config(p, -1, dhx, 0, target_file, readonly, 0, 0, 0, 512, 127, 0, 0, 0);
              else
                uci = add_filesys_config(p, -1, dhx, 0, target_file, readonly, 32, 1, 2, 512, 127, 0, 0, 0);
              if (uci)
                hardfile_do_disk_change (uci, 1);
              gui_force_rtarea_hdchange();
            }
            xmlFree(content);
          }
        }
        xmlFree(attr);
      }
    }
  }
}
Exemple #2
0
void load_buildin_config(int id)
{
  if(changed_prefs.cdslots[0].inuse)
    gui_force_rtarea_hdchange();
  discard_prefs(&changed_prefs, 0);
  default_prefs(&changed_prefs, 0);
  switch(id) {
    case BUILDINID_A500:
      bip_a500(&changed_prefs, -1);
      break;
    
    case BUILDINID_A1200:
      bip_a1200(&changed_prefs, -1);
      break;
      
    case BUILDINID_CD32:
      bip_cd32(&changed_prefs, -1);
      break;
  }
}
static void extract_media(struct uae_prefs *p, unzFile uz, xmlNode *node)
{
  xmlNode *tmp = get_node(node, "media");
  if(tmp != NULL) 
  {
    for(xmlNode *curr_node = tmp; curr_node; curr_node = curr_node->next) 
    {
      int mediatype = -1;
      if (curr_node->type == XML_ELEMENT_NODE && strcmp((const char *)curr_node->name, _T("floppy")) == 0)
        mediatype = 0;
      else if (curr_node->type == XML_ELEMENT_NODE && strcmp((const char *)curr_node->name, _T("harddrive")) == 0)
        mediatype = 1;
      if(mediatype >= 0)
      {
        xmlChar *content = xmlNodeGetContent(curr_node);
        if(content != NULL) 
        {
          int priority = 0;
          xmlChar *attr = xmlGetProp(curr_node, (const xmlChar *) _T("priority"));
          if(attr != NULL) 
          {
            priority = atoi((const char *)attr);
            xmlFree(attr);
          }
        	
        	if (unzLocateFile (uz, (char *)content, 1) == UNZ_OK)
          {
            unz_file_info file_info;
            if (unzGetCurrentFileInfo (uz, &file_info, NULL, 0, NULL, 0, NULL, 0) == UNZ_OK)
            {
              void *buffer = malloc(file_info.uncompressed_size);
              if(buffer != NULL)
              {
                if (unzOpenCurrentFile (uz) == UNZ_OK)
                {
                  int readsize = unzReadCurrentFile(uz, buffer, file_info.uncompressed_size);
                  unzCloseCurrentFile(uz);
                  if(readsize == file_info.uncompressed_size)
                  {
                    char target_file[MAX_DPATH];
                    snprintf(target_file, MAX_DPATH, "%s%s", rp9tmp_path, content);
                    FILE *f = fopen(target_file, "wb");
                    if(f != NULL)
                    {
                      fwrite(buffer, 1, readsize, f);
                      fclose(f);
                      if(mediatype == 0)
                      {
                        // Add floppy
                        if(priority < 2)
                        {
                  	      strncpy(p->floppyslots[0].df, target_file, sizeof(p->floppyslots[0].df));
                  	      disk_insert(0, p->floppyslots[0].df);
                  	    }
                  	    else if(priority == 2 && p->nr_floppies > 1)
                	      {
                  	      strncpy(p->floppyslots[1].df, target_file, sizeof(p->floppyslots[1].df));
                  	      disk_insert(1, p->floppyslots[1].df);
                	      }
                  	    else if(priority == 3 && p->nr_floppies > 2)
                	      {
                  	      strncpy(p->floppyslots[2].df, target_file, sizeof(p->floppyslots[2].df));
                  	      disk_insert(2, p->floppyslots[2].df);
                	      }
                  	    else if(priority == 4 && p->nr_floppies > 3)
                	      {
                  	      strncpy(p->floppyslots[3].df, target_file, sizeof(p->floppyslots[3].df));
                  	      disk_insert(3, p->floppyslots[3].df);
                	      }
                        AddFileToDiskList(target_file, 1);
                      }
                      else
                      {
                        // Add hardfile
                        struct uaedev_config_info *uci;
                        char dhx[8];

                        sprintf(dhx, "DH%d", add_HDF_DHnum);
                        ++add_HDF_DHnum;
                        if(hardfile_testrdb (target_file))                        
                          uci = add_filesys_config(p, -1, dhx, 0, target_file, 0, 0, 0, 0, 512, 0, 0, 0, 0);
                        else
                          uci = add_filesys_config(p, -1, dhx, 0, target_file, 0, 32, 1, 2, 512, 0, 0, 0, 0);
                        if (uci)
    	                    hardfile_do_disk_change (uci, 1);
    	                  gui_force_rtarea_hdchange();
                      }
                      lstTmpRP9Files.push_back(target_file);
                    }
                  }
                }
                free(buffer);
              }
            }
          }
          
          xmlFree(content);
        }      
      }
    }
  }
}