findsofficepath.c (8ac661e5) findsofficepath.c (89a59a52)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 115 unchanged lines hidden (view full) ---

124 * <p>An installation is found, if the executable 'soffice' or a symbolic link
125 * is in one of the directories listed in the PATH environment variable.</p>
126 *
127 * @return the installation path or NULL, if no installation was found or
128 * if an error occured
129 */
130static char* platformSpecific()
131{
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 115 unchanged lines hidden (view full) ---

124 * <p>An installation is found, if the executable 'soffice' or a symbolic link
125 * is in one of the directories listed in the PATH environment variable.</p>
126 *
127 * @return the installation path or NULL, if no installation was found or
128 * if an error occured
129 */
130static char* platformSpecific()
131{
132 const int SEPARATOR = '/';
133 const char* PATHSEPARATOR = ":";
134 const char* PATHVARNAME = "PATH";
135 const char* APPENDIX = "/soffice";
136
137 char* path = NULL;
132 char* path = NULL;
138 char* env = NULL;
139 char* str = NULL;
140 char* dir = NULL;
141 char* file = NULL;
142 char* resolved = NULL;
143 char* sep = NULL;
144
133
145 char buffer[PATH_MAX];
146 int pos;
147
148#ifdef MACOSX
149 /* On MacOS we have no soffice link under /usr/bin but the default office location is known
150 and we check this only
151 */
152 const char* MACDEFAULTOFFICEPATH = "/Applications/OpenOffice.app/Contents/MacOS";
153 const char* MACDEFAULTSOFFICE = "/Applications/OpenOffice.app/Contents/MacOS/soffice";
154
155 if ( !access( MACDEFAULTSOFFICE, F_OK ) )
156 {
157 path = (char*) malloc( strlen(MACDEFAULTOFFICEPATH) + 1 );
158 strcpy( path, MACDEFAULTOFFICEPATH);
159 }
160 return path;
161#else
134#ifdef MACOSX
135 /* On MacOS we have no soffice link under /usr/bin but the default office location is known
136 and we check this only
137 */
138 const char* MACDEFAULTOFFICEPATH = "/Applications/OpenOffice.app/Contents/MacOS";
139 const char* MACDEFAULTSOFFICE = "/Applications/OpenOffice.app/Contents/MacOS/soffice";
140
141 if ( !access( MACDEFAULTSOFFICE, F_OK ) )
142 {
143 path = (char*) malloc( strlen(MACDEFAULTOFFICEPATH) + 1 );
144 strcpy( path, MACDEFAULTOFFICEPATH);
145 }
146 return path;
147#else
148 const int SEPARATOR = '/';
149 const char* PATHSEPARATOR = ":";
150 const char* PATHVARNAME = "PATH";
151 const char* APPENDIX = "/soffice";
152
153 char* env = NULL;
154 char* str = NULL;
155 char* dir = NULL;
156 char* file = NULL;
157 char* resolved = NULL;
158 char* sep = NULL;
159
160 char buffer[PATH_MAX];
161 int pos;
162
162/* get the value of the PATH environment variable */
163 env = getenv( PATHVARNAME );
164 str = (char*) malloc( strlen( env ) + 1 );
165 strcpy( str, env );
166
167 /* get the tokens separated by ':' */
168 dir = strtok( str, PATHSEPARATOR );
169

--- 58 unchanged lines hidden ---
163/* get the value of the PATH environment variable */
164 env = getenv( PATHVARNAME );
165 str = (char*) malloc( strlen( env ) + 1 );
166 strcpy( str, env );
167
168 /* get the tokens separated by ':' */
169 dir = strtok( str, PATHSEPARATOR );
170

--- 58 unchanged lines hidden ---