| 281 | |
| 282 | |
| 283 | static int printportlist(char *buf, int bufsize, struct portlist* pl, char * delim){ |
| 284 | int printed = 0; |
| 285 | |
| 286 | for(; pl; pl = pl->next){ |
| 287 | if(printed > (bufsize - 64)) break; |
| 288 | if(pl->startport != pl->endport) |
| 289 | printed += sprintf(buf+printed, "%hu-%hu%s", pl->startport, pl->endport, pl->next?delim:""); |
| 290 | else { |
| 291 | /* |
| 292 | struct servent *se=NULL; |
| 293 | if(pl->startport)se = getservbyport((int)ntohs(pl->startport), NULL); |
| 294 | printed += sprintf(buf+printed, "%hu(%s)%s", pl->startport, se?se->s_name:"unknown", pl->next?delim:""); |
| 295 | */ |
| 296 | printed += sprintf(buf+printed, "%hu%s", pl->startport, pl->next?delim:""); |
| 297 | } |
| 298 | if(printed > (bufsize - 64)) { |
| 299 | printed += sprintf(buf+printed, "..."); |
| 300 | break; |
| 301 | } |
| 302 | } |
| 303 | return printed; |
| 304 | } |
| 305 | |
| 306 | |
| 307 | static int printuserlist(char *buf, int bufsize, struct userlist* ul, char * delim){ |