Shorten pathname in status message
This commit is contained in:
parent
dc961b598a
commit
758d301c31
3 changed files with 20 additions and 19 deletions
2
nmrp.c
2
nmrp.c
|
|
@ -571,7 +571,7 @@ int nmrp_do(struct nmrpd_args *args)
|
||||||
if (!strcmp(args->file_local, "-")) {
|
if (!strcmp(args->file_local, "-")) {
|
||||||
printf("Uploading from stdin ... ");
|
printf("Uploading from stdin ... ");
|
||||||
} else {
|
} else {
|
||||||
printf("Uploading %s ... ", args->file_local);
|
printf("Uploading %s ... ", leafname(args->file_local));
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
status = tftp_put(args);
|
status = tftp_put(args);
|
||||||
|
|
|
||||||
1
nmrpd.h
1
nmrpd.h
|
|
@ -75,6 +75,7 @@ struct nmrpd_args {
|
||||||
int force_root;
|
int force_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *leafname(const char *path);
|
||||||
int tftp_put(struct nmrpd_args *args);
|
int tftp_put(struct nmrpd_args *args);
|
||||||
bool tftp_is_valid_filename(const char *filename);
|
bool tftp_is_valid_filename(const char *filename);
|
||||||
|
|
||||||
|
|
|
||||||
36
tftp.c
36
tftp.c
|
|
@ -40,24 +40,6 @@ enum tftp_opcode {
|
||||||
ERR = 5
|
ERR = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *leafname(const char *path)
|
|
||||||
{
|
|
||||||
const char *slash, *bslash;
|
|
||||||
|
|
||||||
slash = strrchr(path, '/');
|
|
||||||
bslash = strrchr(path, '\\');
|
|
||||||
|
|
||||||
if (slash && bslash) {
|
|
||||||
path = 1 + (slash > bslash ? slash : bslash);
|
|
||||||
} else if (slash) {
|
|
||||||
path = 1 + slash;
|
|
||||||
} else if (bslash) {
|
|
||||||
path = 1 + bslash;
|
|
||||||
}
|
|
||||||
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_netascii(const char *str)
|
static bool is_netascii(const char *str)
|
||||||
{
|
{
|
||||||
uint8_t *p = (uint8_t*)str;
|
uint8_t *p = (uint8_t*)str;
|
||||||
|
|
@ -211,6 +193,24 @@ static ssize_t tftp_sendto(int sock, char *pkt, size_t len,
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *leafname(const char *path)
|
||||||
|
{
|
||||||
|
const char *slash, *bslash;
|
||||||
|
|
||||||
|
slash = strrchr(path, '/');
|
||||||
|
bslash = strrchr(path, '\\');
|
||||||
|
|
||||||
|
if (slash && bslash) {
|
||||||
|
path = 1 + (slash > bslash ? slash : bslash);
|
||||||
|
} else if (slash) {
|
||||||
|
path = 1 + slash;
|
||||||
|
} else if (bslash) {
|
||||||
|
path = 1 + bslash;
|
||||||
|
}
|
||||||
|
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef NMRPFLASH_WINDOWS
|
#ifdef NMRPFLASH_WINDOWS
|
||||||
void sock_perror(const char *msg)
|
void sock_perror(const char *msg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue