BSD-style license that accompanies tcpdump or the GNU GPL version 2
or later */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifndef lint
+static const char rcsid[] =
+ "@(#) $Header: /tcpdump/master/tcpdump/smbutil.c,v 1.6 2000-01-17 06:24:27 itojun Exp $";
+#endif
+
#include <sys/param.h>
#include <sys/time.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
+#include "interface.h"
#include "smb.h"
extern uchar *startbuf;
/*******************************************************************
create a unix date from a dos date
********************************************************************/
-time_t make_unix_date(void *date_ptr)
+static time_t make_unix_date(const void *date_ptr)
{
uint32 dos_date=0;
struct tm t;
/*******************************************************************
create a unix date from a dos date
********************************************************************/
-time_t make_unix_date2(void *date_ptr)
+static time_t make_unix_date2(const void *date_ptr)
{
uint32 x,x2;
interpret an 8 byte "filetime" structure to a time_t
It's originally in "100ns units since jan 1st 1601"
****************************************************************************/
-time_t interpret_long_date(char *p)
+static time_t interpret_long_date(const char *p)
{
double d;
time_t ret;
static int name_extract(char *buf,int ofs,char *name)
{
char *p = name_ptr(buf,ofs);
- int d = PTR_DIFF(p,buf+ofs);
strcpy(name,"");
return(name_interpret(p,name));
}
/****************************************************************************
return the total storage length of a mangled name
****************************************************************************/
-static int name_len(unsigned char *s)
+static int name_len(const unsigned char *s)
{
- char *s0 = s;
+ const char *s0 = s;
unsigned char c = *(unsigned char *)s;
if ((c & 0xC0) == 0xC0)
return(2);
return(PTR_DIFF(s,s0)+1);
}
-void print_asc(unsigned char *buf,int len)
+static void print_asc(const unsigned char *buf,int len)
{
int i;
for (i=0;i<len;i++)
return(f);
}
-void print_data(unsigned char *buf,int len)
+void print_data(const unsigned char *buf, int len)
{
int i=0;
if (len<=0) return;
}
/* convert a unicode string */
-static char *unistr(char *s, int *len)
+static const char *unistr(const char *s, int *len)
{
static char buf[1000];
int l=0;
return buf;
}
-uchar *fdata1(uchar *buf,char *fmt,uchar *maxbuf)
+static const uchar *fdata1(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
int reverse=0;
char *attrib_fmt = "READONLY|HIDDEN|SYSTEM|VOLUME|DIR|ARCHIVE|";
}
case 'S':
{
- printf("%.*s",PTR_DIFF(maxbuf,buf),unistr(buf, &len));
+ printf("%.*s",(int)PTR_DIFF(maxbuf,buf),unistr(buf, &len));
buf += len;
fmt++;
break;
{
if (*buf != 4 && *buf != 2)
printf("Error! ASCIIZ buffer of type %d (safety=%d)\n",
- *buf,PTR_DIFF(maxbuf,buf));
- printf("%.*s",PTR_DIFF(maxbuf,buf+1),unistr(buf+1, &len));
+ *buf,(int)PTR_DIFF(maxbuf,buf));
+ printf("%.*s",(int)PTR_DIFF(maxbuf,buf+1),unistr(buf+1, &len));
buf += len+1;
fmt++;
break;
return(buf);
}
-uchar *fdata(uchar *buf,char *fmt,uchar *maxbuf)
+const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf)
{
static int depth=0;
char s[128];
case '*':
fmt++;
while (buf < maxbuf) {
- uchar *buf2;
+ const uchar *buf2;
depth++;
buf2 = fdata(buf,fmt,maxbuf);
depth--;
for (j=0;err[j].name;j++)
if (num == err[j].code)
{
- sprintf(ret,"%s - %s (%s)",err_classes[i].class,
+ snprintf(ret,sizeof(ret),"%s - %s (%s)",err_classes[i].class,
err[j].name,err[j].message);
return ret;
}
}
- sprintf(ret,"%s - %d",err_classes[i].class,num);
+ snprintf(ret,sizeof(ret),"%s - %d",err_classes[i].class,num);
return ret;
}
- sprintf(ret,"ERROR: Unknown error (%d,%d)",class,num);
+ snprintf(ret,sizeof(ret),"ERROR: Unknown error (%d,%d)",class,num);
return(ret);
}