1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11 #include <osl/process.h>
15 /* do we start -env: */
17 is_env_arg (rtl_uString
const *str
)
19 return !rtl_ustr_ascii_compare_WithLength (str
->buffer
, 5, "-env:");
24 unsigned int bInhibitSplash
: 1;
25 unsigned int bInhibitPagein
: 1;
26 unsigned int bInhibitJavaLdx
: 1;
27 unsigned int bInhibitPipe
: 1;
28 const char *pPageinType
;
30 /* have a trailing argument */
31 { "pt", 1, 0, 0, 0, NULL
},
32 { "p", 1, 0, 0, 0, NULL
},
33 { "display", 0, 0, 0, 0, NULL
},
36 { "nologo", 1, 0, 0, 0, NULL
},
37 { "headless", 1, 0, 0, 0, NULL
},
38 { "invisible", 1, 0, 0, 0, NULL
},
39 { "quickstart", 1, 0, 0, 0, NULL
},
40 { "minimized", 1, 0, 0, 0, NULL
},
41 { "convert-to", 1, 0, 0, 0, NULL
},
42 { "cat", 1, 0, 0, 0, NULL
},
45 { "writer", 0, 0, 0, 0, "pagein-writer" },
46 { "calc", 0, 0, 0, 0, "pagein-calc" },
47 { "draw", 0, 0, 0, 0, "pagein-draw" },
48 { "impress", 0, 0, 0, 0, "pagein-impress" },
50 /* Do not send --help/--version over the pipe, as their output shall go to
51 the calling process's stdout (ideally, this would also happen in the
52 presence of unknown options); also prevent splash/pagein/javaldx overhead
53 (as these options will be processed early in soffice_main): */
54 { "version", 1, 1, 1, 1, NULL
},
55 { "help", 1, 1, 1, 1, NULL
},
56 { "h", 1, 1, 1, 1, NULL
},
57 { "?", 1, 1, 1, 1, NULL
},
60 Args
*args_parse (void)
63 sal_uInt32 nArgs
, i
, j
;
65 nArgs
= osl_getCommandArgCount();
66 i
= sizeof (Args
) + sizeof (rtl_uString
*) * nArgs
;
69 args
->nArgsTotal
= nArgs
;
73 /* sort the -env: args to the front */
74 for ( i
= 0; i
< nArgs
; ++i
)
76 rtl_uString
*pTmp
= NULL
;
77 osl_getCommandArg( i
, &pTmp
);
78 if (is_env_arg (pTmp
))
79 args
->ppArgs
[j
++] = pTmp
;
81 rtl_uString_release (pTmp
);
85 /* Then the other args */
86 for ( i
= 0; i
< nArgs
; ++i
)
88 rtl_uString
*pTmp
= NULL
;
90 osl_getCommandArg( i
, &pTmp
);
91 if (!is_env_arg (pTmp
))
92 args
->ppArgs
[j
++] = pTmp
;
94 rtl_uString_release (pTmp
);
97 for ( i
= args
->nArgsEnv
; i
< args
->nArgsTotal
; i
++ )
99 const sal_Unicode
*arg
= args
->ppArgs
[i
]->buffer
;
100 sal_Int32 length
= args
->ppArgs
[i
]->length
;
102 /* grok only parameters */
106 while (length
> 1 && arg
[0] == '-') {
111 for ( j
= 0; j
< SAL_N_ELEMENTS (pArgDescr
); ++j
) {
112 if (rtl_ustr_ascii_compare_WithLength(
113 arg
, length
, pArgDescr
[j
].name
)
116 args
->bInhibitSplash
|= pArgDescr
[j
].bInhibitSplash
;
117 args
->bInhibitPagein
|= pArgDescr
[j
].bInhibitPagein
;
118 args
->bInhibitJavaLdx
|= pArgDescr
[j
].bInhibitJavaLdx
;
119 args
->bInhibitPipe
|= pArgDescr
[j
].bInhibitPipe
;
120 if (pArgDescr
[j
].pPageinType
)
121 args
->pPageinType
= pArgDescr
[j
].pPageinType
;
131 args_free (Args
*args
)
133 /* FIXME: free ppArgs */
134 rtl_uString_release( args
->pAppPath
);
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */