/* * check for all uncompleted fields */ int ncp_li_check(struct ncp_conn_loginfo *li) { int error = 0; char *p; do { if (li->server[0] == 0) { ncp_error("no server name specified", 0); error = 1; break; } error = ncp_find_fileserver(li, (server_name==NULL) ? AF_IPX : AF_INET, server_name); if (error) { ncp_error("can't find server %s", error, li->server); break; } if (li->user == NULL || li->user[0] == 0) { ncp_error("no user name specified for server %s", 0, li->server); error = 1; break; } if (li->password == NULL) { p = getpass("Netware password:"); error = ncp_li_setpassword(li, p) ? 1 : 0; } } while (0); return error; }
static int ncp_get_connid(char *server, int justattach) { int connid, error; struct ncp_conn_loginfo li; connid = ncp_conn_find(server, NULL); if (connid > 0) { ncp_conn_getinfo(connid, &conndesc); return connid; } if (!justattach) { if (connid == -1) { printf("You are not attached to server %s\n",server); return -1; } printf("You are not attached to any server\n"); return -1; } ncp_li_init(&li, 0, NULL); if (server) { ncp_li_setserver(&li, server); error = ncp_find_fileserver(&li, AF_IPX, NULL); if (error) { printf("Could not find server %s\n", li.server); return -1; } } else { error = ncp_find_fileserver(&li, AF_IPX, NULL); if (error) { printf("Can't find any file server\n"); return -1; } } error = ncp_connect(&li, &connid); if (error) { printf("Can't attach to a nearest server\n"); return -1; } ncp_conn_getinfo(connid, &conndesc); return connid; }