@@ -57,125 +57,135 @@ Updated driver to use INDI::Telescope (JM)
5757 ** device afterwards. If the binary name does not match any known devices,
5858 ** we simply create a generic device.
5959 */
60+
61+ #ifdef __APPLE__
62+ // getprogname() is a BSD/Darwin function present in the runtime but hidden from
63+ // <stdlib.h> when _POSIX_C_SOURCE or _XOPEN_SOURCE are defined. Forward-declare it
64+ // explicitly to bypass the header visibility guard.
65+ extern " C" const char *getprogname (void );
66+ #endif
67+
68+ static const char *getProgName ()
69+ {
6070#ifdef __APPLE__
61- #include < stdlib.h>
62- #define PROGNAME getprogname ()
71+ return getprogname ();
6372#else
6473 extern char *__progname;
65- # define PROGNAME __progname
74+ return __progname;
6675#endif
76+ }
6777
6878#define LX200_TRACK 0
6979#define LX200_SYNC 1
7080
71- static class Loader
72- {
73- std::unique_ptr<LX200Generic> telescope;
74- public:
75- Loader ()
76- {
77- // Note: these if statements use strstr() which isn't a full string match, just a substring,
78- // so if one driver name is the start of another's name, it needs to be AFTER the longer one!
79- if (strstr (PROGNAME , " indi_lx200classic" ))
80- {
81- IDLog (" initializing from LX200 classic device...\n " );
82- telescope.reset (new LX200Classic ());
83- }
84- else if (strstr (PROGNAME , " indi_lx200_OnStep" ))
85- {
86- IDLog (" initializing from LX200 OnStep device...\n " );
87- telescope.reset (new LX200_OnStep ());
88- }
89- else if (strstr (PROGNAME , " indi_lx200gps" ))
90- {
91- IDLog (" initializing from LX200 GPS device...\n " );
92- telescope.reset (new LX200GPS ());
93- }
94- else if (strstr (PROGNAME , " indi_lx200_16" ))
95- {
96- IDLog (" Initializing from LX200 16 device...\n " );
97- telescope.reset (new LX200_16 ());
98- }
99- else if (strstr (PROGNAME , " indi_lx200autostar" ))
100- {
101- IDLog (" initializing from Autostar device...\n " );
102- telescope.reset (new LX200Autostar ());
103- }
104- else if (strstr (PROGNAME , " indi_lx200ap_v2" ))
105- {
106- IDLog (" initializing from Astrophysics V2 device...\n " );
107- telescope.reset (new LX200AstroPhysicsV2 ());
108- }
109- else if (strstr (PROGNAME , " indi_lx200ap_legacy" ))
110- {
111- IDLog (" initializing from Astrophysics GTOCP2 device...\n " );
112- telescope.reset (new LX200AstroPhysicsGTOCP2 ());
113- }
114- else if (strstr (PROGNAME , " indi_lx200gemini" ))
115- {
116- IDLog (" initializing from Losmandy Gemini device...\n " );
117- telescope.reset (new LX200Gemini ());
118- }
119- else if (strstr (PROGNAME , " indi_lx200zeq25" ))
120- {
121- IDLog (" initializing from ZEQ25 device...\n " );
122- telescope.reset (new LX200ZEQ25 ());
123- }
124- else if (strstr (PROGNAME , " indi_lx200gotonova" ))
125- {
126- IDLog (" initializing from GotoNova device...\n " );
127- telescope.reset (new LX200GotoNova ());
128- }
129- else if (strstr (PROGNAME , " indi_ioptronHC8406" ))
130- {
131- IDLog (" initializing from ioptron telescope Hand Controller HC8406 device...\n " );
132- telescope.reset (new ioptronHC8406 ());
133- }
134- else if (strstr (PROGNAME , " indi_lx200pulsar2" ))
135- {
136- IDLog (" initializing from pulsar2 device...\n " );
137- telescope.reset (new LX200Pulsar2 ());
138- }
139- else if (strstr (PROGNAME , " indi_lx200ss2000pc" ))
140- {
141- IDLog (" initializing from skysensor2000pc device...\n " );
142- telescope.reset (new LX200SS2000PC ());
143- }
144- else if (strstr (PROGNAME , " indi_lx200fs2" ))
145- {
146- IDLog (" initializing from Astro-Electronic FS-2...\n " );
147- telescope.reset (new LX200FS2 ());
148- }
149- else if (strstr (PROGNAME , " indi_lx200_10micron" ))
150- {
151- IDLog (" initializing for 10Micron mount...\n " );
152- telescope.reset (new LX200_10MICRON ());
153- }
154- else if (strstr (PROGNAME , " indi_eq500x" ))
155- {
156- IDLog (" initializing for EQ500X mount...\n " );
157- telescope.reset (new EQ500X ());
158- }
159- else if (strstr (PROGNAME , " indi_lx200am5" ))
160- {
161- IDLog (" initializing for ZWO AM5 mount...\n " );
162- telescope.reset (new LX200AM5 ());
163- }
164- else if (strstr (PROGNAME , " indi_lx200_OpenAstroTech" ))
165- {
166- IDLog (" initializing for OpenAstroTech mount...\n " );
167- telescope.reset (new LX200_OpenAstroTech ());
168- }
169- else if (strstr (PROGNAME , " indi_lx200_pegasus_nyx101" ))
170- {
171- IDLog (" initializing for Pegasus NYX-101 mount...\n " );
172- telescope.reset (new LX200NYX101 ());
173- }
174- // be nice and give them a generic device
175- else
176- telescope.reset (new LX200Generic ());
177- }
178- } loader;
81+ static class Loader
82+ {
83+ std::unique_ptr<LX200Generic> telescope;
84+ public:
85+ Loader ()
86+ {
87+ // Note: these if statements use strstr() which isn't a full string match, just a substring,
88+ // so if one driver name is the start of another's name, it needs to be AFTER the longer one!
89+ if (strstr (getProgName () , " indi_lx200classic" ))
90+ {
91+ IDLog (" initializing from LX200 classic device...\n " );
92+ telescope.reset (new LX200Classic ());
93+ }
94+ else if (strstr (getProgName () , " indi_lx200_OnStep" ))
95+ {
96+ IDLog (" initializing from LX200 OnStep device...\n " );
97+ telescope.reset (new LX200_OnStep ());
98+ }
99+ else if (strstr (getProgName () , " indi_lx200gps" ))
100+ {
101+ IDLog (" initializing from LX200 GPS device...\n " );
102+ telescope.reset (new LX200GPS ());
103+ }
104+ else if (strstr (getProgName () , " indi_lx200_16" ))
105+ {
106+ IDLog (" Initializing from LX200 16 device...\n " );
107+ telescope.reset (new LX200_16 ());
108+ }
109+ else if (strstr (getProgName () , " indi_lx200autostar" ))
110+ {
111+ IDLog (" initializing from Autostar device...\n " );
112+ telescope.reset (new LX200Autostar ());
113+ }
114+ else if (strstr (getProgName () , " indi_lx200ap_v2" ))
115+ {
116+ IDLog (" initializing from Astrophysics V2 device...\n " );
117+ telescope.reset (new LX200AstroPhysicsV2 ());
118+ }
119+ else if (strstr (getProgName () , " indi_lx200ap_legacy" ))
120+ {
121+ IDLog (" initializing from Astrophysics GTOCP2 device...\n " );
122+ telescope.reset (new LX200AstroPhysicsGTOCP2 ());
123+ }
124+ else if (strstr (getProgName () , " indi_lx200gemini" ))
125+ {
126+ IDLog (" initializing from Losmandy Gemini device...\n " );
127+ telescope.reset (new LX200Gemini ());
128+ }
129+ else if (strstr (getProgName () , " indi_lx200zeq25" ))
130+ {
131+ IDLog (" initializing from ZEQ25 device...\n " );
132+ telescope.reset (new LX200ZEQ25 ());
133+ }
134+ else if (strstr (getProgName () , " indi_lx200gotonova" ))
135+ {
136+ IDLog (" initializing from GotoNova device...\n " );
137+ telescope.reset (new LX200GotoNova ());
138+ }
139+ else if (strstr (getProgName () , " indi_ioptronHC8406" ))
140+ {
141+ IDLog (" initializing from ioptron telescope Hand Controller HC8406 device...\n " );
142+ telescope.reset (new ioptronHC8406 ());
143+ }
144+ else if (strstr (getProgName () , " indi_lx200pulsar2" ))
145+ {
146+ IDLog (" initializing from pulsar2 device...\n " );
147+ telescope.reset (new LX200Pulsar2 ());
148+ }
149+ else if (strstr (getProgName () , " indi_lx200ss2000pc" ))
150+ {
151+ IDLog (" initializing from skysensor2000pc device...\n " );
152+ telescope.reset (new LX200SS2000PC ());
153+ }
154+ else if (strstr (getProgName () , " indi_lx200fs2" ))
155+ {
156+ IDLog (" initializing from Astro-Electronic FS-2...\n " );
157+ telescope.reset (new LX200FS2 ());
158+ }
159+ else if (strstr (getProgName () , " indi_lx200_10micron" ))
160+ {
161+ IDLog (" initializing for 10Micron mount...\n " );
162+ telescope.reset (new LX200_10MICRON ());
163+ }
164+ else if (strstr (getProgName () , " indi_eq500x" ))
165+ {
166+ IDLog (" initializing for EQ500X mount...\n " );
167+ telescope.reset (new EQ500X ());
168+ }
169+ else if (strstr (getProgName () , " indi_lx200am5" ))
170+ {
171+ IDLog (" initializing for ZWO AM5 mount...\n " );
172+ telescope.reset (new LX200AM5 ());
173+ }
174+ else if (strstr (getProgName () , " indi_lx200_OpenAstroTech" ))
175+ {
176+ IDLog (" initializing for OpenAstroTech mount...\n " );
177+ telescope.reset (new LX200_OpenAstroTech ());
178+ }
179+ else if (strstr (getProgName () , " indi_lx200_pegasus_nyx101" ))
180+ {
181+ IDLog (" initializing for Pegasus NYX-101 mount...\n " );
182+ telescope.reset (new LX200NYX101 ());
183+ }
184+ // be nice and give them a generic device
185+ else
186+ telescope.reset (new LX200Generic ());
187+ }
188+ } loader;
179189
180190/* *************************************************
181191*** LX200 Generic Implementation
0 commit comments