~ubuntu-branches/ubuntu/lucid/gpgme1.0/lucid-security

« back to all changes in this revision

Viewing changes to gpgme/data.c

  • Committer: Bazaar Package Importer
  • Author(s): Jose Carlos Garcia Sogo
  • Date: 2005-10-08 14:26:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051008142601-jajb789561w8nwhu
Tags: 1.1.0-1
New upstream version. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* data.c - An abstraction for data objects.
2
 
   Copyright (C) 2002, 2003, 2004 g10 Code GmbH
 
2
   Copyright (C) 2002, 2003, 2004, 2005 g10 Code GmbH
3
3
 
4
4
   This file is part of GPGME.
5
5
 
31
31
#include "data.h"
32
32
#include "util.h"
33
33
#include "ops.h"
34
 
#include "io.h"
 
34
#include "priv-io.h"
35
35
 
36
36
 
37
37
gpgme_error_t
57
57
void
58
58
_gpgme_data_release (gpgme_data_t dh)
59
59
{
60
 
  if (dh)
61
 
    free (dh);
 
60
  if (!dh)
 
61
    return;
 
62
 
 
63
  if (dh->file_name)
 
64
    free (dh->file_name);
 
65
  free (dh);
62
66
}
63
67
 
64
68
 
75
79
    }
76
80
  if (!dh->cbs->read)
77
81
    {
78
 
      errno = EOPNOTSUPP;
 
82
      errno = ENOSYS;
79
83
      return -1;
80
84
    }
81
85
  return (*dh->cbs->read) (dh, buffer, size);
95
99
    }
96
100
  if (!dh->cbs->write)
97
101
    {
98
 
      errno = EOPNOTSUPP;
 
102
      errno = ENOSYS;
99
103
      return -1;
100
104
    }
101
105
  return (*dh->cbs->write) (dh, buffer, size);
115
119
    }
116
120
  if (!dh->cbs->seek)
117
121
    {
118
 
      errno = EOPNOTSUPP;
 
122
      errno = ENOSYS;
119
123
      return -1;
120
124
    }
121
125
 
167
171
  return 0;
168
172
}
169
173
 
 
174
 
 
175
/* Set the file name associated with the data object with handle DH to
 
176
   FILE_NAME.  */
 
177
gpgme_error_t
 
178
gpgme_data_set_file_name (gpgme_data_t dh, const char *file_name)
 
179
{
 
180
  if (!dh)
 
181
    return gpg_error (GPG_ERR_INV_VALUE);
 
182
 
 
183
  if (dh->file_name)
 
184
    free (dh->file_name);
 
185
 
 
186
  dh->file_name = strdup (file_name);
 
187
  if (!dh->file_name)
 
188
    return gpg_error_from_errno (errno);
 
189
 
 
190
  return 0;
 
191
}
 
192
 
 
193
/* Get the file name associated with the data object with handle DH,
 
194
   or NULL if there is none.  */
 
195
char *
 
196
gpgme_data_get_file_name (gpgme_data_t dh)
 
197
{
 
198
  if (!dh)
 
199
    return NULL;
 
200
 
 
201
  return dh->file_name;
 
202
}
 
203
 
170
204
 
171
205
/* Functions to support the wait interface.  */
172
206