summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2014-01-16 09:26:50 -0600
committerRob Landley <rob@landley.net>2014-01-16 09:26:50 -0600
commit59d85e2bb065a3bdc27868acb7a65f89d872c7fa (patch)
tree25db9183f6e142b7c5f12b69e9728aaa98f5bbd6
parent2ded83376cb822198e83048335417a0e870f2240 (diff)
downloadtoybox-59d85e2bb065a3bdc27868acb7a65f89d872c7fa.tar.gz
toybox-59d85e2bb065a3bdc27868acb7a65f89d872c7fa.tar.bz2
toybox-59d85e2bb065a3bdc27868acb7a65f89d872c7fa.zip
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.
-rw-r--r--lib/lib.h2
-rw-r--r--lib/password.c4
-rw-r--r--lib/xwrap.c2
-rw-r--r--toys/lsb/mktemp.c2
-rw-r--r--toys/lsb/passwd.c2
-rw-r--r--toys/lsb/su.c2
-rw-r--r--toys/lsb/umount.c2
-rw-r--r--toys/other/pwdx.c2
-rw-r--r--toys/pending/fdisk.c2
-rw-r--r--toys/pending/fsck.c4
-rw-r--r--toys/pending/groupadd.c6
-rw-r--r--toys/pending/init.c4
-rw-r--r--toys/pending/netstat.c8
-rw-r--r--toys/pending/ps.c30
-rw-r--r--toys/pending/syslogd.c2
-rw-r--r--toys/pending/tcpsvd.c4
-rw-r--r--toys/pending/useradd.c12
-rw-r--r--toys/pending/watch.c4
-rw-r--r--toys/posix/cp.c4
-rw-r--r--toys/posix/ln.c2
-rw-r--r--toys/posix/nohup.c2
-rw-r--r--toys/posix/split.c2
22 files changed, 52 insertions, 52 deletions
diff --git a/lib/lib.h b/lib/lib.h
index d052880..be94018 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -83,7 +83,7 @@ void *xzalloc(size_t size);
void *xrealloc(void *ptr, size_t size);
char *xstrndup(char *s, size_t n);
char *xstrdup(char *s);
-char *xmsprintf(char *format, ...);
+char *xmprintf(char *format, ...);
void xprintf(char *format, ...);
void xputs(char *s);
void xputc(char c);
diff --git a/lib/password.c b/lib/password.c
index e184e0e..f2d010e 100644
--- a/lib/password.c
+++ b/lib/password.c
@@ -129,7 +129,7 @@ int update_password(char *filename, char* username, char* entry)
struct flock lock;
shadow = strstr(filename, "shadow");
- filenamesfx = xmsprintf("%s+", filename);
+ filenamesfx = xmprintf("%s+", filename);
sfx = strchr(filenamesfx, '+');
exfp = fopen(filename, "r+");
@@ -163,7 +163,7 @@ int update_password(char *filename, char* username, char* entry)
}
ret = 0;
- namesfx = xmsprintf("%s:",username);
+ namesfx = xmprintf("%s:",username);
while ((line = get_line(fileno(exfp))) != NULL)
{
if (strncmp(line, namesfx, strlen(namesfx)))
diff --git a/lib/xwrap.c b/lib/xwrap.c
index ae296cd..2ecffaa 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -66,7 +66,7 @@ char *xstrdup(char *s)
}
// Die unless we can allocate enough space to sprintf() into.
-char *xmsprintf(char *format, ...)
+char *xmprintf(char *format, ...)
{
va_list va, va2;
int len;
diff --git a/toys/lsb/mktemp.c b/toys/lsb/mktemp.c
index 86c2033..c1175fe 100644
--- a/toys/lsb/mktemp.c
+++ b/toys/lsb/mktemp.c
@@ -38,7 +38,7 @@ void mktemp_main(void)
if (!TT.tmpdir) TT.tmpdir = "/tmp";
tmp = "tmp.xxxxxx";
}
- if (TT.tmpdir) tmp = xmsprintf("%s/%s", TT.tmpdir ? TT.tmpdir : "/tmp",
+ if (TT.tmpdir) tmp = xmprintf("%s/%s", TT.tmpdir ? TT.tmpdir : "/tmp",
*toys.optargs ? *toys.optargs : "tmp.XXXXXX");
if (d_flag ? mkdtemp(tmp) == NULL : mkstemp(tmp) == -1)
diff --git a/toys/lsb/passwd.c b/toys/lsb/passwd.c
index f333836..c92fb0d 100644
--- a/toys/lsb/passwd.c
+++ b/toys/lsb/passwd.c
@@ -160,7 +160,7 @@ void passwd_main(void)
} else if (toys.optflags & FLAG_l) {
if (pass[0] == '!') error_exit("password is already locked for %s",name);
printf("Locking password for %s\n",name);
- encrypted = xmsprintf("!%s",pass);
+ encrypted = xmprintf("!%s",pass);
} else if (toys.optflags & FLAG_u) {
if (pass[0] != '!') error_exit("password is already unlocked for %s",name);
diff --git a/toys/lsb/su.c b/toys/lsb/su.c
index 04b0dc1..a92705c 100644
--- a/toys/lsb/su.c
+++ b/toys/lsb/su.c
@@ -33,7 +33,7 @@ static char *snapshot_env(char *name)
{
char *s = getenv(name);
- if (s) return xmsprintf("%s=%s", name, s);
+ if (s) return xmprintf("%s=%s", name, s);
return 0;
}
diff --git a/toys/lsb/umount.c b/toys/lsb/umount.c
index bcc1fff..cc40f14 100644
--- a/toys/lsb/umount.c
+++ b/toys/lsb/umount.c
@@ -57,7 +57,7 @@ void comma_collate(char **old, char *new)
char *comma = ",";
if (atold[strlen(atold)-1] == ',') comma = "";
- temp = xmsprintf("%s%s%s", atold, comma, new);
+ temp = xmprintf("%s%s%s", atold, comma, new);
} else temp = xstrdup(new);
free (atold);
*old = temp;
diff --git a/toys/other/pwdx.c b/toys/other/pwdx.c
index b2acc41..bde16e7 100644
--- a/toys/other/pwdx.c
+++ b/toys/other/pwdx.c
@@ -23,7 +23,7 @@ void pwdx_main(void)
char *path;
int num_bytes;
- path = xmsprintf("/proc/%s/cwd", *optargs);
+ path = xmprintf("/proc/%s/cwd", *optargs);
num_bytes = readlink(path, toybuf, sizeof(toybuf)-1);
free(path);
diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c
index 24769c6..932b38d 100644
--- a/toys/pending/fdisk.c
+++ b/toys/pending/fdisk.c
@@ -1005,7 +1005,7 @@ static void add_new_partition(void)
return;
}
- msg = xmsprintf(" %s\n p primary partition(1-4)\n",
+ msg = xmprintf(" %s\n p primary partition(1-4)\n",
extended_offset? "l logical (5 or over)" : "e extended");
choice = 0x20 | read_input(msg, NULL);
diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c
index 1c607ae..1e31fe4 100644
--- a/toys/pending/fsck.c
+++ b/toys/pending/fsck.c
@@ -198,9 +198,9 @@ static void do_fsck(struct f_sys_info *finfo)
else type = "auto";
args = xzalloc((toys.optc + 2 + 1 + 1) * sizeof(char*)); //+1, for NULL, +1 if -C
- args[0] = xmsprintf("fsck.%s", type);
+ args[0] = xmprintf("fsck.%s", type);
- if(toys.optflags & FLAG_C) args[i++] = xmsprintf("%s %d","-C", TT.fd_num);
+ if(toys.optflags & FLAG_C) args[i++] = xmprintf("%s %d","-C", TT.fd_num);
while(toys.optargs[j]) {
if(*toys.optargs[j]) args[i++] = xstrdup(toys.optargs[j]);
j++;
diff --git a/toys/pending/groupadd.c b/toys/pending/groupadd.c
index 8ff539e..c19e1ee 100644
--- a/toys/pending/groupadd.c
+++ b/toys/pending/groupadd.c
@@ -59,10 +59,10 @@ static void new_group()
}
}
- entry = xmsprintf("%s:%s:%d:", *toys.optargs, "x", TT.gid);
+ entry = xmprintf("%s:%s:%d:", *toys.optargs, "x", TT.gid);
update_password(GROUP_PATH, *toys.optargs, entry);
free(entry);
- entry = xmsprintf("%s:%s::", *toys.optargs, "!");
+ entry = xmprintf("%s:%s::", *toys.optargs, "!");
update_password(SECURE_GROUP_PATH, *toys.optargs, entry);
free(entry);
}
@@ -82,7 +82,7 @@ void groupadd_main(void)
xgetpwnam(*toys.optargs);
if (!(grp = getgrnam(toys.optargs[1])))
error_exit("group '%s' does not exist", toys.optargs[1]);
- if (!grp->gr_mem) entry = xmsprintf("%s", *toys.optargs);
+ if (!grp->gr_mem) entry = xmprintf("%s", *toys.optargs);
else {
int i;
diff --git a/toys/pending/init.c b/toys/pending/init.c
index 559ab09..751f987 100644
--- a/toys/pending/init.c
+++ b/toys/pending/init.c
@@ -155,8 +155,8 @@ static void inittab_parsing(void)
case 1:
if (*extracted_token) {
if (!strncmp(extracted_token, "/dev/", 5))
- tty_name = xmsprintf("%s",extracted_token);
- else tty_name = xmsprintf("/dev/%s",extracted_token);
+ tty_name = xmprintf("%s",extracted_token);
+ else tty_name = xmprintf("/dev/%s",extracted_token);
} else tty_name = xstrdup("");
break;
case 2:
diff --git a/toys/pending/netstat.c b/toys/pending/netstat.c
index 34644f4..55be772 100644
--- a/toys/pending/netstat.c
+++ b/toys/pending/netstat.c
@@ -115,7 +115,7 @@ static char *append_pathandfile(char *path, char *fname)
if (!path) path = "";
c = find_last_char(path, '/');
while (*fname == '/') fname++;
- return xmsprintf("%s%s%s", path, (c)? "" : "/", fname);
+ return xmprintf("%s%s%s", path, (c)? "" : "/", fname);
}
/*
* Concat sub-path and the file name.
@@ -211,10 +211,10 @@ static void show_data(unsigned rport, char *label, unsigned rxq, unsigned txq, c
static char *get_servname(int port, char *label)
{
int lport = htons(port);
- if (!lport) return xmsprintf("%s", "*");
+ if (!lport) return xmprintf("%s", "*");
struct servent *ser = getservbyport(lport, label);
- if (ser) return xmsprintf("%s", ser->s_name);
- return xmsprintf("%u", (unsigned)ntohs(lport));
+ if (ser) return xmprintf("%s", ser->s_name);
+ return xmprintf("%u", (unsigned)ntohs(lport));
}
/*
* used to convert address into text format.
diff --git a/toys/pending/ps.c b/toys/pending/ps.c
index 19521b6..fddf2f3 100644
--- a/toys/pending/ps.c
+++ b/toys/pending/ps.c
@@ -104,8 +104,8 @@ static void print_header(void)
temp++;
while (def_header[i].name) {
if (!(strcmp(def_header[i].name, ptr))) { // search from default header
- if (str) ptr = xmsprintf("%s,%s", temp, str); //handle condition like ppid = M,OM
- else ptr = xmsprintf("%s", temp);
+ if (str) ptr = xmprintf("%s,%s", temp, str); //handle condition like ppid = M,OM
+ else ptr = xmprintf("%s", temp);
list_add(&o_list, &def_header[i], ptr);
break;
}
@@ -163,7 +163,7 @@ void get_etime(unsigned long s_time)
min = info.uptime - min;
sec = min % 60;
min = min / 60;
- temp = xmsprintf("%3lu:%02u", min,sec);
+ temp = xmprintf("%3lu:%02u", min,sec);
xprintf("%*.*s",7,7,temp);
free(temp);
}
@@ -177,7 +177,7 @@ void get_time(unsigned long s_time, unsigned long u_time)
min = (s_time + u_time)/sysconf(_SC_CLK_TCK);
sec = min % 60;
min = min / 60;
- temp = xmsprintf("%3lu:%02u", min,sec);
+ temp = xmprintf("%3lu:%02u", min,sec);
xprintf("%*.*s",6,6,temp);
free(temp);
}
@@ -237,7 +237,7 @@ static void do_ps_line(int pid, int tid)
name = ptr;
ptr = strrchr(stat_buff, ')');
*ptr = '\0'; //unecessary if?
- name = xmsprintf("[%s]", name);
+ name = xmprintf("[%s]", name);
ptr += 2; // goto STATE
n = sscanf(ptr, "%c %u %u %*u %d %*s %*s %*s %*s %*s %*s "
"%lu %lu %*s %*s %*s %d %*s %*s %lu %lu %ld",
@@ -272,15 +272,15 @@ static void do_ps_line(int pid, int tid)
switch (p->position) {
case 0:
pw = getpwuid(stats.st_uid);
- if (!pw) user = xmsprintf("%d",(int)stats.st_uid);
- else user = xmsprintf("%s", pw->pw_name);
+ if (!pw) user = xmprintf("%d",(int)stats.st_uid);
+ else user = xmprintf("%s", pw->pw_name);
printf("%-*.*s", width, width, user);
free(user);
break;
case 1:
gr = getgrgid(stats.st_gid);
- if (!gr) group = xmsprintf("%d",(int)stats.st_gid);
- else group = xmsprintf("%s", gr->gr_name);
+ if (!gr) group = xmprintf("%d",(int)stats.st_gid);
+ else group = xmprintf("%s", gr->gr_name);
printf("%-*.*s", width, width, group);
free(group);
break;
@@ -322,16 +322,16 @@ static void do_ps_line(int pid, int tid)
case 9:
get_uid_gid(stat_buff, "Gid:", &rgid);
gr = getgrgid(rgid);
- if (!gr) rgroup = xmsprintf("%d",(int)stats.st_gid);
- else rgroup = xmsprintf("%s", gr->gr_name);
+ if (!gr) rgroup = xmprintf("%d",(int)stats.st_gid);
+ else rgroup = xmprintf("%s", gr->gr_name);
printf("%-*.*s", width,width, rgroup);
free(rgroup);
break;
case 10:
get_uid_gid(stat_buff, "Uid:", &ruid);
pw = getpwuid(ruid);
- if (!pw) ruser = xmsprintf("%d",(int)stats.st_uid);
- else ruser = xmsprintf("%s", pw->pw_name);
+ if (!pw) ruser = xmprintf("%d",(int)stats.st_uid);
+ else ruser = xmprintf("%s", pw->pw_name);
printf("%-*.*s", width, width, ruser);
free(ruser);
break;
@@ -340,7 +340,7 @@ static void do_ps_line(int pid, int tid)
break;
case 12:
if (tty_major) {
- char *temp = xmsprintf("%d,%d", tty_major,tty_minor);
+ char *temp = xmprintf("%d,%d", tty_major,tty_minor);
printf("%-*s", width, temp);
free(temp);
} else printf("%-*s", width, "?");
@@ -370,7 +370,7 @@ void do_ps_threads(int pid)
DIR *d;
int tid;
struct dirent *de;
- char *tmp = xmsprintf("/proc/%d/task",pid);
+ char *tmp = xmprintf("/proc/%d/task",pid);
if (!(d = opendir(tmp))) {
free(tmp);
diff --git a/toys/pending/syslogd.c b/toys/pending/syslogd.c
index e272691..28b1413 100644
--- a/toys/pending/syslogd.c
+++ b/toys/pending/syslogd.c
@@ -176,7 +176,7 @@ static int parse_config_file(void)
*/
if (toys.optflags & FLAG_R) {
file = xzalloc(sizeof(struct logfile));
- file->filename = xmsprintf("@%s",TT.remote_log);
+ file->filename = xmprintf("@%s",TT.remote_log);
TT.lfiles = file;
if (!(toys.optflags & FLAG_L)) return 0;
}
diff --git a/toys/pending/tcpsvd.c b/toys/pending/tcpsvd.c
index 37aafeb..031d723 100644
--- a/toys/pending/tcpsvd.c
+++ b/toys/pending/tcpsvd.c
@@ -79,8 +79,8 @@ static char *sock_to_address(struct sockaddr *sock, int flags)
if (!(status = getnameinfo(sock, len, hbuf, sizeof(hbuf), sbuf,
sizeof(sbuf), flags))) {
- if (flags & NI_NUMERICSERV) return xmsprintf("%s:%s",hbuf, sbuf);
- return xmsprintf("%s",hbuf);
+ if (flags & NI_NUMERICSERV) return xmprintf("%s:%s",hbuf, sbuf);
+ return xmprintf("%s",hbuf);
}
error_exit("getnameinfo: %s", gai_strerror(status));
}
diff --git a/toys/pending/useradd.c b/toys/pending/useradd.c
index ecfd638..450e021 100644
--- a/toys/pending/useradd.c
+++ b/toys/pending/useradd.c
@@ -90,7 +90,7 @@ static void create_copy_skel(char *skel, char *hdir)
args[0] = "chown";
args[1] = "-R";
- args[2] = xmsprintf("%u:%u", TT.uid, TT.gid);
+ args[2] = xmprintf("%u:%u", TT.uid, TT.gid);
args[3] = hdir;
//Change ownership to that of UID and GID of new user
toys.exitval = exec_wait(args);
@@ -118,7 +118,7 @@ static void new_user()
if (toys.optflags & FLAG_g) pwd.pw_gecos = TT.gecos;
else pwd.pw_gecos = "Linux User,";
if (toys.optflags & FLAG_h) pwd.pw_dir = TT.dir;
- else pwd.pw_dir = xmsprintf("/home/%s", *toys.optargs);
+ else pwd.pw_dir = xmprintf("/home/%s", *toys.optargs);
if (toys.optflags & FLAG_s) pwd.pw_shell = TT.shell;
else pwd.pw_shell = get_shell();
@@ -168,7 +168,7 @@ static void new_user()
//add group, invoke addgroup command
args[0] = "groupadd";
args[1] = toys.optargs[0];
- args[2] = xmsprintf("-g%ld", pwd.pw_gid);
+ args[2] = xmprintf("-g%ld", pwd.pw_gid);
args[3] = NULL;
if (exec_wait(args)) error_msg("addgroup fail");
}
@@ -180,15 +180,15 @@ static void new_user()
*/
// 1. add an entry to /etc/passwd and /etc/shadow file
- entry = xmsprintf("%s:%s:%ld:%ld:%s:%s:%s", pwd.pw_name, pwd.pw_passwd,
+ entry = xmprintf("%s:%s:%ld:%ld:%s:%s:%s", pwd.pw_name, pwd.pw_passwd,
pwd.pw_uid, pwd.pw_gid, pwd.pw_gecos, pwd.pw_dir, pwd.pw_shell);
if (update_password("/etc/passwd", pwd.pw_name, entry)) error_exit("updating passwd file failed");
free(entry);
if (toys.optflags & FLAG_S)
- entry = xmsprintf("%s:!!:%u::::::", pwd.pw_name,
+ entry = xmprintf("%s:!!:%u::::::", pwd.pw_name,
(unsigned)(time(NULL))/(24*60*60)); //passwd is not set initially
- else entry = xmsprintf("%s:!!:%u:%ld:%ld:%ld:::", pwd.pw_name,
+ else entry = xmprintf("%s:!!:%u:%ld:%ld:%ld:::", pwd.pw_name,
(unsigned)(time(NULL))/(24*60*60), 0, 99999, 7); //passwd is not set initially
update_password("/etc/shadow", pwd.pw_name, entry);
free(entry);
diff --git a/toys/pending/watch.c b/toys/pending/watch.c
index b7fdb5c..8343fe1 100644
--- a/toys/pending/watch.c
+++ b/toys/pending/watch.c
@@ -35,10 +35,10 @@ void watch_main(void)
while(toys.optargs[++i])
{
char * oldcmd = cmd;
- cmd = xmsprintf("%s %s", oldcmd, toys.optargs[i]);
+ cmd = xmprintf("%s %s", oldcmd, toys.optargs[i]);
if (CFG_TOYBOX_FREE) free(oldcmd);
}
- header = xmsprintf("Every %us: %s", TT.interval, cmd);
+ header = xmprintf("Every %us: %s", TT.interval, cmd);
hlen = strlen(header);
while(1) {
diff --git a/toys/posix/cp.c b/toys/posix/cp.c
index 088f224..817a0c6 100644
--- a/toys/posix/cp.c
+++ b/toys/posix/cp.c
@@ -176,7 +176,7 @@ int cp_node(struct dirtree *try)
if (*or->name == '/') dotdots = 0;
if (dotdots) {
- char *s2 = xmsprintf("% *c%s", 3*dotdots, ' ', s);
+ char *s2 = xmprintf("% *c%s", 3*dotdots, ' ', s);
free(s);
s = s2;
while(dotdots--) {
@@ -275,7 +275,7 @@ void cp_main(void)
char *src = toys.optargs[i];
int rc = 1;
- if (destdir) TT.destname = xmsprintf("%s/%s", destname, basename(src));
+ if (destdir) TT.destname = xmprintf("%s/%s", destname, basename(src));
else TT.destname = destname;
errno = EXDEV;
diff --git a/toys/posix/ln.c b/toys/posix/ln.c
index 3c94e72..d8f4ce6 100644
--- a/toys/posix/ln.c
+++ b/toys/posix/ln.c
@@ -48,7 +48,7 @@ void ln_main(void)
int rc;
char *try = toys.optargs[i];
- if (S_ISDIR(buf.st_mode)) new = xmsprintf("%s/%s", dest, basename(try));
+ if (S_ISDIR(buf.st_mode)) new = xmprintf("%s/%s", dest, basename(try));
else new = dest;
// Silently unlink the existing target (if any)
if (toys.optflags & FLAG_f) unlink(new);
diff --git a/toys/posix/nohup.c b/toys/posix/nohup.c
index e435455..42d0e11 100644
--- a/toys/posix/nohup.c
+++ b/toys/posix/nohup.c
@@ -28,7 +28,7 @@ void nohup_main(void)
S_IRUSR|S_IWUSR ))
{
char *temp = getenv("HOME");
- temp = xmsprintf("%s/%s", temp ? temp : "", "nohup.out");
+ temp = xmprintf("%s/%s", temp ? temp : "", "nohup.out");
xcreate(temp, O_CREAT|O_APPEND|O_WRONLY, S_IRUSR|S_IWUSR);
}
}
diff --git a/toys/posix/split.c b/toys/posix/split.c
index f80527d..d9a556b 100644
--- a/toys/posix/split.c
+++ b/toys/posix/split.c
@@ -100,7 +100,7 @@ void split_main(void)
if (!TT.bytes && !TT.lines) TT.lines = 1000;
// Allocate template for output filenames
- TT.outfile = xmsprintf("%s% *c", (toys.optc == 2) ? toys.optargs[1] : "x",
+ TT.outfile = xmprintf("%s% *c", (toys.optc == 2) ? toys.optargs[1] : "x",
(int)TT.suflen, ' ');
// We only ever use one input, but this handles '-' or no input for us.