mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
lib: Add server_id_str_buf_unique
A representation including the unique id Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
620b7467ad
commit
8044e2dcc0
@ -847,6 +847,7 @@ struct server_id;
|
||||
|
||||
struct server_id_buf { char buf[48]; }; /* probably a bit too large ... */
|
||||
char *server_id_str_buf(struct server_id id, struct server_id_buf *dst);
|
||||
size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen);
|
||||
|
||||
bool server_id_same_process(const struct server_id *p1,
|
||||
const struct server_id *p2);
|
||||
|
@ -65,6 +65,28 @@ char *server_id_str_buf(struct server_id id, struct server_id_buf *dst)
|
||||
return dst->buf;
|
||||
}
|
||||
|
||||
size_t server_id_str_buf_unique(struct server_id id, char *buf, size_t buflen)
|
||||
{
|
||||
struct server_id_buf idbuf;
|
||||
char unique_buf[21]; /* 2^64 is 18446744073709551616, 20 chars */
|
||||
size_t idlen, unique_len, needed;
|
||||
|
||||
server_id_str_buf(id, &idbuf);
|
||||
|
||||
idlen = strlen(idbuf.buf);
|
||||
unique_len = snprintf(unique_buf, sizeof(unique_buf), "%"PRIu64,
|
||||
id.unique_id);
|
||||
needed = idlen + unique_len + 2;
|
||||
|
||||
if (buflen >= needed) {
|
||||
memcpy(buf, idbuf.buf, idlen);
|
||||
buf[idlen] = '/';
|
||||
memcpy(buf + idlen + 1, unique_buf, unique_len+1);
|
||||
}
|
||||
|
||||
return needed;
|
||||
}
|
||||
|
||||
struct server_id server_id_from_string(uint32_t local_vnn,
|
||||
const char *pid_string)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user