Unverified Commit 9193d11e authored by Mike Gabriel's avatar Mike Gabriel

Merge branch 'uli42-pr/cmdline' into 3.6.x

parents 4ccb7eda 3f7b3001
...@@ -135,7 +135,7 @@ char nxagentShadowDisplayName[1024] = {0}; ...@@ -135,7 +135,7 @@ char nxagentShadowDisplayName[1024] = {0};
char nxagentWindowName[256]; char nxagentWindowName[256];
char nxagentDialogName[256]; char nxagentDialogName[256];
char nxagentSessionId[256] = {0}; char nxagentSessionId[256] = {0};
char *nxagentOptionFile; char *nxagentOptionsFilename;
Bool nxagentFullGeneration = False; Bool nxagentFullGeneration = False;
int nxagentDefaultClass = TrueColor; int nxagentDefaultClass = TrueColor;
...@@ -259,18 +259,18 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -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 ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc)
{ {
if (nxagentOptionFile) if (nxagentOptionsFilename)
{ {
nxagentOptionFile = (char *) realloc(nxagentOptionFile, strlen(argv[j + 1]) + 1); nxagentOptionsFilename = (char *) realloc(nxagentOptionsFilename, strlen(argv[j + 1]) + 1);
} }
else else
{ {
nxagentOptionFile = (char *) malloc(strlen(argv[j + 1]) +1); nxagentOptionsFilename = (char *) malloc(strlen(argv[j + 1]) +1);
} }
if (nxagentOptionFile != NULL) if (nxagentOptionsFilename != NULL)
{ {
nxagentOptionFile = strcpy(nxagentOptionFile, argv[j + 1]); nxagentOptionsFilename = strcpy(nxagentOptionsFilename, argv[j + 1]);
} }
#ifdef WARNING #ifdef WARNING
else else
...@@ -283,9 +283,24 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -283,9 +283,24 @@ int ddxProcessArgument(int argc, char *argv[], int i)
} }
} }
if (nxagentOptionFile) if (nxagentOptionsFilename)
{ {
nxagentProcessOptionsFile(); /* 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);
}
} }
} }
...@@ -365,23 +380,23 @@ int ddxProcessArgument(int argc, char *argv[], int i) ...@@ -365,23 +380,23 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{ {
int size; int size;
if (nxagentOptionFile != NULL) if (nxagentOptionsFilename != NULL)
{ {
free(nxagentOptionFile); free(nxagentOptionsFilename);
nxagentOptionFile = NULL; nxagentOptionsFilename = NULL;
} }
if ((size = strlen(argv[i])) < 1024) if ((size = strlen(argv[i])) < 1024)
{ {
if ((nxagentOptionFile = malloc(size + 1)) == NULL) if ((nxagentOptionsFilename = malloc(size + 1)) == NULL)
{ {
FatalError("malloc failed"); FatalError("malloc failed");
} }
strncpy(nxagentOptionFile, argv[i], size); strncpy(nxagentOptionsFilename, argv[i], size);
nxagentOptionFile[size] = '\0'; nxagentOptionsFilename[size] = '\0';
} }
else else
{ {
...@@ -1569,7 +1584,7 @@ static void nxagentParseOptionString(char *string) ...@@ -1569,7 +1584,7 @@ static void nxagentParseOptionString(char *string)
} }
} }
void nxagentProcessOptionsFile() void nxagentProcessOptionsFile(char * filename)
{ {
FILE *file; FILE *file;
char *data; char *data;
...@@ -1581,8 +1596,8 @@ void nxagentProcessOptionsFile() ...@@ -1581,8 +1596,8 @@ void nxagentProcessOptionsFile()
int maxFileSize = 1024; int maxFileSize = 1024;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentProcessOptionsFile: Going to process option the file [%s].\n", fprintf(stderr, "nxagentProcessOptionsFile: Going to process option file [%s].\n",
validateString(nxagentOptionFile)); validateString(filename);
#endif #endif
/* /*
...@@ -1590,15 +1605,15 @@ void nxagentProcessOptionsFile() ...@@ -1590,15 +1605,15 @@ void nxagentProcessOptionsFile()
*/ */
setStatePath(""); setStatePath("");
if (nxagentOptionFile == NULL) if (filename == NULL)
{ {
return; return;
} }
if ((file = fopen(nxagentOptionFile, "r")) == NULL) if ((file = fopen(filename, "r")) == NULL)
{ {
fprintf(stderr, "Warning: Couldn't open option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't open option file '%s'. Error is '%s'.\n",
validateString(nxagentOptionFile), strerror(errno)); validateString(filename), strerror(errno));
goto nxagentProcessOptionsFileExit; goto nxagentProcessOptionsFileExit;
} }
...@@ -1606,7 +1621,7 @@ void nxagentProcessOptionsFile() ...@@ -1606,7 +1621,7 @@ void nxagentProcessOptionsFile()
if (fseek(file, 0, SEEK_END) != 0) if (fseek(file, 0, SEEK_END) != 0)
{ {
fprintf(stderr, "Warning: Couldn't position inside option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't position inside option file '%s'. Error is '%s'.\n",
validateString(nxagentOptionFile), strerror(errno)); validateString(filename), strerror(errno));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileClose;
} }
...@@ -1614,14 +1629,14 @@ void nxagentProcessOptionsFile() ...@@ -1614,14 +1629,14 @@ void nxagentProcessOptionsFile()
if ((sizeOfFile = ftell(file)) == -1) if ((sizeOfFile = ftell(file)) == -1)
{ {
fprintf(stderr, "Warning: Couldn't get the size of option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't get the size of option file '%s'. Error is '%s'.\n",
validateString(nxagentOptionFile), strerror(errno)); validateString(filename), strerror(errno));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileClose;
} }
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "nxagentProcessOptionsFile: Processing option file [%s].\n", fprintf(stderr, "nxagentProcessOptionsFile: Processing option file [%s].\n",
validateString(nxagentOptionFile)); validateString(filename));
#endif #endif
rewind(file); rewind(file);
...@@ -1629,7 +1644,7 @@ void nxagentProcessOptionsFile() ...@@ -1629,7 +1644,7 @@ void nxagentProcessOptionsFile()
if (sizeOfFile > maxFileSize) if (sizeOfFile > maxFileSize)
{ {
fprintf(stderr, "Warning: Maximum file size exceeded for options '%s'.\n", fprintf(stderr, "Warning: Maximum file size exceeded for options '%s'.\n",
validateString(nxagentOptionFile)); validateString(filename));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileClose;
} }
...@@ -1637,7 +1652,7 @@ void nxagentProcessOptionsFile() ...@@ -1637,7 +1652,7 @@ void nxagentProcessOptionsFile()
if ((data = malloc(sizeOfFile + 1)) == NULL) if ((data = malloc(sizeOfFile + 1)) == NULL)
{ {
fprintf(stderr, "Warning: Memory allocation failed processing file '%s'.\n", fprintf(stderr, "Warning: Memory allocation failed processing file '%s'.\n",
validateString(nxagentOptionFile)); validateString(filename));
goto nxagentProcessOptionsFileClose; goto nxagentProcessOptionsFileClose;
} }
...@@ -1652,7 +1667,7 @@ void nxagentProcessOptionsFile() ...@@ -1652,7 +1667,7 @@ void nxagentProcessOptionsFile()
if (ferror(file) != 0) if (ferror(file) != 0)
{ {
fprintf(stderr, "Warning: Error reading the option file '%s'.\n", fprintf(stderr, "Warning: Error reading the option file '%s'.\n",
validateString(nxagentOptionFile)); validateString(filename));
goto nxagentProcessOptionsFileFree; goto nxagentProcessOptionsFileFree;
} }
...@@ -1669,7 +1684,7 @@ void nxagentProcessOptionsFile() ...@@ -1669,7 +1684,7 @@ void nxagentProcessOptionsFile()
if (size != sizeOfFile) if (size != sizeOfFile)
{ {
fprintf(stderr, "Warning: Premature end of option file '%s' while reading.\n", fprintf(stderr, "Warning: Premature end of option file '%s' while reading.\n",
validateString(nxagentOptionFile)); validateString(filename));
goto nxagentProcessOptionsFileFree; goto nxagentProcessOptionsFileFree;
} }
...@@ -1696,7 +1711,7 @@ nxagentProcessOptionsFileClose: ...@@ -1696,7 +1711,7 @@ nxagentProcessOptionsFileClose:
if (fclose(file) != 0) if (fclose(file) != 0)
{ {
fprintf(stderr, "Warning: Couldn't close option file '%s'. Error is '%s'.\n", fprintf(stderr, "Warning: Couldn't close option file '%s'. Error is '%s'.\n",
validateString(nxagentOptionFile), strerror(errno)); validateString(filename), strerror(errno));
} }
nxagentProcessOptionsFileExit: nxagentProcessOptionsFileExit:
......
...@@ -81,7 +81,7 @@ extern Bool nxagentIpaq; ...@@ -81,7 +81,7 @@ extern Bool nxagentIpaq;
extern int nxagentLockDeferLevel; extern int nxagentLockDeferLevel;
Bool nxagentPostProcessArgs(char *name, Display *dpy, Screen *scr); Bool nxagentPostProcessArgs(char *name, Display *dpy, Screen *scr);
void nxagentProcessOptionsFile(void); void nxagentProcessOptionsFile(char * filename);
void nxagentSetPackMethod(void); void nxagentSetPackMethod(void);
void nxagentSetDeferLevel(void); void nxagentSetDeferLevel(void);
......
...@@ -103,6 +103,8 @@ extern Bool nxagentRenderEnable; ...@@ -103,6 +103,8 @@ extern Bool nxagentRenderEnable;
extern char *nxagentKeyboard; extern char *nxagentKeyboard;
extern char *nxagentOptionsFilename;
enum SESSION_STATE nxagentSessionState = SESSION_STARTING; enum SESSION_STATE nxagentSessionState = SESSION_STARTING;
struct nxagentExceptionStruct nxagentException = {0, 0}; struct nxagentExceptionStruct nxagentException = {0, 0};
...@@ -454,7 +456,7 @@ Bool nxagentReconnectSession(void) ...@@ -454,7 +456,7 @@ Bool nxagentReconnectSession(void)
nxagentResetOptions(); nxagentResetOptions();
nxagentProcessOptionsFile(); nxagentProcessOptionsFile(nxagentOptionsFilename);
if (nxagentReconnectDisplay(reconnectLossyLevel[DISPLAY_STEP]) == 0) if (nxagentReconnectDisplay(reconnectLossyLevel[DISPLAY_STEP]) == 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