78 lines
1.5 KiB
C
78 lines
1.5 KiB
C
#include "ncplib.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
void
|
|
main(int argc, char *argv[])
|
|
{
|
|
struct ncp_server server;
|
|
struct ncp_bindery_object obj;
|
|
int found = 0;
|
|
char default_pattern[2] = "*";
|
|
char *pattern = default_pattern;
|
|
char *p;
|
|
|
|
if (argc > 2) {
|
|
printf("usage: %s [pattern]\n", argv[0]);
|
|
exit(1);
|
|
}
|
|
|
|
if (argc == 2) {
|
|
pattern = argv[1];
|
|
}
|
|
|
|
for (p = pattern; *p != '\0'; p++) {
|
|
*p = toupper(*p);
|
|
}
|
|
|
|
memset(&server, 0, sizeof(server));
|
|
|
|
if (ncp_connect(&server, NULL) != 0) {
|
|
perror("ncp_connect");
|
|
exit(1);
|
|
}
|
|
|
|
if (isatty(1)) {
|
|
printf("\n%-52s%-10s%-12s\n"
|
|
"-----------------------------------------------"
|
|
"---------------------------\n",
|
|
"Known NetWare File Servers",
|
|
"Network",
|
|
"Node Address");
|
|
}
|
|
|
|
obj.object_id = 0xffffffff;
|
|
|
|
while (ncp_scan_bindery_object(&server, obj.object_id,
|
|
NCP_BINDERY_FSERVER, pattern,
|
|
&obj) == 0) {
|
|
|
|
struct nw_property prop;
|
|
struct prop_net_address *naddr
|
|
= (struct prop_net_address *)∝
|
|
|
|
found = 1;
|
|
|
|
printf("%-52s", obj.object_name);
|
|
|
|
if (ncp_read_property_value(&server, NCP_BINDERY_FSERVER,
|
|
obj.object_name, 1, "NET_ADDRESS",
|
|
&prop) == 0) {
|
|
ipx_print_network(naddr->network);
|
|
printf(" ");
|
|
ipx_print_node(naddr->node);
|
|
}
|
|
printf("\n");
|
|
}
|
|
|
|
if ((found == 0) && (isatty(1))) {
|
|
printf("No servers found\n");
|
|
}
|
|
|
|
ncp_disconnect(&server);
|
|
}
|
|
|