* Macintosh OpenTransport networking abstraction
*/
+#if TARGET_API_MAC_CARBON
+#define OTCARBONAPPLICATION 1
+#endif
+
+#include <Files.h> /* Needed by OpenTransportInternet.h */
#include <OpenTransport.h>
#include <OpenTptInternet.h>
CloseOpenTransport();
}
-SockAddr ot_namelookup(char *host, char **canonicalname)
+SockAddr ot_namelookup(char const *host, char **canonicalname)
{
- SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
+ SockAddr ret = snew(struct SockAddr_tag);
char *realhost;
-
- ret->error = OTInetStringToAddress(ot.inetsvc, host, &ret->hostinfo);
+
+ /* Casting away const -- hope OTInetStringToAddress is sensible */
+ ret->error = OTInetStringToAddress(ot.inetsvc, (char *)host,
+ &ret->hostinfo);
ret->resolved = TRUE;
if (ret->error == kOTNoError)
realhost = ret->hostinfo.name;
else
realhost = "";
- *canonicalname = smalloc(1+strlen(realhost));
+ *canonicalname = snewn(1+strlen(realhost), char);
strcpy(*canonicalname, realhost);
return ret;
}
-SockAddr ot_nonamelookup(char *host)
+SockAddr ot_nonamelookup(char const *host)
{
- SockAddr ret = smalloc(sizeof(struct SockAddr_tag));
+ SockAddr ret = snew(struct SockAddr_tag);
ret->resolved = FALSE;
ret->error = kOTNoError;
Actual_Socket ret;
- ret = smalloc(sizeof(struct Socket_tag));
+ ret = snew(struct Socket_tag);
ret->fn = &fn_table;
ret->error = kOTNoError;
ret->plug = plug;
InetAddress dest;
TCall connectCall;
- ret = smalloc(sizeof(struct Socket_tag));
+ ret = snew(struct Socket_tag);
ret->fn = &fn_table;
ret->error = kOTNoError;
ret->plug = plug;
do {
o = OTRcv(s->ep, buf, sizeof(buf), &flags);
if (o > 0)
- plug_receive(s->plug, 0, buf, sizeof(buf));
+ plug_receive(s->plug, 0, buf, o);
if (o < 0 && o != kOTNoDataErr)
plug_closing(s->plug, NULL, 0, 0); /* XXX Error msg */
} while (o > 0);