Example #1
0
File: scmio.c Project: rlk/scmtiff
long long scm_write_header(scm *s, header *h)
{
    assert(s);
    assert(h);

    if (scm_seek(s, 0))
    {
        return scm_write(s, h, sizeof (header));
    }
    return -1;
}
Example #2
0
static int
port_seek (void *cookie, off64_t * pos, int whence)
{
  SCM port = PTR2SCM (cookie);
  SCM new_pos;

  new_pos = scm_seek (port, scm_from_int64 (*pos), scm_from_int (whence));
  *pos = scm_to_int64 (new_pos);

  return PORT_OK;
}
Example #3
0
File: scmio.c Project: rlk/scmtiff
bool scm_read(scm *s, void *ptr, size_t len, long long o)
{
    if (scm_seek(s, o))
    {
        if (fread(ptr, 1, len, s->fp) == len)
        {
            return true;
        }
        else syserr("Failed to read SCM");
    }
    else syserr("Failed to seek SCM");

    return false;
}
Example #4
0
File: scmio.c Project: rlk/scmtiff
long long scm_write_ifd(scm *s, ifd *d, long long o)
{
    assert(s);
    assert(d);

    if (o)
    {
        if (scm_seek(s, o))
        {
            return scm_write(s, d, sizeof (ifd));
        }
        else return -1;
    }
    else return scm_write(s, d, sizeof (ifd));
}
Example #5
0
static const char *
gdbscm_disasm_read_memory_worker (void *datap)
{
  struct gdbscm_disasm_read_data *data
    = (struct gdbscm_disasm_read_data *) datap;
  struct disassemble_info *dinfo = data->dinfo;
  struct gdbscm_disasm_data *disasm_data
    = (struct gdbscm_disasm_data *) dinfo->application_data;
  SCM seekto, newpos, port = disasm_data->port;
  size_t bytes_read;

  seekto = gdbscm_scm_from_ulongest (data->memaddr - disasm_data->offset);
  newpos = scm_seek (port, seekto, scm_from_int (SEEK_SET));
  if (!scm_is_eq (seekto, newpos))
    return "seek error";

  bytes_read = scm_c_read (port, data->myaddr, data->length);

  if (bytes_read != data->length)
    return "short read";

  /* If we get here the read succeeded.  */
  return NULL;
}