#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <atalk/nbp.h>
#include <atalk/netddp.h>
#include <atalk/ddp.h>
+#include <atalk/util.h>
/* FIXME/SOCKLEN_T: socklen_t is a unix98 feature */
#ifndef SOCKLEN_T
time_t totalms = 0, minms = -1, maxms = -1;
static unsigned int pings = 0;
-#if !defined( ibm032 ) && !defined( _IBMR2 )
- void
-#endif ibm032 _IBMR2
-done()
+void usage(char *);
+
+void done()
{
if ( nsent > 0 ) {
printf( "\n----%d.%d AEP Statistics----\n",
printf( "%d packets sent, %d packets received, %d%% packet loss\n",
nsent, nrecv, (( nsent - nrecv ) * 100 ) / nsent );
if ( nrecv > 0 ) {
- printf( "round-trip (ms) min/avg/max = %d/%d/%d\n",
+ printf( "round-trip (ms) min/avg/max = %ld/%ld/%ld\n",
minms, totalms / nrecv, maxms );
}
}
exit( 0 );
}
-#if !defined( ibm032 ) && !defined( _IBMR2 )
- void
-#endif ibm032 _IBMR2
-aep_send()
+void aep_send()
{
struct timeval tv;
char *p, buf[ 1024 ];
if (pings && nsent > pings) done();
}
-main( ac, av )
+int main( ac, av )
int ac;
char **av;
{
if ( ms < minms || minms == -1 ) {
minms = ms;
}
- printf( "%d bytes from %u.%u: aep_seq=%d. time=%d. ms\n",
+ printf( "%d bytes from %u.%u: aep_seq=%d. time=%ld. ms\n",
cc, ntohs( sat.sat_addr.s_net ), sat.sat_addr.s_node,
seq, ms );
if (pings && seq + 1 >= pings) done();
}
}
-usage( av0 )
+void usage( char * av0 )
{
fprintf( stderr, "usage:\t%s [-A source address ] [-c count] ( addr | nbpname )\n", av0 );
exit( 1 );
#include <sys/param.h>
#include <sys/uio.h>
#include <sys/time.h>
+#include <unistd.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <netatalk/endian.h>
#include <netatalk/at.h>
#include <atalk/atp.h>
+#include <atalk/util.h>
#include <atalk/zip.h>
-usage( s )
+void print_zones(short n, char *buf);
+
+void usage( s )
char *s;
{
fprintf( stderr, "usage:\t%s [-m | -l] [address]\n", s );
exit( 1 );
}
-main( argc, argv )
+int main( argc, argv )
int argc;
char *argv[];
{
}
-print_zones( n, buf )
+void print_zones( n, buf )
short n; /* number of zones in this packet */
char *buf; /* zone length/name pairs */
{
#include <sys/time.h>
#include <sys/param.h>
#include <fcntl.h>
+#include <time.h>
#include <string.h>
#include <syslog.h>
#include <ctype.h>
#include <netatalk/endian.h>
#include "megatron.h"
+int single_header_read(struct FHeader *fh, int version);
+int single_close(int readflag);
+int single_header_test(void);
+
/* String used to indicate standard input instead of a disk
file. Should be a string not normally used for a file
*/
* somewhat initialized; single_filed is set.
*/
-single_open( singlefile, flags, fh, options )
+int single_open( singlefile, flags, fh, options )
char *singlefile;
int flags, options;
struct FHeader *fh;
single_close( KEEP );
return( -1 );
}
+ return( 0 );
}
/*
* Otherwise, a value of -1 is returned.
*/
-single_close( keepflag )
+int single_close( keepflag )
int keepflag;
{
if ( keepflag == KEEP ) {
* bytes of the other two forks can be read, as well.
*/
-single_header_read( fh, version )
+int single_header_read( fh, version )
struct FHeader *fh;
int version;
{
u_char sixteennulls[] = { 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
-single_header_test()
+int single_header_test(void)
{
int cc;
u_int32_t templong;
*
*/
-single_read( fork, buffer, length )
+int single_read( fork, buffer, length )
int fork;
char *buffer;
int length;
/*
- * $Id: hqx.c,v 1.4 2001-03-29 16:40:35 rufustfirefly Exp $
+ * $Id: hqx.c,v 1.5 2001-05-01 13:21:22 rufustfirefly Exp $
*/
#ifdef HAVE_CONFIG_H
# include <netinet/in.h>
#endif
#endif notdef
+#include <time.h>
#include <fcntl.h>
#include <string.h>
#include <syslog.h>
/* These are field sizes in bytes of various pieces of the
binhex header
*/
-#define BVERSION 1
-#define TCSIZ 8
-#define FLAGSIZ 2
-#define DATASIZ 4
-#define RESSIZ 4
-#define CRCSIZ 2
-#define HEADSIZ 21
+#define BHH_VERSION 1
+#define BHH_TCSIZ 8
+#define BHH_FLAGSIZ 2
+#define BHH_DATASIZ 4
+#define BHH_RESSIZ 4
+#define BHH_CRCSIZ 2
+#define BHH_HEADSIZ 21
u_short updcrc();
here; skip_junk leaves hqx7_first and hqx7_last set.
*/
-hqx_open( hqxfile, flags, fh, options )
+int hqx_open( hqxfile, flags, fh, options )
char *hqxfile;
int flags, options;
struct FHeader *fh;
* Otherwise, a value of -1 is returned.
*/
-hqx_close( keepflag )
+int hqx_close( keepflag )
int keepflag;
{
if ( keepflag == KEEP ) {
* return zero and no more than that.
*/
-hqx_read( fork, buffer, length )
+int hqx_read( fork, buffer, length )
int fork;
char *buffer;
int length;
* to fill the hqx_header fields.
*/
-hqx_header_read( fh )
+int hqx_header_read( fh )
struct FHeader *fh;
{
char *headerbuf, *headerptr;
#endif
if (( headerbuf =
- (char *)malloc( (unsigned int)( namelen + HEADSIZ ))) == 0 ) {
+ (char *)malloc( (unsigned int)( namelen + BHH_HEADSIZ ))) == 0 ) {
return( -1 );
}
- if ( hqx_7tobin( headerbuf, ( namelen + HEADSIZ )) == 0 ) {
+ if ( hqx_7tobin( headerbuf, ( namelen + BHH_HEADSIZ )) == 0 ) {
free( headerbuf );
fprintf( stderr, "Premature end of file :" );
return( -2 );
}
headerptr = headerbuf;
hqx.headercrc = updcrc( hqx.headercrc,
- (u_char *)headerbuf, ( namelen + HEADSIZ - CRCSIZ ));
+ (u_char *)headerbuf, ( namelen + BHH_HEADSIZ - BHH_CRCSIZ ));
#if HEXOUTPUT
- write( headerfork, headerbuf, ( namelen + HEADSIZ ));
+ write( headerfork, headerbuf, ( namelen + BHH_HEADSIZ ));
#endif
/*
headerptr += TCSIZ;
memcpy(&fh->finder_info.fdFlags, headerptr, FLAGSIZ );
fh->finder_info.fdFlags = fh->finder_info.fdFlags & mask;
- headerptr += FLAGSIZ;
- memcpy(&fh->forklen[ DATA ], headerptr, DATASIZ );
+ headerptr += BHH_FLAGSIZ;
+ memcpy(&fh->forklen[ DATA ], headerptr, BHH_DATASIZ );
hqx.forklen[ DATA ] = ntohl( fh->forklen[ DATA ] );
- headerptr += DATASIZ;
- memcpy( &fh->forklen[ RESOURCE ], headerptr, RESSIZ );
+ headerptr += BHH_DATASIZ;
+ memcpy( &fh->forklen[ RESOURCE ], headerptr, BHH_RESSIZ );
hqx.forklen[ RESOURCE ] = ntohl( fh->forklen[ RESOURCE ] );
- headerptr += RESSIZ;
- memcpy(&header_crc, headerptr, CRCSIZ );
- headerptr += CRCSIZ;
+ headerptr += BHH_RESSIZ;
+ memcpy(&header_crc, headerptr, BHH_CRCSIZ );
+ headerptr += BHH_CRCSIZ;
header_crc = ntohs( header_crc );
/*
* hqx_header_write.
*/
-hqx_header_write( fh )
+int hqx_header_write( fh )
struct FHeader *fh;
{
return( -1 );
* it sets the pointers to the hqx7 buffer up to point to the valid data.
*/
-hqx7_fill( hqx7_ptr )
+int hqx7_fill( hqx7_ptr )
u_char *hqx7_ptr;
{
int cc;
* OTHER when looking for any subsequent line.
*/
-skip_junk( line )
+int skip_junk( line )
int line;
{
int found = NOWAY;
* file is reached.
*/
-hqx_7tobin( outbuf, datalen )
+int hqx_7tobin( outbuf, datalen )
char *outbuf;
int datalen;
{
static u_char hqx8[3];
- static char hqx8i;
+ static int hqx8i;
static u_char prev_hqx8;
static u_char prev_out;
static u_char prev_hqx7;
static int eofflag;
u_char hqx7[4];
- char hqx7i = 0;
+ int hqx7i = 0;
char *out_first;
char *out_last;
#include <sys/param.h>
#include <fcntl.h>
#include <unistd.h>
+#include <string.h>
#include <strings.h>
#include <syslog.h>
#include <ctype.h>
* somewhat initialized; bin_filed is set.
*/
-bin_open( binfile, flags, fh, options )
+int bin_open( binfile, flags, fh, options )
char *binfile;
int flags, options;
struct FHeader *fh;
bin.gmtoff = 0;
#ifndef NO_STRUCT_TM_GMTOFF
time(&t);
- if (tp = localtime(&t))
+ tp = localtime(&t);
+ if (tp)
bin.gmtoff = tp->tm_gmtoff;
#endif
* Otherwise, a value of -1 is returned.
*/
-bin_close( keepflag )
+int bin_close( keepflag )
int keepflag;
{
#if DEBUG
* return zero and no more than that.
*/
-bin_read( fork, buffer, length )
+int bin_read( fork, buffer, length )
int fork;
char *buffer;
int length;
#if DEBUG
fprintf( stderr, "current position is %ld\n", pos );
#endif
- if (pos = pos % HEADBUFSIZ) {
+ pos %= HEADBUFSIZ;
+ if (pos != 0) {
pos = lseek( bin.filed, HEADBUFSIZ - pos, SEEK_CUR );
}
#if DEBUG
* bin_write
*/
-bin_write( fork, buffer, length )
+int bin_write( fork, buffer, length )
int fork;
char *buffer;
int length;
#if DEBUG
fprintf( stderr, "current position is %ld\n", pos );
#endif
- if (pos = pos % HEADBUFSIZ) { /* pad only if we need to */
+ pos %= HEADBUFSIZ;
+ if (pos != 0) { /* pad only if we need to */
pos = lseek( bin.filed, HEADBUFSIZ - pos - 1, SEEK_CUR );
if ( write( bin.filed, &padchar, 1 ) != 1 ) {
perror( "Couldn't write to macbinary file:" );
* of the bytes of the other two forks can be read, as well.
*/
-bin_header_read( fh, revision )
+int bin_header_read( fh, revision )
struct FHeader *fh;
int revision;
{
* bin_header_write and bin_header_read are opposites.
*/
-bin_header_write( fh )
+int bin_header_write( fh )
struct FHeader *fh;
{
char *write_ptr;
* so, the check for byte 74 isn't very useful.
*/
-test_header()
+int test_header()
{
const char zeros[25] = "";
u_int32_t cc;
#include <sys/stat.h>
#include <sys/uio.h>
#include <fcntl.h>
+#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
continue;
}
- if ( rc = megatron( argv[ c ], module, newname, flags) != 0 ) {
+ rc = megatron( argv[ c ], module, newname, flags);
+ if ( rc != 0 ) {
rv = rc;
}
*newname = '\0';
struct adouble ad;
} nad;
-nad_open( path, openflags, fh, options )
+int nad_open( path, openflags, fh, options )
char *path;
int openflags, options;
struct FHeader *fh;
}
}
-nad_header_read( fh )
+int nad_header_read( fh )
struct FHeader *fh;
{
u_int32_t temptime;
}
-nad_header_write( fh )
+int nad_header_write( fh )
struct FHeader *fh;
{
u_int32_t temptime;
int forkeid[] = { ADEID_DFORK, ADEID_RFORK };
-nad_read( fork, forkbuf, bufc )
+int nad_read( fork, forkbuf, bufc )
int fork;
char *forkbuf;
int bufc;
return( cc );
}
-nad_write( fork, forkbuf, bufc )
+int nad_write( fork, forkbuf, bufc )
int fork;
char *forkbuf;
int bufc;
return( bufc );
}
-nad_close( status )
+int nad_close( status )
int status;
{
int rv;
}
return( 0 );
} else return( -1 );
+ return( 0 );
}
/* Value used by: CCITT XMODEM ARC */
#define P 0x1021 /* the poly: 0x1021 0x1021 A001 */
#define INIT_CRC 0L /* init value: -1 0 0 */
-/*#define SWAPPED /* bit order: undef defined defined */
+#if 0
+#define SWAPPED /* bit order: undef defined defined */
+#endif
#define W 16 /* bits in CRC:16 16 16 */
/* data type that holds a W-bit unsigned integer */
#include <string.h>
char hexdig[] = "0123456789abcdef";
-bprint( data, len )
+void bprint( data, len )
char *data;
int len;
{
if (!ifacelist)
return;
- while (value = *list++) {
+ while ((value = *list++)) {
free(value);
}