fixed. Support buulding in 1 binary
This commit is contained in:
parent
f8dd7660ae
commit
7d0207ace2
58 changed files with 251 additions and 434 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
unsigned long long parse_uint(const char *str) {
|
||||
static unsigned long long parse_uint(const char *str) {
|
||||
char *p = NULL;
|
||||
|
||||
unsigned long long res = strtoull(str, &p, 0);
|
||||
|
@ -32,7 +32,7 @@ unsigned long long parse_uint(const char *str) {
|
|||
return res;
|
||||
}
|
||||
|
||||
unsigned long long mu_parse_duration(const char *arg) {
|
||||
static unsigned long long mu_parse_duration(const char *arg) {
|
||||
if (strchr(arg, '.')) {
|
||||
/* TODO */
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int mu_get_stat(const char *prog_name, const char *path, struct stat *stat_path) {
|
||||
static int mu_get_stat(const char *prog_name, const char *path, struct stat *stat_path) {
|
||||
if (stat(path, stat_path)) {
|
||||
if (prog_name != NULL)
|
||||
fprintf(stderr, "%s: %s: %s\n", prog_name, path, strerror(errno));
|
||||
|
@ -17,7 +17,7 @@ int mu_get_stat(const char *prog_name, const char *path, struct stat *stat_path)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mu_get_lstat(const char *prog_name, const char *path, struct stat *stat_path) {
|
||||
static int mu_get_lstat(const char *prog_name, const char *path, struct stat *stat_path) {
|
||||
if (lstat(path, stat_path)) {
|
||||
if (prog_name != NULL)
|
||||
fprintf(stderr, "%s: %s: %s\n", prog_name, path, strerror(errno));
|
||||
|
@ -28,7 +28,7 @@ int mu_get_lstat(const char *prog_name, const char *path, struct stat *stat_path
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mu_get_stats(const char *prog_name, int flag, const char *path, struct stat *stat_path) {
|
||||
static int mu_get_stats(const char *prog_name, int flag, const char *path, struct stat *stat_path) {
|
||||
if (flag)
|
||||
return mu_get_lstat(prog_name, path, stat_path);
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#define MU_HUMAN_BUF_SIZE 16
|
||||
|
||||
char *mu_humansize(off_t n, off_t block) {
|
||||
static char *mu_humansize(off_t n, off_t block) {
|
||||
static char mu_hs_buf[MU_HUMAN_BUF_SIZE + 1];
|
||||
memset(mu_hs_buf, '\0', sizeof(mu_hs_buf));
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char *mu_make_path(const char *prog_name, const char *src, const char *dst) {
|
||||
static char *mu_make_path(const char *prog_name, const char *src, const char *dst) {
|
||||
int flag = 0;
|
||||
|
||||
if (src == NULL) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
char *mu_mode_2_str(mode_t file_mode) {
|
||||
static char *mu_mode_2_str(mode_t file_mode) {
|
||||
static char mode[11];
|
||||
snprintf(mode, sizeof(mode), "----------");
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _UTF8_STRLEN
|
||||
#define _UTF8_STRLEN
|
||||
|
||||
size_t mu_strlen(const char *s) {
|
||||
static size_t mu_strlen(const char *s) {
|
||||
size_t i = 0;
|
||||
|
||||
while (*s++)
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#define SU_PERM (S_ISUID | S_ISGID | S_ISVTX)
|
||||
#define FULL_PERM (WR_PERM | EX_PERM | RD_PERM)
|
||||
|
||||
mode_t mu_parse_mode(const char *s, mode_t cur_mode) {
|
||||
static mode_t mu_parse_mode(const char *s, mode_t cur_mode) {
|
||||
char *p = NULL;
|
||||
|
||||
mode_t mode = (mode_t)strtol(s, &p, 8);
|
||||
|
|
|
@ -9,7 +9,7 @@ typedef struct {
|
|||
unsigned int val;
|
||||
} MU_MOUNT_OPTS;
|
||||
|
||||
MU_MOUNT_OPTS mu_options[] = {
|
||||
static MU_MOUNT_OPTS mu_options[] = {
|
||||
{"defaults", NULL, NULL, 0},
|
||||
{"ro", "rw", "Read only / Read and write", MS_RDONLY},
|
||||
{"remount", NULL, "Remount a mounted filesystem", MS_REMOUNT},
|
||||
|
@ -20,7 +20,7 @@ MU_MOUNT_OPTS mu_options[] = {
|
|||
{"noatime", "atime", "Disable/enable updates to inode access times", MS_NOATIME}
|
||||
};
|
||||
|
||||
unsigned long mu_parse_opts(char *str, char *data, const size_t data_size) {
|
||||
static unsigned long mu_parse_opts(char *str, char *data, const size_t data_size) {
|
||||
memset(data, '\0', data_size);
|
||||
unsigned long opt = 0;
|
||||
size_t data_len = 0;
|
||||
|
|
|
@ -46,7 +46,7 @@ struct mu_proc {
|
|||
long rsslim;
|
||||
};
|
||||
|
||||
int mu_proc_status(const char *prog_name, const pid_t pid, struct mu_proc *proc_s) {
|
||||
static int mu_proc_status(const char *prog_name, const pid_t pid, struct mu_proc *proc_s) {
|
||||
proc_s->uid = -1;
|
||||
proc_s->gid = -1;
|
||||
|
||||
|
@ -98,7 +98,7 @@ int mu_proc_status(const char *prog_name, const pid_t pid, struct mu_proc *proc_
|
|||
return 0;
|
||||
}
|
||||
|
||||
int mu_proc_stat(const char *prog_name, const pid_t pid, struct mu_proc *proc_s) {
|
||||
static int mu_proc_stat(const char *prog_name, const pid_t pid, struct mu_proc *proc_s) {
|
||||
char path[PATH_MAX + 1];
|
||||
snprintf(path, sizeof(path), "/proc/%d/stat", pid);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <errno.h>
|
||||
#include "config.h"
|
||||
|
||||
void dec_salt(void) {
|
||||
static void dec_salt(void) {
|
||||
size_t i;
|
||||
for (i = 0; i < sizeof(MU_SALT_ENC) / sizeof(int); i++)
|
||||
MU_SALT_BUF[i] = (char)MU_SALT_ENC[i];
|
||||
|
@ -16,7 +16,7 @@ void dec_salt(void) {
|
|||
MU_SALT_BUF[i + 1] = '\0';
|
||||
}
|
||||
|
||||
char *enc_password(const char *prog_name, const char *pass, const char *salt) {
|
||||
static char *enc_password(const char *prog_name, const char *pass, const char *salt) {
|
||||
if (salt == NULL)
|
||||
dec_salt();
|
||||
|
||||
|
@ -31,7 +31,7 @@ char *enc_password(const char *prog_name, const char *pass, const char *salt) {
|
|||
return cpass;
|
||||
}
|
||||
|
||||
int pw_check(const char *prog_name, const struct passwd *pw, const char *pass) {
|
||||
static int pw_check(const char *prog_name, const struct passwd *pw, const char *pass) {
|
||||
if (pw->pw_passwd[0] == '\0' && pass[0] == '\0')
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "make_path.h"
|
||||
#include "get_stat.h"
|
||||
|
||||
int mu_recurse(const char *restrict prog_name, int link_flag, const char *restrict path, void *restrict arg, int (*file_act)(const char *path, void *p), int (*dir_act)(const char *path, void *p)) {
|
||||
static int mu_recurse(const char *restrict prog_name, int link_flag, const char *restrict path, void *restrict arg, int (*file_act)(const char *path, void *p), int (*dir_act)(const char *path, void *p)) {
|
||||
struct stat sb;
|
||||
if (mu_get_stats(prog_name, link_flag, path, &sb))
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue