mirror of
https://github.com/sheumann/AFPBridge.git
synced 2024-06-01 21:41:29 +00:00
Start writing AFP mounter program/test case.
Currently this just does an NBP lookup.
This commit is contained in:
parent
6367b37e6f
commit
f9a65d1f54
25
Makefile.mk
25
Makefile.mk
|
@ -1,11 +1,26 @@
|
||||||
CFLAGS = -i -w
|
CFLAGS = -i -w
|
||||||
|
|
||||||
OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o
|
DSITEST_OBJS = dsitest.o aspinterface.o dsi.o readtcp.o endian.o tcpconnection.o atipmapping.o
|
||||||
PROG = dsitest
|
DSITEST_PROG = dsitest
|
||||||
|
|
||||||
$(PROG): $(OBJS)
|
AFPMOUNTER_OBJS = afpmounter.o callat.o endian.o
|
||||||
occ $(CFLAGS) -o $@ $(OBJS)
|
AFPMOUNTER_PROG = afpmounter
|
||||||
|
|
||||||
|
.PHONY: default
|
||||||
|
default: $(DSITEST_PROG) $(AFPMOUNTER_PROG)
|
||||||
|
|
||||||
|
$(DSITEST_PROG): $(DSITEST_OBJS)
|
||||||
|
occ $(CFLAGS) -o $@ $(DSITEST_OBJS)
|
||||||
|
|
||||||
|
$(AFPMOUNTER_PROG): $(AFPMOUNTER_OBJS)
|
||||||
|
occ $(CFLAGS) -o $@ $(AFPMOUNTER_OBJS)
|
||||||
|
|
||||||
|
endian.o: endian.asm
|
||||||
|
occ $(CFLAGS) -c $<
|
||||||
|
|
||||||
|
callat.o: callat.asm
|
||||||
|
occ $(CFLAGS) -c $<
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(RM) $(OBJS) $(PROG)
|
$(RM) $(DSITEST_OBJS) $(DSITEST_PROG) $(AFPMOUNTER_PROG) $(AFPMOUNTER_OBJS) > .null
|
||||||
|
|
82
afpmounter.c
Normal file
82
afpmounter.c
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <appletalk.h>
|
||||||
|
#include "endian.h"
|
||||||
|
|
||||||
|
#define ENTITY_FIELD_MAX 32
|
||||||
|
|
||||||
|
typedef struct NBPLookupResultBuf {
|
||||||
|
Word networkNum;
|
||||||
|
Byte nodeNum;
|
||||||
|
Byte socketNum;
|
||||||
|
// First enumerator/name only
|
||||||
|
Byte enumerator;
|
||||||
|
EntName entName;
|
||||||
|
} NBPLookupResultBuf;
|
||||||
|
|
||||||
|
NBPLookupResultBuf lookupResultBuf;
|
||||||
|
NBPLookupNameRec lookupNameRec;
|
||||||
|
EntName entName;
|
||||||
|
|
||||||
|
char *object, *zone, *type;
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
int i, j;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "Usage: afpmounter name zone\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
object = argv[1];
|
||||||
|
type = "AFPServer";
|
||||||
|
zone = argv[2];
|
||||||
|
if (strlen(object) > ENTITY_FIELD_MAX || strlen(zone) > ENTITY_FIELD_MAX) {
|
||||||
|
fprintf(stderr, "Entity name too long (max 32 chars)\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lookupNameRec.async = 0;
|
||||||
|
lookupNameRec.command = nbpLookupNameCommand;
|
||||||
|
lookupNameRec.completionPtr = 0;
|
||||||
|
lookupNameRec.entityPtr = (LongWord)&entName;
|
||||||
|
lookupNameRec.rInterval = 1;
|
||||||
|
lookupNameRec.rCount = 20;
|
||||||
|
lookupNameRec.reserved = 0;
|
||||||
|
lookupNameRec.bufferLength = sizeof(lookupResultBuf);
|
||||||
|
lookupNameRec.bufferPtr = (LongWord)&lookupResultBuf;
|
||||||
|
lookupNameRec.maxMatch = 1;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
count = strlen(object);
|
||||||
|
entName.buffer[i++] = count;
|
||||||
|
for (j = 0; j < count; j++) {
|
||||||
|
entName.buffer[i++] = object[j];
|
||||||
|
}
|
||||||
|
count = strlen(type);
|
||||||
|
entName.buffer[i++] = count;
|
||||||
|
for (j = 0; j < count; j++) {
|
||||||
|
entName.buffer[i++] = type[j];
|
||||||
|
}
|
||||||
|
count = strlen(zone);
|
||||||
|
entName.buffer[i++] = count;
|
||||||
|
for (j = 0; j < count; j++) {
|
||||||
|
entName.buffer[i++] = zone[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_CALLAT(&lookupNameRec)) {
|
||||||
|
fprintf(stderr, "NBP lookup error: %04x\n", lookupNameRec.result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%i matches\n", lookupNameRec.actualMatch);
|
||||||
|
if (lookupNameRec.actualMatch > 0) {
|
||||||
|
printf("network = %u, node = %u, socket = %u\n",
|
||||||
|
ntohs(lookupResultBuf.networkNum),
|
||||||
|
lookupResultBuf.nodeNum,
|
||||||
|
lookupResultBuf.socketNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user