home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 3
/
goldfish_volume_3.bin
/
files
/
comm
/
tcp
/
ftpdaemon
/
source
/
sockuser.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-26
|
1KB
|
92 lines
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <exec/types.h>
#include <proto/socket.h>
#include "ftp.h"
extern LONG server_socket;
static char buf[1024];
int recvchar(LONG s)
{
char c;
if(recv(s,&c,1,0)==-1) return EOF;
return (int)c;
}
/* Buffered putchar to a socket */
int usputc(LONG s,char c)
{
static char *rn="\r\n";
if(c=='\n') return send(s,rn,2,0);
return send(s,&c,1,0);
}
/* The guts of printf, uses variable arg version of sprintf */
int usvprintf(int s,char *fmt, va_list args)
{
int len;
int i;
char *cp;
vsprintf(buf,fmt,args);
len = strlen(buf);
cp = buf;
i = len;
while(i-->0) usputc(s,*cp++);
return len;
}
/* Do printf on a user socket */
int usprintf(LONG s,char *fmt,...)
{
va_list args;
int len;
va_start(args,fmt);
len = usvprintf(s,fmt,args);
va_end(args);
return len;
}
/* Printf on standard output socket */
int tprintf(char *fmt,...)
{
va_list args;
int len;
va_start(args,fmt);
len = usvprintf(server_socket,fmt,args);
va_end(args);
return len;
}
/* Put a character to standard output socket */
int tputc(char c)
{
return usputc(server_socket,c);
}
int usputs(LONG s,char *x)
{
while(*x != '\0')
if(usputc(s,*x++) == EOF)
return EOF;
return 0;
}
/* Put a string to standard output socket */
int tputs(char *s)
{
return usputs(server_socket,s);
}