/*
- * $Id: nad.c,v 1.12 2005-04-28 20:49:20 bfernhomberg Exp $
+ * $Id: nad.c,v 1.18 2010-01-27 21:27:53 didg Exp $
*/
#ifdef HAVE_CONFIG_H
#include "megatron.h"
#include "nad.h"
-struct volinfo vol;
+static struct volinfo vol;
static char hexdig[] = "0123456789abcdef";
static char mtou_buf[MAXPATHLEN + 1], utom_buf[MAXPATHLEN + 1];
-static char *mtoupathcap( mpath )
- char *mpath;
+static char *mtoupathcap(char *mpath)
{
char *m, *u, *umax;
int i = 0;
#define hextoint( c ) ( isdigit( c ) ? c - '0' : c + 10 - 'a' )
#define islxdigit(x) (!isupper(x)&&isxdigit(x))
-static char *utompathcap( upath )
- char *upath;
+static char *utompathcap( char *upath)
{
char *m, *u;
int h;
char *m, *u;
u_int16_t flags = CONV_IGNORE | CONV_UNESCAPEHEX;
size_t outlen;
- static char mpath[MAXPATHLEN];
+ static char mpath[MAXPATHLEN +2]; /* for convert_charset dest_len parameter +2 */
m = mpath;
outlen = strlen(upath);
goto utompath_error;
}
- mpath[outlen] = 0;
if (flags & CONV_REQMANGLE)
goto utompath_error;
return(utompathcap( upath ));
}
-char *mtoupathiconv(char *mpath)
+static char *mtoupathiconv(char *mpath)
{
char *m, *u;
size_t inplen;
size_t outlen;
u_int16_t flags = 0;
- static char upath[MAXPATHLEN];
+ static char upath[MAXPATHLEN +2]; /* for convert_charset dest_len parameter +2 */
if ( *mpath == '\0' ) {
return( "." );
fprintf (stderr, "conversion from %s to %s for %s failed.", vol.v_maccodepage, vol.v_volcodepage, mpath);
return(mtoupathcap( upath ));
}
- upath[outlen] = 0;
return( upath );
}
int hexfork[ NUMFORKS ];
#endif /* HEXOUTPUT */
-struct nad_file_data {
+static struct nad_file_data {
char macname[ MAXPATHLEN + 1 ];
char adpath[ 2 ][ MAXPATHLEN + 1];
int offset[ NUMFORKS ];
}
-int nad_open( path, openflags, fh, options )
- char *path;
- int openflags, options;
- struct FHeader *fh;
+int nad_open( char *path, int openflags, struct FHeader *fh, int options)
{
struct stat st;
int fork;
initvol(path);
strcpy( nad.adpath[0], path );
strcpy( nad.adpath[1],
- nad.ad.ad_path( nad.adpath[0], ADFLAGS_DF|ADFLAGS_HF ));
+ nad.ad.ad_ops->ad_path( nad.adpath[0], ADFLAGS_HF ));
for ( fork = 0 ; fork < NUMFORKS ; fork++ ) {
if ( stat( nad.adpath[ fork ], &st ) < 0 ) {
if ( errno == ENOENT ) {
strcpy( nad.macname, fh->name );
strcpy( nad.adpath[0], mtoupath( nad.macname ));
strcpy( nad.adpath[1],
- nad.ad.ad_path( nad.adpath[0], ADFLAGS_DF|ADFLAGS_HF ));
+ nad.ad.ad_ops->ad_path( nad.adpath[0], ADFLAGS_HF ));
#if DEBUG
fprintf(stderr, "%s\n", nad.macname);
fprintf(stderr, "%s is adpath[0]\n", nad.adpath[0]);
}
}
-int nad_header_read( fh )
- struct FHeader *fh;
+int nad_header_read(struct FHeader *fh)
{
u_int32_t temptime;
struct stat st;
}
-int nad_header_write( fh )
- struct FHeader *fh;
+int nad_header_write(struct FHeader *fh)
{
u_int32_t temptime;
#endif /* HEXOUTPUT */
nad.offset[ DATA ] = nad.offset[ RESOURCE ] = 0;
- ad_flush( &nad.ad, ADFLAGS_DF|ADFLAGS_HF );
+ ad_flush( &nad.ad );
return( 0 );
}
-int forkeid[] = { ADEID_DFORK, ADEID_RFORK };
+static int forkeid[] = { ADEID_DFORK, ADEID_RFORK };
-int nad_read( fork, forkbuf, bufc )
- int fork;
- char *forkbuf;
- int bufc;
+ssize_t nad_read(int fork, char *forkbuf, size_t bufc)
{
- int cc = 0;
+ ssize_t cc = 0;
#if DEBUG
fprintf( stderr, "Entering nad_read\n" );
return( cc );
}
-int nad_write( fork, forkbuf, bufc )
- int fork;
- char *forkbuf;
- int bufc;
+ssize_t nad_write(int fork, char *forkbuf, size_t bufc)
{
char *buf_ptr;
- int writelen;
- int cc = 0;
+ size_t writelen;
+ ssize_t cc = 0;
#if DEBUG
fprintf( stderr, "Entering nad_write\n" );
return( bufc );
}
-int nad_close( status )
-int status;
+int nad_close(int status)
{
int rv;
if ( status == KEEP ) {
- if (( rv = ad_flush( &nad.ad, ADFLAGS_DF|ADFLAGS_HF )) < 0 ) {
+ if (( rv = ad_flush( &nad.ad )) < 0 ) {
fprintf( stderr, "nad_close rv for flush %d\n", rv );
return( rv );
}