1 /* Panorama_Tools - Generate, Edit and Convert Panoramic Images
2 Copyright (C) 1998,1999 - Helmut Dersch der@fh-furtwangen.de
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this software; see the file COPYING. If not, a copy
16 can be downloaded from http://www.gnu.org/licenses/gpl.html, or
17 obtained by writing to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
19
20
21 #include "sys_compat.h"
22 #include "filter.h"
23 #include <assert.h>
24
25 // Return the base filename of current executable
26
panoBasenameOfExecutable(void)27 char *panoBasenameOfExecutable(void)
28 {
29
30 // Make it static so we don't have to worry about allocating storage
31 // and to make it compatible with what linux does
32 // I presume this is reeentrant safe
33 static char AppNamePath[MAX_PATH_LENGTH] = "";
34 static char *name = NULL;
35
36 if (name == NULL) {
37 // Only do it if we haven't yet
38 // to make it reentrant
39 GetModuleFileName( NULL, AppNamePath, MAX_PATH_LENGTH );
40
41 // Remove extension
42 name = strrchr( AppNamePath, '.' );
43 if( name != NULL )
44 *name = '\0';
45
46 // Search for directory separator
47 name = strrchr( AppNamePath, PATH_SEP );
48 if( name != NULL )
49 name++;
50 else
51 // No directory, use name
52 name = AppNamePath;
53 }
54 return name;
55 }
56
57 #ifdef _MSC_VER
panoTimeToStrWithTimeZone(char * sTime,int len,struct tm * time)58 int panoTimeToStrWithTimeZone(char *sTime, int len, struct tm *time)
59 {
60 char sZone[20];
61 long lZone = 0;
62
63 assert(len > 11); // This function needs at least 11 characters + null
64 // %z or %Z in strftime produces a name of the time zone not a numeric value.
65 if (strftime(sTime, len, "%H%M%S", time) != 0) {
66 _get_timezone(&lZone);
67 sprintf(sZone, "%+03d%02d", -lZone/60/60, lZone/60%60);
68 strncat(sTime, sZone, len-1); // Copy at most len -1
69 // so we can force the end character to be null
70 sTime[len-1] = 0;
71 return 1;
72 } else
73 return 0;
74 }
75 #else
76 #ifdef __MINGW32__
panoTimeToStrWithTimeZone(char * sTime,int len,struct tm * time)77 int panoTimeToStrWithTimeZone(char *sTime, int len, struct tm *time)
78 {
79 assert(len >= 11);
80 return strftime(sTime, len, "%H%M%S%z", time);
81
82 }
83 #endif
84 #endif
85