-/* $Id: macstore.c,v 1.1 2002/11/19 02:13:46 ben Exp $ */
+/* $Id: macstore.c,v 1.2 2002/12/12 23:55:51 ben Exp $ */
/*
* macstore.c: Macintosh-specific impementation of the interface
int fd;
Handle h;
OSErr error;
+ size_t len;
if (handle == NULL) goto out;
fd = *(int *)handle;
h = get1namedresource(FOUR_CHAR_CODE('TEXT'), key);
if (h == NULL) goto out;
- if (GetHandleSize(h) > buflen) goto out;
- p2cstrcpy(buffer, (StringPtr)*h);
+ len = GetHandleSize(h);
+ if (len + 1 > buflen) goto out;
+ memcpy(buffer, *h, len);
+ buffer[len] = '\0';
+
ReleaseResource(h);
if (ResError() != noErr) goto out;
return buffer;