Update device ID validation rules and help description

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2025-07-04 09:36:56 +08:00
parent d103b0cbf9
commit 136e03aa33
2 changed files with 6 additions and 3 deletions

View File

@@ -84,8 +84,8 @@ static struct option long_options[] = {
static void usage(const char *prog)
{
fprintf(stderr, "Usage: %s [option]\n"
" -I, --id=string Set an ID for the device(Maximum 63 bytes, valid\n"
" character:letter, number, underline and short line)\n"
" -I, --id=string Set an ID for the device(Any printable character except\n"
" space is allowed, with a maximum of 32 characters)\n"
" -h, --host=string Server's host or ipaddr(Default is localhost)\n"
" -p, --port=number Server port(Default is 5912)\n"
" -d, --description=string Add a description to the device(Maximum 126 bytes)\n"

View File

@@ -50,8 +50,11 @@ int find_login(char *buf, int len)
bool valid_id(const char *id)
{
if (strlen(id) > 32)
return false;
while (*id) {
if (!isalnum(*id) && *id != '-' && *id != '_')
if (!isprint(*id) || *id == ' ')
return false;
id++;
}