Mercurial > hg > toybox
comparison toys/pending/netstat.c @ 1183:0752b2d58909 draft
Rename xmsprintf() to just xmprintf().
Partly because there's no supplied target string ala sprintf, and partly
because I can never remember what order the m and s go in.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 16 Jan 2014 09:26:50 -0600 |
parents | e11684e3bbc5 |
children | c0c91437138b |
comparison
equal
deleted
inserted
replaced
1182:7079ea384a2e | 1183:0752b2d58909 |
---|---|
113 { | 113 { |
114 char *c; | 114 char *c; |
115 if (!path) path = ""; | 115 if (!path) path = ""; |
116 c = find_last_char(path, '/'); | 116 c = find_last_char(path, '/'); |
117 while (*fname == '/') fname++; | 117 while (*fname == '/') fname++; |
118 return xmsprintf("%s%s%s", path, (c)? "" : "/", fname); | 118 return xmprintf("%s%s%s", path, (c)? "" : "/", fname); |
119 } | 119 } |
120 /* | 120 /* |
121 * Concat sub-path and the file name. | 121 * Concat sub-path and the file name. |
122 */ | 122 */ |
123 static char *append_subpathandfile(char *path, char *fname) | 123 static char *append_subpathandfile(char *path, char *fname) |
209 * used to get service name. | 209 * used to get service name. |
210 */ | 210 */ |
211 static char *get_servname(int port, char *label) | 211 static char *get_servname(int port, char *label) |
212 { | 212 { |
213 int lport = htons(port); | 213 int lport = htons(port); |
214 if (!lport) return xmsprintf("%s", "*"); | 214 if (!lport) return xmprintf("%s", "*"); |
215 struct servent *ser = getservbyport(lport, label); | 215 struct servent *ser = getservbyport(lport, label); |
216 if (ser) return xmsprintf("%s", ser->s_name); | 216 if (ser) return xmprintf("%s", ser->s_name); |
217 return xmsprintf("%u", (unsigned)ntohs(lport)); | 217 return xmprintf("%u", (unsigned)ntohs(lport)); |
218 } | 218 } |
219 /* | 219 /* |
220 * used to convert address into text format. | 220 * used to convert address into text format. |
221 */ | 221 */ |
222 static void addr2str(int af, void *addr, unsigned port, char *buf, char *label) | 222 static void addr2str(int af, void *addr, unsigned port, char *buf, char *label) |