mirror of
https://github.com/samba-team/samba.git
synced 2025-02-03 13:47:25 +03:00
lib: Add server_id_str_buf
This is usable in a DEBUG statement without talloc_tos() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
0e9d4f68f9
commit
7a3bda54b0
@ -984,6 +984,10 @@ char *data_path(TALLOC_CTX *mem_ctx, const char *name);
|
||||
const char *shlib_ext(void);
|
||||
|
||||
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);
|
||||
|
||||
bool server_id_equal(const struct server_id *p1, const struct server_id *p2);
|
||||
char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id);
|
||||
struct server_id server_id_from_string(uint32_t local_vnn,
|
||||
|
@ -41,6 +41,28 @@ bool server_id_equal(const struct server_id *p1, const struct server_id *p2)
|
||||
return true;
|
||||
}
|
||||
|
||||
char *server_id_str_buf(struct server_id id, struct server_id_buf *dst)
|
||||
{
|
||||
if (server_id_is_disconnected(&id)) {
|
||||
strlcpy(dst->buf, "disconnected", sizeof(dst->buf));
|
||||
} else if ((id.vnn == NONCLUSTER_VNN) && (id.task_id == 0)) {
|
||||
snprintf(dst->buf, sizeof(dst->buf), "%llu",
|
||||
(unsigned long long)id.pid);
|
||||
} else if (id.vnn == NONCLUSTER_VNN) {
|
||||
snprintf(dst->buf, sizeof(dst->buf), "%llu.%u",
|
||||
(unsigned long long)id.pid, (unsigned)id.task_id);
|
||||
} else if (id.task_id == 0) {
|
||||
snprintf(dst->buf, sizeof(dst->buf), "%u:%llu",
|
||||
(unsigned)id.vnn, (unsigned long long)id.pid);
|
||||
} else {
|
||||
snprintf(dst->buf, sizeof(dst->buf), "%u:%llu.%u",
|
||||
(unsigned)id.vnn,
|
||||
(unsigned long long)id.pid,
|
||||
(unsigned)id.task_id);
|
||||
}
|
||||
return dst->buf;
|
||||
}
|
||||
|
||||
char *server_id_str(TALLOC_CTX *mem_ctx, const struct server_id *id)
|
||||
{
|
||||
if (server_id_is_disconnected(id)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user