Deleted Added
full compact
util-print.c (313537) util-print.c (327234)
1/*
2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22/*
23 * txtproto_print() derived from original code by Hannes Gredler
1/*
2 * Copyright (c) 1990, 1991, 1993, 1994, 1995, 1996, 1997
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that: (1) source code distributions
7 * retain the above copyright notice and this paragraph in its entirety, (2)
8 * distributions including binary code include the above copyright notice and

--- 7 unchanged lines hidden (view full) ---

16 * written permission.
17 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20 */
21
22/*
23 * txtproto_print() derived from original code by Hannes Gredler
24 * (hannes@juniper.net):
24 * (hannes@gredler.at):
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that: (1) source code
28 * distributions retain the above copyright notice and this paragraph
29 * in its entirety, and (2) distributions including binary code include
30 * the above copyright notice and this paragraph in its entirety in
31 * the documentation or other materials provided with the distribution.
32 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND

--- 483 unchanged lines hidden (view full) ---

516 * Convert a bit token value to a string; use "fmt" if not found.
517 * this is useful for parsing bitfields, the output strings are seperated
518 * if the s field is positive.
519 */
520static char *
521bittok2str_internal(register const struct tok *lp, register const char *fmt,
522 register u_int v, const char *sep)
523{
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that: (1) source code
28 * distributions retain the above copyright notice and this paragraph
29 * in its entirety, and (2) distributions including binary code include
30 * the above copyright notice and this paragraph in its entirety in
31 * the documentation or other materials provided with the distribution.
32 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND

--- 483 unchanged lines hidden (view full) ---

516 * Convert a bit token value to a string; use "fmt" if not found.
517 * this is useful for parsing bitfields, the output strings are seperated
518 * if the s field is positive.
519 */
520static char *
521bittok2str_internal(register const struct tok *lp, register const char *fmt,
522 register u_int v, const char *sep)
523{
524 static char buf[256]; /* our stringbuffer */
525 int buflen=0;
524 static char buf[1024+1]; /* our string buffer */
525 char *bufp = buf;
526 size_t space_left = sizeof(buf), string_size;
526 register u_int rotbit; /* this is the bit we rotate through all bitpositions */
527 register u_int tokval;
528 const char * sepstr = "";
529
530 while (lp != NULL && lp->s != NULL) {
531 tokval=lp->v; /* load our first value */
532 rotbit=1;
533 while (rotbit != 0) {
534 /*
535 * lets AND the rotating bit with our token value
536 * and see if we have got a match
537 */
538 if (tokval == (v&rotbit)) {
539 /* ok we have found something */
527 register u_int rotbit; /* this is the bit we rotate through all bitpositions */
528 register u_int tokval;
529 const char * sepstr = "";
530
531 while (lp != NULL && lp->s != NULL) {
532 tokval=lp->v; /* load our first value */
533 rotbit=1;
534 while (rotbit != 0) {
535 /*
536 * lets AND the rotating bit with our token value
537 * and see if we have got a match
538 */
539 if (tokval == (v&rotbit)) {
540 /* ok we have found something */
540 buflen+=snprintf(buf+buflen, sizeof(buf)-buflen, "%s%s",
541 sepstr, lp->s);
541 if (space_left <= 1)
542 return (buf); /* only enough room left for NUL, if that */
543 string_size = strlcpy(bufp, sepstr, space_left);
544 if (string_size >= space_left)
545 return (buf); /* we ran out of room */
546 bufp += string_size;
547 space_left -= string_size;
548 if (space_left <= 1)
549 return (buf); /* only enough room left for NUL, if that */
550 string_size = strlcpy(bufp, lp->s, space_left);
551 if (string_size >= space_left)
552 return (buf); /* we ran out of room */
553 bufp += string_size;
554 space_left -= string_size;
542 sepstr = sep;
543 break;
544 }
545 rotbit=rotbit<<1; /* no match - lets shift and try again */
546 }
547 lp++;
548 }
549
555 sepstr = sep;
556 break;
557 }
558 rotbit=rotbit<<1; /* no match - lets shift and try again */
559 }
560 lp++;
561 }
562
550 if (buflen == 0)
563 if (bufp == buf)
551 /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
552 (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
553 return (buf);
554}
555
556/*
557 * Convert a bit token value to a string; use "fmt" if not found.
558 * this is useful for parsing bitfields, the output strings are not seperated.

--- 338 unchanged lines hidden (view full) ---

897}
898
899void
900safeputs(netdissect_options *ndo,
901 const u_char *s, const u_int maxlen)
902{
903 u_int idx = 0;
904
564 /* bummer - lets print the "unknown" message as advised in the fmt string if we got one */
565 (void)snprintf(buf, sizeof(buf), fmt == NULL ? "#%08x" : fmt, v);
566 return (buf);
567}
568
569/*
570 * Convert a bit token value to a string; use "fmt" if not found.
571 * this is useful for parsing bitfields, the output strings are not seperated.

--- 338 unchanged lines hidden (view full) ---

910}
911
912void
913safeputs(netdissect_options *ndo,
914 const u_char *s, const u_int maxlen)
915{
916 u_int idx = 0;
917
905 while (*s && idx < maxlen) {
918 while (idx < maxlen && *s) {
906 safeputchar(ndo, *s);
907 idx++;
908 s++;
909 }
910}
911
912void
913safeputchar(netdissect_options *ndo,

--- 25 unchanged lines hidden ---
919 safeputchar(ndo, *s);
920 idx++;
921 s++;
922 }
923}
924
925void
926safeputchar(netdissect_options *ndo,

--- 25 unchanged lines hidden ---