Commit cac1af52 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Args.c: simplify nxagentGetDialogName()

parent 74c21e9e
...@@ -2098,31 +2098,24 @@ void ddxUseMsg() ...@@ -2098,31 +2098,24 @@ void ddxUseMsg()
static int nxagentGetDialogName() static int nxagentGetDialogName()
{ {
snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX");
if (*nxagentSessionId != '\0') if (*nxagentSessionId != '\0')
{ {
int length = strlen(nxagentSessionId); int length = strlen(nxagentSessionId);
strcpy(nxagentDialogName, "NX - ");
/* if the session id contains an MD5 hash in a well-known format cut it off */ /* if the session id contains an MD5 hash in a well-known format cut it off */
if (length > (MD5_LENGTH * 2 + 1) && if (length > (MD5_LENGTH * 2 + 1) &&
*(nxagentSessionId + (length - (MD5_LENGTH * 2 + 1))) == '-') *(nxagentSessionId + (length - (MD5_LENGTH * 2 + 1))) == '-')
{ {
strncat(nxagentDialogName, nxagentSessionId, length -= (MD5_LENGTH * 2 + 1);
MIN(NXAGENTDIALOGNAMELENGTH - strlen(nxagentDialogName), length - (MD5_LENGTH * 2 + 1)) - 1);
}
else
{
strncat(nxagentDialogName, nxagentSessionId, NXAGENTDIALOGNAMELENGTH - strlen(nxagentDialogName) - 1);
} }
nxagentDialogName[NXAGENTDIALOGNAMELENGTH - 1] = '\0'; snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX - %.*s", length, nxagentSessionId);
return 1; return 1;
} }
snprintf(nxagentDialogName, NXAGENTDIALOGNAMELENGTH, "NX");
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment