nmblookup.c PATCH: usage() update from my previous post

Derrell.Lipman at UnwiredUniverse.com Derrell.Lipman at UnwiredUniverse.com
Fri May 10 11:36:02 GMT 2002


Here's a patch for my nmblookup changes, that provides complete usage()
information (including the Name Resolution types).  Apparently these nmblookup
changes from previously have not yet been incorporated in cvs, as this is cvs
diff output after doing a cvs update today.

Derrell


Index: nmblookup.c
===================================================================
RCS file: /cvsroot/samba/source/utils/nmblookup.c,v
retrieving revision 1.50
diff -r1.50 nmblookup.c
36a37,38
> static BOOL line_field_output = False;
> 
74a77,103
>   d_printf("\n");
>   d_printf("\t-x                    Generate script-parsable output format.\n\n");
>   d_printf("\t                        Each relevant line begins a '+'.\n");
>   d_printf("\t                        The next character indicates a Node\n");
>   d_printf("\t                        (N) or an IP Address (I) message.\n");
>   d_printf("\t                        The next two characters are hex\n");
>   d_printf("\t                        digits representing the node type.\n\n");
>   d_printf("\t                        Node lines then have 9 characters\n");
>   d_printf("\t                        indicating status flags.  If the \n");
>   d_printf("\t                        flag is enabled, the letter is\n");
>   d_printf("\t                        displayed; otherwise, a dot (.) is\n");
>   d_printf("\t                        shown.  Status flags are:\n\n");
>   d_printf("\t                          g: Group\n");
>   d_printf("\t                          h: Name Resolution type: Hybrid\n");
>   d_printf("\t                          m: Name Resolution type: Mixed\n");
>   d_printf("\t                          p: Name Resolution type: Point-to-Point\n");
>   d_printf("\t                          b: Name Resolution type: Broadcast\n");
>   d_printf("\t                          d: Deregistering\n");
>   d_printf("\t                          c: Conflict\n");
>   d_printf("\t                          a: Active\n");
>   d_printf("\t                          r: peRmanent\n\n");
>   d_printf("\t                        A tab then separates the status\n");
>   d_printf("\t                        flags from the node name.\n\n");
>   d_printf("\t                        IP Address lines have the name\n");
>   d_printf("\t                        immediately following the type\n");
>   d_printf("\t                        digits.  A tab character separates\n");
>   d_printf("\t                        the name from the IP Address.\n\n");
86c115
< 	fstrcpy(ret,"");
---
>         fstrcpy(ret,"");
88,96c117,137
< 	fstrcat(ret, (flags & 0x80) ? "<GROUP> " : "        ");
< 	if ((flags & 0x60) == 0x00) fstrcat(ret,"B ");
< 	if ((flags & 0x60) == 0x20) fstrcat(ret,"P ");
< 	if ((flags & 0x60) == 0x40) fstrcat(ret,"M ");
< 	if ((flags & 0x60) == 0x60) fstrcat(ret,"H ");
< 	if (flags & 0x10) fstrcat(ret,"<DEREGISTERING> ");
< 	if (flags & 0x08) fstrcat(ret,"<CONFLICT> ");
< 	if (flags & 0x04) fstrcat(ret,"<ACTIVE> ");
< 	if (flags & 0x02) fstrcat(ret,"<PERMANENT> ");
---
>         if (line_field_output) {
>                 fstrcat(ret,(flags & 0x80) ? "g" : ".");
>                 fstrcat(ret,((flags & 0x60) == 0x60) ? "h" : ".");
>                 fstrcat(ret,((flags & 0x60) == 0x40) ? "m" : ".");
>                 fstrcat(ret,((flags & 0x60) == 0x20) ? "p" : ".");
>                 fstrcat(ret,((flags & 0x60) == 0x00) ? "b" : ".");
>                 fstrcat(ret,(flags & 0x10) ? "d" : ".");
>                 fstrcat(ret,(flags & 0x08) ? "c" : ".");
>                 fstrcat(ret,(flags & 0x04) ? "a" : ".");
>                 fstrcat(ret,(flags & 0x02) ? "r" : ".");
>         } else {
>                 fstrcat(ret, (flags & 0x80) ? "<GROUP> " : "        ");
>                 if ((flags & 0x60) == 0x00) fstrcat(ret,"B ");
>                 if ((flags & 0x60) == 0x20) fstrcat(ret,"P ");
>                 if ((flags & 0x60) == 0x40) fstrcat(ret,"M ");
>                 if ((flags & 0x60) == 0x60) fstrcat(ret,"H ");
>                 if (flags & 0x10) fstrcat(ret,"<DEREGISTERING> ");
>                 if (flags & 0x08) fstrcat(ret,"<CONFLICT> ");
>                 if (flags & 0x04) fstrcat(ret,"<ACTIVE> ");
>                 if (flags & 0x02) fstrcat(ret,"<PERMANENT> ");
>         }
111c152,153
< 	d_printf("Looking up status of %s\n",inet_ntoa(ip));
---
>         if (! line_field_output)
>                 d_printf("Looking up status of %s\n",inet_ntoa(ip));
120,122c162,170
< 			d_printf("\t%-15s <%02x> - %s\n",
< 			       cleanname,status[i].type,
< 			       node_status_flags(status[i].flags));
---
>                         if (line_field_output)
>                                 d_printf("+N%02X%s\t%s\n",
>                                          status[i].type,
>                                          node_status_flags(status[i].flags),
>                                          cleanname);
>                         else
>                                 d_printf("\t%-15s <%02x> - %s\n",
>                                          cleanname,status[i].type,
>                                          node_status_flags(status[i].flags));
126c174,175
< 	d_printf("\n");
---
>         if (! line_field_output)
>                 d_printf("\n");
139c188,189
< 		d_printf("querying %s on %s\n", lookup, inet_ntoa(bcast_addr));
---
>                 if (! line_field_output)
>                         d_printf("querying %s on %s\n", lookup, inet_ntoa(bcast_addr));
149,150c199,201
< 			d_printf("querying %s on %s\n", 
< 			       lookup, inet_ntoa(*bcast));
---
>                         if (! line_field_output)
>         			d_printf("querying %s on %s\n", 
>                                          lookup, inet_ntoa(*bcast));
160a212,213
>                 if (line_field_output)
>                         d_printf("+I%02X%s\t", lookup_type, lookup);
164c217,220
< 				d_printf("%s, ", host -> h_name);
---
>                                 if (line_field_output)
>                                         d_printf("%s", host -> h_name);
>                                 else
>                                         d_printf("%s, ", host -> h_name);
165a222,223
>                         if (line_field_output)
>                                 d_printf(":");
167c225,228
< 		d_printf("%s %s<%02x>\n",inet_ntoa(ip_list[j]),lookup, lookup_type);
---
>                 if (line_field_output)
>                         d_printf("%s\n", inet_ntoa(ip_list[j]));
>                 else
>                         d_printf("%s %s<%02x>\n",inet_ntoa(ip_list[j]),lookup, lookup_type);
206c267
<   while ((opt = getopt(argc, argv, "d:B:U:i:s:SMrhART")) != EOF)
---
>   while ((opt = getopt(argc, argv, "d:B:U:i:s:SMrhARTx")) != EOF)
253a315,317
>       case 'x':
>         line_field_output = True;
>         break;
310c374,376
< 	d_printf( "name_query failed to find name %s", lookup );
---
>         if (line_field_output)
>           d_printf("+E\t");
> 	d_printf( "name_query failed to find name %s ", lookup );




More information about the samba-technical mailing list