87 lines
2.1 KiB
C
87 lines
2.1 KiB
C
/* slist.c - list known NetWare file servers, DOS mars-dosutils version */
|
|
|
|
#include "net.h"
|
|
|
|
#define NCP_BINDERY_FSERVER 0x0004
|
|
|
|
static int usage(void)
|
|
{
|
|
fprintf(stdout, "Usage: SLIST [Server] [/Continue]\n");
|
|
return(0);
|
|
}
|
|
|
|
static int is_help_arg(char *s)
|
|
{
|
|
if (!s) return(0);
|
|
return(!strcmp(s, "/?") || !strcmp(s, "-?") || !strcmp(s, "?"));
|
|
}
|
|
|
|
static void print_net_node_status(uint8 *addr, int is_default)
|
|
{
|
|
fprintf(stdout, "[%08lX][%02X%02X%02X%02X%02X%02X]%s",
|
|
(unsigned long)GET_BE32(addr),
|
|
addr[4], addr[5], addr[6], addr[7], addr[8], addr[9],
|
|
is_default ? "Default" : "");
|
|
}
|
|
|
|
int func_slist(int argc, char *argv[], int mode)
|
|
{
|
|
BINDERY_OBJECT obj;
|
|
uint32 last_id = MAX_U32;
|
|
uint8 pattern[50];
|
|
int found = 0;
|
|
int result;
|
|
int i;
|
|
|
|
(void)mode;
|
|
|
|
strcpy(pattern, "*");
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
if (is_help_arg(argv[i])) return(usage());
|
|
|
|
if (argv[i][0] == '/' || argv[i][0] == '-') {
|
|
if (!stricmp(argv[i], "/C") || !stricmp(argv[i], "/CONTINUE") ||
|
|
!stricmp(argv[i], "-C") || !stricmp(argv[i], "-CONTINUE")) {
|
|
continue;
|
|
}
|
|
return(usage());
|
|
}
|
|
|
|
strmaxcpy(pattern, argv[i], sizeof(pattern) - 1);
|
|
}
|
|
|
|
upstr(pattern);
|
|
|
|
fprintf(stdout, "Known NetWare File Servers Network Node Address Status\n");
|
|
fprintf(stdout, "-------------------------------------------- -------- ----------------------\n");
|
|
|
|
while ((result = ncp_17_37(last_id, NCP_BINDERY_FSERVER,
|
|
pattern, &obj)) == 0) {
|
|
NW_PROPERTY prop;
|
|
|
|
found++;
|
|
last_id = obj.object_id;
|
|
|
|
fprintf(stdout, "%-44s", obj.object_name);
|
|
|
|
if (!ncp_17_3d(NCP_BINDERY_FSERVER, obj.object_name,
|
|
1, "NET_ADDRESS", &prop)) {
|
|
/*
|
|
* We only have one active connection in mars-dosutils, so mark the
|
|
* first/current server as Default. This matches the useful Novell
|
|
* output closely enough for scripts and humans.
|
|
*/
|
|
print_net_node_status(prop.value, found == 1);
|
|
}
|
|
|
|
fprintf(stdout, "\n");
|
|
|
|
if (last_id == MAX_U32) break;
|
|
}
|
|
|
|
fprintf(stdout, "\nTotal of %d file servers found\n", found);
|
|
|
|
return(0);
|
|
}
|