Implement infrastructure (in init and CDev) to support options encoded in the zone name.
This commit is contained in:
parent
df9a9f8821
commit
695f2d8611
|
@ -4,7 +4,7 @@ COMMAND = $(!eq,$(CMNDNAME),$(CC) $(CMNDNAME) $(USEORCALIBS)&&$(CC)) $(CMNDARGS)
|
|||
|
||||
CFLAGS = -i -w -O95
|
||||
|
||||
DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o cmdproc.o installcmds.o
|
||||
DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o cmdproc.o installcmds.o afpoptions.o strncasecmp.o
|
||||
DSITEST_PROG = dsitest
|
||||
|
||||
MOUNTAFP_OBJS = afpmounter.o callat.o endian.o
|
||||
|
@ -13,10 +13,10 @@ MOUNTAFP_PROG = mountafp
|
|||
DUMPCMDTBL_OBJS = dumpcmdtbl.o asmglue.o
|
||||
DUMPCMDTBL_PROG = dumpcmdtbl
|
||||
|
||||
AFPBRIDGE_OBJS = afpinit.o afpbridge.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o installcmds.o cmdproc.o callat.o
|
||||
AFPBRIDGE_OBJS = afpinit.o afpbridge.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o asmglue.o installcmds.o cmdproc.o callat.o afpoptions.o strncasecmp.o
|
||||
AFPBRIDGE_PROG = AFPBridge
|
||||
|
||||
AFPMOUNTER_OBJS = cdevstart.o afpcdev.o afpurlparser.o
|
||||
AFPMOUNTER_OBJS = cdevstart.o afpcdev.o afpurlparser.o afpoptions.o strncasecmp.o
|
||||
AFPMOUNTER_RSRC = afpcdev.rez
|
||||
AFPMOUNTER_CDEV = AFPMounter
|
||||
|
||||
|
|
18
afpcdev.c
18
afpcdev.c
|
@ -19,7 +19,9 @@
|
|||
#include <desk.h>
|
||||
#include <menu.h>
|
||||
#include <finder.h>
|
||||
#include "afpoptions.h"
|
||||
#include "afpurlparser.h"
|
||||
#include "strncasecmp.h"
|
||||
#include "cdevutil.h"
|
||||
|
||||
#define MachineCDEV 1
|
||||
|
@ -75,8 +77,6 @@ typedef struct EasyMountRec {
|
|||
|
||||
EasyMountRec easyMountRec;
|
||||
|
||||
char afpOverTCPZone[] = "AFP over TCP";
|
||||
|
||||
typedef struct GSString1024 {
|
||||
Word length;
|
||||
char text[1024];
|
||||
|
@ -105,10 +105,7 @@ SFReplyRec2 sfReplyRec;
|
|||
|
||||
Word modifiers = 0;
|
||||
|
||||
#define fLargeReads 0x0001
|
||||
#define fForceAFP22 0x0002
|
||||
|
||||
Word flags = fLargeReads; /* for AFP over TCP connections */
|
||||
unsigned int flags = fLargeReads; /* for AFP over TCP connections */
|
||||
|
||||
void fillEasyMountRec(char *server, char *zone, char *volume, char *user,
|
||||
char *password, char *volpass)
|
||||
|
@ -233,6 +230,8 @@ int writeAlias(GSString255Ptr file)
|
|||
|
||||
void finalizeURLParts(AFPURLParts *urlParts)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
if (urlParts->server == NULL)
|
||||
urlParts->server = "";
|
||||
if (urlParts->zone == NULL)
|
||||
|
@ -262,7 +261,12 @@ void finalizeURLParts(AFPURLParts *urlParts)
|
|||
}
|
||||
|
||||
if (urlParts->protocol == proto_TCP) {
|
||||
urlParts->zone = afpOverTCPZone;
|
||||
urlParts->zone = afpOptions[0].zoneString;
|
||||
for (i = 0; afpOptions[i].zoneString != NULL; i++) {
|
||||
if (afpOptions[i].flags == flags) {
|
||||
urlParts->zone = afpOptions[i].zoneString;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#pragma noroot
|
||||
|
||||
#include "afpoptions.h"
|
||||
|
||||
AFPOptions afpOptions[] =
|
||||
{
|
||||
/*12345678901234567890123456789012 <- max length = 32 */
|
||||
{"AFP over TCP", 0},
|
||||
{"AFP over TCP (LargeReads)", fLargeReads},
|
||||
{"AFP over TCP (AFP2.2)", fForceAFP22},
|
||||
{"AFP over TCP (LargeReads,AFP2.2)", fLargeReads | fForceAFP22},
|
||||
{0, 0}
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
#ifndef AFPOPTIONS_H
|
||||
#define AFPOPTIONS_H
|
||||
|
||||
#define fLargeReads 0x0001
|
||||
#define fForceAFP22 0x0002
|
||||
|
||||
typedef struct AFPOptions {
|
||||
char *zoneString;
|
||||
unsigned int flags;
|
||||
} AFPOptions;
|
||||
|
||||
extern AFPOptions afpOptions[];
|
||||
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include "afpurlparser.h"
|
||||
|
||||
#include "strncasecmp.h"
|
||||
|
||||
#ifdef AFPURLPARSER_TEST
|
||||
# include <stdio.h>
|
||||
|
@ -11,17 +11,6 @@
|
|||
# endif
|
||||
#endif
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
while (tolower(*s1) == tolower(*s2) && *s1 != 0 && n > 1) {
|
||||
s1++;
|
||||
s2++;
|
||||
n--;
|
||||
}
|
||||
|
||||
return (int)*s1 - (int)*s2;
|
||||
}
|
||||
|
||||
static int hextonum(char c) {
|
||||
if (c >= '0' && c <= '9')
|
||||
return c - '0';
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
#include "aspinterface.h"
|
||||
#include "installcmds.h"
|
||||
#include "cmdproc.h"
|
||||
#include "afpoptions.h"
|
||||
#include "strncasecmp.h"
|
||||
|
||||
struct ATIPMapping atipMapping;
|
||||
|
||||
#define DEFAULT_DSI_PORT 548
|
||||
|
||||
static char ATIPTypeName[] = "\pAFPServer";
|
||||
static char ATIPZoneName[] = "\pAFP over TCP";
|
||||
static char DefaultZoneName[] = "\p*";
|
||||
|
||||
// Next numbers to use for new mappings
|
||||
static int nextNode = 1;
|
||||
|
@ -39,15 +41,16 @@ LongWord DoLookupName(NBPLookupNameRec *commandRec) {
|
|||
NBPLUNameBufferRec *resultBuf;
|
||||
LongWord initialTime;
|
||||
Word stateReg;
|
||||
unsigned int flags;
|
||||
|
||||
stateReg = ForceRomIn();
|
||||
|
||||
// Length needed for result, assuming the request is for our type/zone
|
||||
count = offsetof(NBPLUNameBufferRec, entityName)
|
||||
+ ((EntName*)commandRec->entityPtr)->buffer[0]
|
||||
+ ATIPTypeName[0] + ATIPZoneName[0];
|
||||
+ ((EntName*)commandRec->entityPtr)->buffer[0] + 1
|
||||
+ ATIPTypeName[0] + 1 + DefaultZoneName[0] + 1;
|
||||
if (count > commandRec->bufferLength)
|
||||
return_error(nbpBufferErr);
|
||||
goto passThrough;
|
||||
|
||||
resultBuf = (NBPLUNameBufferRec *)commandRec->bufferPtr;
|
||||
|
||||
|
@ -69,10 +72,19 @@ LongWord DoLookupName(NBPLookupNameRec *commandRec) {
|
|||
*dest++ = ATIPTypeName[count];
|
||||
}
|
||||
nameLen = *curr;
|
||||
flags = 0xFFFF;
|
||||
for (count = 0; afpOptions[count].zoneString != NULL; count++) {
|
||||
if (strncasecmp(afpOptions[count].zoneString, curr+1, nameLen) == 0) {
|
||||
flags = afpOptions[count].flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flags == 0xFFFF)
|
||||
goto passThrough;
|
||||
|
||||
nameLen = *DefaultZoneName;
|
||||
for (count = 0; count <= nameLen; count++) {
|
||||
if (toupper(*curr++) != toupper(ATIPZoneName[count]))
|
||||
goto passThrough;
|
||||
*dest++ = ATIPTypeName[count];
|
||||
*dest++ = DefaultZoneName[count];
|
||||
}
|
||||
|
||||
if (TCPIPValidateIPString(&resultBuf->entityName.buffer[0])) {
|
||||
|
@ -138,6 +150,7 @@ LongWord DoLookupName(NBPLookupNameRec *commandRec) {
|
|||
nextSocket = 1;
|
||||
|
||||
haveMapping:
|
||||
atipMapping.flags = flags;
|
||||
resultBuf->netNum = atipMapping.networkNumber;
|
||||
resultBuf->nodeNum = atipMapping.node;
|
||||
resultBuf->socketNum = atipMapping.socket;
|
||||
|
|
|
@ -13,6 +13,9 @@ typedef struct ATIPMapping {
|
|||
/* IP address/port */
|
||||
LongWord ipAddr;
|
||||
Word port;
|
||||
|
||||
/* Flags for AFP over TCP (defined in afpoptions.h) */
|
||||
unsigned int flags;
|
||||
} ATIPMapping;
|
||||
|
||||
extern struct ATIPMapping atipMapping;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
# ifdef __ORCAC__
|
||||
# pragma noroot
|
||||
# endif
|
||||
|
||||
#include <stddef.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
if (n == 0)
|
||||
return 0;
|
||||
|
||||
while (n > 1 && *s1 != 0 && tolower(*s1) == tolower(*s2)) {
|
||||
s1++;
|
||||
s2++;
|
||||
n--;
|
||||
}
|
||||
|
||||
return (int)*s1 - (int)*s2;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef STRNCASECMP_H
|
||||
#define STRNCASECMP_H
|
||||
|
||||
int strncasecmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue