Logo Search packages:      
Sourcecode: cbmlink version File versions  Download package

static int drive_image_read ( const char *  cmd,
const char *  filename 
) [static]

copy the contents of a disk accessible by the remote host to a file

Parameters:
cmd the -dr command
filename name of the file to be saved, "-" for stdout
Returns:
zero on success, nonzero on error

output file

drive unit

start and end track

Definition at line 674 of file cbmlink.c.

References buffer, device, disk_install(), disk_params(), disk_read(), disk_remove(), and interleave.

Referenced by main().

{
  /** output file */
  FILE* f;
  /** drive unit */
  unsigned unit;
  /** start and end track */
  unsigned track, track_end;

  if (disk_params (cmd, &unit, &track, &track_end))
    return -1;

  f = *filename == '-' && !filename[1] ? stdout : fopen (filename, "wb");
  if (!f) {
    fputs (filename, stderr), perror (": fopen(writing)");
    return -2;
  }

  if (disk_install (comm, hostinfo, device)) {
    fputs ("disk: installation failed\n", stderr);
    if (f != stdout) fclose (f);
    return 2;
  }

  if (disk_read (comm, unit, interleave, track, track_end, f, buffer)) {
    fputs ("disk: read failed\n", stderr);
    if (f != stdout)
      fclose (f);
    if (disk_remove (comm)) {
    diskRemove:
      fputs ("disk: removal failed\n", stderr);
      return 2;
    }
    return 1;
  }

  if (disk_remove (comm))
    goto diskRemove;

  return 0;
}


Generated by  Doxygen 1.6.0   Back to index