svn commit: samba r11553 - in branches/SAMBA_4_0/source/utils: .

metze at samba.org metze at samba.org
Mon Nov 7 15:07:41 GMT 2005


Author: metze
Date: 2005-11-07 15:07:41 +0000 (Mon, 07 Nov 2005)
New Revision: 11553

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11553

Log:
give an error when the lookup failed

metze
Modified:
   branches/SAMBA_4_0/source/utils/nmblookup.c


Changeset:
Modified: branches/SAMBA_4_0/source/utils/nmblookup.c
===================================================================
--- branches/SAMBA_4_0/source/utils/nmblookup.c	2005-11-07 14:34:49 UTC (rev 11552)
+++ branches/SAMBA_4_0/source/utils/nmblookup.c	2005-11-07 15:07:41 UTC (rev 11553)
@@ -100,7 +100,7 @@
 }
 
 /* do a single node status */
-static void do_node_status(struct nbt_name_socket *nbtsock,
+static BOOL do_node_status(struct nbt_name_socket *nbtsock,
 			   const char *addr)
 {
 	struct nbt_name_status io;
@@ -131,7 +131,10 @@
 		       io.out.status.statistics.unit_id[3],
 		       io.out.status.statistics.unit_id[4],
 		       io.out.status.statistics.unit_id[5]);
+		return True;
 	}
+
+	return False;
 }
 
 /* do a single node query */
@@ -171,13 +174,14 @@
 }
 
 
-static void process_one(const char *name)
+static BOOL process_one(const char *name)
 {
 	TALLOC_CTX *tmp_ctx = talloc_new(NULL);
 	enum nbt_name_type node_type = NBT_NAME_CLIENT;
 	char *node_name, *p;
 	struct nbt_name_socket *nbtsock;
 	NTSTATUS status = NT_STATUS_OK;
+	BOOL ret = True;
 
 	if (!options.case_sensitive) {
 		name = strupper_talloc(tmp_ctx, name);
@@ -205,14 +209,15 @@
 		status = socket_listen(nbtsock->sock, "0.0.0.0", NBT_NAME_SERVICE_PORT, 0, 0);
 		if (!NT_STATUS_IS_OK(status)) {
 			printf("Failed to bind to local port 137 - %s\n", nt_errstr(status));
-			return;
+			talloc_free(tmp_ctx);
+			return False;
 		}
 	}
 
 	if (options.lookup_by_ip) {
-		do_node_status(nbtsock, name);
+		ret = do_node_status(nbtsock, name);
 		talloc_free(tmp_ctx);
-		return;
+		return ret;
 	}
 
 	if (options.broadcast_address) {
@@ -230,16 +235,19 @@
 
 	if (!NT_STATUS_IS_OK(status)) {
 		printf("Lookup failed - %s\n", nt_errstr(status));
+		ret = False;
 	}
 
 	talloc_free(tmp_ctx);
- }
+	return ret;
+}
 
 /*
   main program
 */
 int main(int argc,char *argv[])
 {
+	BOOL ret = True;
 	poptContext pc;
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -288,10 +296,14 @@
 	while (poptPeekArg(pc)) {
 		const char *name = poptGetArg(pc);
 
-		process_one(name);
+		ret &= process_one(name);
 	}
 
 	poptFreeContext(pc);
 
+	if (!ret) {
+		return 1;
+	}
+
 	return 0;
 }



More information about the samba-cvs mailing list