diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2004-04-25 14:10:03 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2004-04-25 14:10:03 +0000 |
commit | 9717723fd7bdc64648c258967911d0932248cf1f (patch) | |
tree | b1a70d9713de3aab9a0344efb33604a0f40c08c0 /src | |
parent | 6caf64335ab07e1bd138e11a1823ba9baa209fef (diff) |
Better display of decoded LMP features
Diffstat (limited to 'src')
-rw-r--r-- | src/hci.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -409,8 +409,8 @@ static hci_map lmp_features_map[8][9] = { char *lmp_featurestostr(uint8_t *features, char *pref, int width) { - char *ptr, *str = malloc(400); - int i, w; + char *off, *ptr, *str = malloc(400); + int i; if (!str) return NULL; @@ -420,16 +420,19 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width) if (pref) ptr += sprintf(ptr, "%s", pref); - for (i = 0, w = 0; i < 8; i++) { + off = ptr; + + for (i = 0; i < 8; i++) { hci_map *m; m = lmp_features_map[i]; while (m->str) { if ((unsigned int) m->val & (unsigned int) features[i]) { - ptr += sprintf(ptr, "%s ", m->str); - w = (w + 1) & width; - if (!w) + if (strlen(off) + strlen(m->str) > width - 1) { ptr += sprintf(ptr, "\n%s", pref ? pref : ""); + off = ptr; + } + ptr += sprintf(ptr, "%s ", m->str); } m++; } |