~ubuntu-branches/ubuntu/quantal/vice/quantal

« back to all changes in this revision

Viewing changes to src/attach.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2006-07-30 19:15:59 UTC
  • mto: (9.1.1 lenny) (1.1.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20060730191559-g31ymd2mk102kzff
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
#include "lib.h"
41
41
#include "log.h"
42
42
#include "machine-drive.h"
 
43
#include "network.h"
43
44
#include "resources.h"
44
45
#include "serial.h"
45
46
#include "snapshot.h"
 
47
#ifdef HAS_TRANSLATION
 
48
#include "translate.h"
 
49
#endif
46
50
#include "types.h"
47
51
#include "ui.h"
48
52
#include "vdrive-bam.h"
109
113
 
110
114
/* ------------------------------------------------------------------------- */
111
115
 
112
 
static const cmdline_option_t cmdline_options[] = {
113
 
    { "-device8", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice8",
114
 
      (void *)ATTACH_DEVICE_FS, "<type>",
115
 
      "Set device type for device #8 (0: NONE, 1: FS, 2: REAL, 3: RAW)" },
116
 
    { "-device9", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice9",
117
 
      (void *)ATTACH_DEVICE_FS, "<type>",
118
 
      "Set device type for device #9 (0: NONE, 1: FS, 2: REAL, 3: RAW)" },
119
 
    { "-device10", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice10",
120
 
      (void *)ATTACH_DEVICE_FS, "<type>",
121
 
      "Set device type for device #10 (0: NONE, 1: FS, 2: REAL, 3: RAW)" },
122
 
    { "-device11", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice11",
123
 
      (void *)ATTACH_DEVICE_FS, "<type>",
124
 
      "Set device type for device #11 (0: NONE, 1: FS, 2: REAL, 3: RAW)" },
125
 
    { "-attach8ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
126
 
      (resource_value_t)1,
127
 
      NULL, "Attach disk image for drive #8 read only" },
128
 
    { "-attach8rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
129
 
      (resource_value_t)0,
130
 
      NULL, "Attach disk image for drive #8 read write (if possible)" },
131
 
    { "-attach9ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
132
 
      (resource_value_t)1,
133
 
      NULL, "Attach disk image for drive #9 read only" },
134
 
    { "-attach9rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
135
 
      (resource_value_t)0,
136
 
      NULL, "Attach disk image for drive #9 read write (if possible)" },
137
 
    { "-attach10ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
138
 
      (resource_value_t)1,
139
 
      NULL, "Attach disk image for drive #10 read only" },
140
 
    { "-attach10rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
141
 
      (resource_value_t)0,
142
 
      NULL, "Attach disk image for drive #10 read write (if possible)" },
143
 
    { "-attach11ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
144
 
      (resource_value_t)1,
145
 
      NULL, "Attach disk image for drive #11 read only" },
146
 
    { "-attach11rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
147
 
      (resource_value_t)0,
148
 
      NULL, "Attach disk image for drive #11 read write (if possible)" },
149
 
    { NULL }
150
 
};
 
116
#ifdef HAS_TRANSLATION
 
117
static const cmdline_option_t cmdline_options[] = {
 
118
    { "-device8", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice8",
 
119
      (void *)ATTACH_DEVICE_FS, IDCLS_P_TYPE,
 
120
      IDCLS_SET_DEVICE_TYPE_8 },
 
121
    { "-device9", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice9",
 
122
      (void *)ATTACH_DEVICE_FS, IDCLS_P_TYPE,
 
123
      IDCLS_SET_DEVICE_TYPE_9 },
 
124
    { "-device10", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice10",
 
125
      (void *)ATTACH_DEVICE_FS, IDCLS_P_TYPE,
 
126
      IDCLS_SET_DEVICE_TYPE_10 },
 
127
    { "-device11", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice11",
 
128
      (void *)ATTACH_DEVICE_FS, IDCLS_P_TYPE,
 
129
      IDCLS_SET_DEVICE_TYPE_11 },
 
130
    { "-attach8ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
 
131
      (resource_value_t)1,
 
132
      0, IDCLS_ATTACH_READ_ONLY_8 },
 
133
    { "-attach8rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
 
134
      (resource_value_t)0,
 
135
      0, IDCLS_ATTACH_READ_WRITE_8 },
 
136
    { "-attach9ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
 
137
      (resource_value_t)1,
 
138
      0, IDCLS_ATTACH_READ_ONLY_9 },
 
139
    { "-attach9rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
 
140
      (resource_value_t)0,
 
141
      0, IDCLS_ATTACH_READ_WRITE_9 },
 
142
    { "-attach10ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
 
143
      (resource_value_t)1,
 
144
      0, IDCLS_ATTACH_READ_ONLY_10 },
 
145
    { "-attach10rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
 
146
      (resource_value_t)0,
 
147
      0, IDCLS_ATTACH_READ_WRITE_10 },
 
148
    { "-attach11ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
 
149
      (resource_value_t)1,
 
150
      0, IDCLS_ATTACH_READ_ONLY_11 },
 
151
    { "-attach11rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
 
152
      (resource_value_t)0,
 
153
      0, IDCLS_ATTACH_READ_WRITE_11 },
 
154
    { NULL }
 
155
};
 
156
#else
 
157
static const cmdline_option_t cmdline_options[] = {
 
158
    { "-device8", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice8",
 
159
      (void *)ATTACH_DEVICE_FS, N_("<type>"),
 
160
      N_("Set device type for device #8 (0: NONE, 1: FS, 2: REAL, 3: RAW)") },
 
161
    { "-device9", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice9",
 
162
      (void *)ATTACH_DEVICE_FS, N_("<type>"),
 
163
      N_("Set device type for device #9 (0: NONE, 1: FS, 2: REAL, 3: RAW)") },
 
164
    { "-device10", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice10",
 
165
      (void *)ATTACH_DEVICE_FS, N_("<type>"),
 
166
      N_("Set device type for device #10 (0: NONE, 1: FS, 2: REAL, 3: RAW)") },
 
167
    { "-device11", SET_RESOURCE, 1, NULL, NULL, "FileSystemDevice11",
 
168
      (void *)ATTACH_DEVICE_FS, N_("<type>"),
 
169
      N_("Set device type for device #11 (0: NONE, 1: FS, 2: REAL, 3: RAW)") },
 
170
    { "-attach8ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
 
171
      (resource_value_t)1,
 
172
      NULL, N_("Attach disk image for drive #8 read only") },
 
173
    { "-attach8rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice8Readonly",
 
174
      (resource_value_t)0,
 
175
      NULL, N_("Attach disk image for drive #8 read write (if possible)") },
 
176
    { "-attach9ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
 
177
      (resource_value_t)1,
 
178
      NULL, N_("Attach disk image for drive #9 read only") },
 
179
    { "-attach9rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice9Readonly",
 
180
      (resource_value_t)0,
 
181
      NULL, N_("Attach disk image for drive #9 read write (if possible)") },
 
182
    { "-attach10ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
 
183
      (resource_value_t)1,
 
184
      NULL, N_("Attach disk image for drive #10 read only") },
 
185
    { "-attach10rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice10Readonly",
 
186
      (resource_value_t)0,
 
187
      NULL, N_("Attach disk image for drive #10 read write (if possible)") },
 
188
    { "-attach11ro", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
 
189
      (resource_value_t)1,
 
190
      NULL, N_("Attach disk image for drive #11 read only") },
 
191
    { "-attach11rw", SET_RESOURCE, 0, NULL, NULL, "AttachDevice11Readonly",
 
192
      (resource_value_t)0,
 
193
      NULL, N_("Attach disk image for drive #11 read write (if possible)") },
 
194
    { NULL }
 
195
};
 
196
#endif
151
197
 
152
198
int file_system_cmdline_options_init(void)
153
199
{
407
453
    detach_disk_image(image, floppy, unit);
408
454
    
409
455
    if ((image != NULL) && (image == oldimg))
410
 
        lib_free(image);
 
456
        disk_image_destroy(image);
411
457
}
412
458
 
413
459
static int attach_disk_image(disk_image_t **imgptr, vdrive_t *floppy,
455
501
 
456
502
    detach_disk_image_and_free(*imgptr, floppy, unit);
457
503
 
458
 
    *imgptr = (disk_image_t *)lib_malloc(sizeof(disk_image_t));
 
504
    *imgptr = disk_image_create();
459
505
    image = *imgptr;
460
506
 
461
507
    memcpy(image, &new_image, sizeof(disk_image_t));
485
531
    if (err) {
486
532
        disk_image_close(image);
487
533
        disk_image_media_destroy(image);
488
 
        lib_free(image);
 
534
        disk_image_destroy(image);
489
535
        *imgptr = NULL;
490
536
    }
491
537
    return err;
521
567
   if (event_playback_active())
522
568
        return -1;
523
569
 
 
570
    if (network_connected()) {
 
571
        network_attach_image(unit, filename);
 
572
        return 0;
 
573
    }
 
574
 
524
575
   return file_system_attach_disk_internal(unit, filename);
525
576
}
526
577
 
561
612
 
562
613
void file_system_detach_disk(int unit)
563
614
{
564
 
   if (event_playback_active())
565
 
        return;
 
615
    char event_data[2];
 
616
 
 
617
    if (event_playback_active())
 
618
        return;
 
619
 
 
620
    event_data[0] = (char)unit;
 
621
    event_data[1] = 0;
 
622
 
 
623
    if (network_connected()) {
 
624
        network_event_record(EVENT_ATTACHDISK, (void *)event_data, 2);
 
625
        return;
 
626
    }
566
627
 
567
628
   file_system_detach_disk_internal(unit);
568
629
}