aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-11-18 22:15:50 +0100
committerUlrich Sibiller <uli42@gmx.de>2017-11-18 23:55:02 +0100
commit76ce623abfd61c71912585a3c24d36cdc1d0a7b4 (patch)
tree3379cc70950d1d5589b2d81ab5b5a37784563d99
parent39d45a0e8ff58a649e5c8e403f89e3b14ad1c9d2 (diff)
downloadnx-libs-76ce623abfd61c71912585a3c24d36cdc1d0a7b4.tar.gz
nx-libs-76ce623abfd61c71912585a3c24d36cdc1d0a7b4.tar.bz2
nx-libs-76ce623abfd61c71912585a3c24d36cdc1d0a7b4.zip
Fix options parsing on reconnect
Commit 3f7b3001988bf921e6cd860f03a6256b1451ee3d was incomplete: the options parameter was not parsed as a string on reconnect. It was always assumed to be a filename.
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Args.c74
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Args.h1
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Reconnect.c4
3 files changed, 43 insertions, 36 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.c b/nx-X11/programs/Xserver/hw/nxagent/Args.c
index e4fa350bc..effb3f746 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Args.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Args.c
@@ -135,7 +135,7 @@ char nxagentShadowDisplayName[1024] = {0};
char nxagentWindowName[256];
char nxagentDialogName[256];
char nxagentSessionId[256] = {0};
-char *nxagentOptionsFilename;
+char *nxagentOptionsFilenameOrString;
Bool nxagentFullGeneration = False;
int nxagentDefaultClass = TrueColor;
@@ -259,18 +259,18 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc)
{
- if (nxagentOptionsFilename)
+ if (nxagentOptionsFilenameOrString)
{
- nxagentOptionsFilename = (char *) realloc(nxagentOptionsFilename, strlen(argv[j + 1]) + 1);
+ nxagentOptionsFilenameOrString = (char *) realloc(nxagentOptionsFilenameOrString, strlen(argv[j + 1]) + 1);
}
else
{
- nxagentOptionsFilename = (char *) malloc(strlen(argv[j + 1]) +1);
+ nxagentOptionsFilenameOrString = (char *) malloc(strlen(argv[j + 1]) +1);
}
- if (nxagentOptionsFilename != NULL)
+ if (nxagentOptionsFilenameOrString != NULL)
{
- nxagentOptionsFilename = strcpy(nxagentOptionsFilename, argv[j + 1]);
+ nxagentOptionsFilenameOrString = strcpy(nxagentOptionsFilenameOrString, argv[j + 1]);
}
#ifdef WARNING
else
@@ -283,25 +283,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
}
}
- if (nxagentOptionsFilename)
- {
- /* if the "filename" starts with an nx marker treat it
- as an option _string_ instead of a filename */
- if (strncasecmp(nxagentOptionsFilename, "nx/nx,", 6) == 0 ||
- strncasecmp(nxagentOptionsFilename, "nx/nx:", 6) == 0)
- {
- nxagentParseOptionString(nxagentOptionsFilename + 6);
- }
- else if (strncasecmp(nxagentOptionsFilename, "nx,", 3) == 0 ||
- strncasecmp(nxagentOptionsFilename, "nx:", 3) == 0)
- {
- nxagentParseOptionString(nxagentOptionsFilename + 3);
- }
- else
- {
- nxagentProcessOptionsFile(nxagentOptionsFilename);
- }
- }
+ nxagentProcessOptions(nxagentOptionsFilenameOrString);
}
if (!strcmp(argv[i], "-B"))
@@ -380,23 +362,19 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
int size;
- if (nxagentOptionsFilename != NULL)
- {
- free(nxagentOptionsFilename);
-
- nxagentOptionsFilename = NULL;
- }
+ free(nxagentOptionsFilenameOrString);
+ nxagentOptionsFilenameOrString = NULL;
if ((size = strlen(argv[i])) < 1024)
{
- if ((nxagentOptionsFilename = malloc(size + 1)) == NULL)
+ if ((nxagentOptionsFilenameOrString = malloc(size + 1)) == NULL)
{
FatalError("malloc failed");
}
- strncpy(nxagentOptionsFilename, argv[i], size);
+ strncpy(nxagentOptionsFilenameOrString, argv[i], size);
- nxagentOptionsFilename[size] = '\0';
+ nxagentOptionsFilenameOrString[size] = '\0';
}
else
{
@@ -1584,6 +1562,34 @@ static void nxagentParseOptionString(char *string)
}
}
+void nxagentProcessOptions(char * string)
+{
+ if (!string)
+ return;
+
+ #ifdef DEBUG
+ fprintf(stderr, "%s: Going to process option string/filename [%s].\n",
+ __func__, validateString(string));
+ #endif
+
+ /* if the "filename" starts with an nx marker treat it
+ as an option _string_ instead of a filename */
+ if (strncasecmp(string, "nx/nx,", 6) == 0 ||
+ strncasecmp(string, "nx/nx:", 6) == 0)
+ {
+ nxagentParseOptionString(string + 6);
+ }
+ else if (strncasecmp(string, "nx,", 3) == 0 ||
+ strncasecmp(string, "nx:", 3) == 0)
+ {
+ nxagentParseOptionString(string + 3);
+ }
+ else
+ {
+ nxagentProcessOptionsFile(string);
+ }
+}
+
void nxagentProcessOptionsFile(char * filename)
{
FILE *file;
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Args.h b/nx-X11/programs/Xserver/hw/nxagent/Args.h
index 4c736ea9f..d60488c0d 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Args.h
+++ b/nx-X11/programs/Xserver/hw/nxagent/Args.h
@@ -81,6 +81,7 @@ extern Bool nxagentIpaq;
extern int nxagentLockDeferLevel;
Bool nxagentPostProcessArgs(char *name, Display *dpy, Screen *scr);
+void nxagentProcessOptions(char * string);
void nxagentProcessOptionsFile(char * filename);
void nxagentSetPackMethod(void);
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
index 902fe36be..cae0a397b 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c
@@ -103,7 +103,7 @@ extern Bool nxagentRenderEnable;
extern char *nxagentKeyboard;
-extern char *nxagentOptionsFilename;
+extern char *nxagentOptionsFilenameOrString;
enum SESSION_STATE nxagentSessionState = SESSION_STARTING;
@@ -456,7 +456,7 @@ Bool nxagentReconnectSession(void)
nxagentResetOptions();
- nxagentProcessOptionsFile(nxagentOptionsFilename);
+ nxagentProcessOptions(nxagentOptionsFilenameOrString);
if (nxagentReconnectDisplay(reconnectLossyLevel[DISPLAY_STEP]) == 0)
{