[Gpredict-svn] SF.net SVN: gpredict:[71] trunk/src
Real time satellite tracking and orbit prediction
Status: Beta
Brought to you by:
csete
|
From: <cs...@us...> - 2008-08-27 20:52:25
|
Revision: 71
http://gpredict.svn.sourceforge.net/gpredict/?rev=71&view=rev
Author: csete
Date: 2008-08-27 20:52:34 +0000 (Wed, 27 Aug 2008)
Log Message:
-----------
Added field for port number. Added error handling.
Modified Paths:
--------------
trunk/src/rotor-conf.c
trunk/src/rotor-conf.h
Modified: trunk/src/rotor-conf.c
===================================================================
--- trunk/src/rotor-conf.c 2008-08-27 20:40:34 UTC (rev 70)
+++ trunk/src/rotor-conf.c 2008-08-27 20:52:34 UTC (rev 71)
@@ -36,6 +36,7 @@
#define GROUP "Rotator"
#define KEY_HOST "Host"
+#define KEY_PORT "Port"
#define KEY_MINAZ "MinAz"
#define KEY_MAXAZ "MaxAz"
#define KEY_MINEL "MinEl"
@@ -55,10 +56,15 @@
GKeyFile *cfg = NULL;
gchar *confdir;
gchar *fname;
+ GError *error = NULL;
- if (conf->name == NULL)
+ if (conf->name == NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: NULL configuration name!"),
+ __FUNCTION__);
return FALSE;
+ }
confdir = get_conf_dir();
fname = g_strconcat (confdir, G_DIR_SEPARATOR_S,
@@ -82,12 +88,66 @@
g_free (fname);
/* read parameters */
- conf->host = g_key_file_get_string (cfg, GROUP, KEY_HOST, NULL);
- conf->minaz = g_key_file_get_double (cfg, GROUP, KEY_MINAZ, NULL);
- conf->maxaz = g_key_file_get_double (cfg, GROUP, KEY_MAXAZ, NULL);
- conf->minel = g_key_file_get_double (cfg, GROUP, KEY_MINEL, NULL);
- conf->maxel = g_key_file_get_double (cfg, GROUP, KEY_MAXEL, NULL);
+ conf->host = g_key_file_get_string (cfg, GROUP, KEY_HOST, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+ conf->port = g_key_file_get_string (cfg, GROUP, KEY_PORT, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+
+ conf->minaz = g_key_file_get_double (cfg, GROUP, KEY_MINAZ, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+
+ conf->maxaz = g_key_file_get_double (cfg, GROUP, KEY_MAXAZ, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+
+ conf->minel = g_key_file_get_double (cfg, GROUP, KEY_MINEL, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+
+ conf->maxel = g_key_file_get_double (cfg, GROUP, KEY_MAXEL, &error);
+ if (error != NULL) {
+ sat_log_log (SAT_LOG_LEVEL_ERROR,
+ _("%s: Error reading rotor conf from %s (%s)."),
+ __FUNCTION__, conf->name, error->message);
+ g_clear_error (&error);
+ g_key_file_free (cfg);
+ return FALSE;
+ }
+
g_key_file_free (cfg);
return TRUE;
@@ -115,11 +175,12 @@
/* create a config structure */
cfg = g_key_file_new();
- g_key_file_set_string (cfg, GROUP, KEY_HOST, conf->host);
- g_key_file_set_double (cfg, GROUP, KEY_MINAZ, conf->minaz);
- g_key_file_set_double (cfg, GROUP, KEY_MAXAZ, conf->maxaz);
- g_key_file_set_double (cfg, GROUP, KEY_MINEL, conf->minel);
- g_key_file_set_double (cfg, GROUP, KEY_MAXEL, conf->maxel);
+ g_key_file_set_string (cfg, GROUP, KEY_HOST, conf->host);
+ g_key_file_set_integer (cfg, GROUP, KEY_HOST, conf->port);
+ g_key_file_set_double (cfg, GROUP, KEY_MINAZ, conf->minaz);
+ g_key_file_set_double (cfg, GROUP, KEY_MAXAZ, conf->maxaz);
+ g_key_file_set_double (cfg, GROUP, KEY_MINEL, conf->minel);
+ g_key_file_set_double (cfg, GROUP, KEY_MAXEL, conf->maxel);
/* convert to text sdata */
data = g_key_file_to_data (cfg, &len, NULL);
Modified: trunk/src/rotor-conf.h
===================================================================
--- trunk/src/rotor-conf.h 2008-08-27 20:40:34 UTC (rev 70)
+++ trunk/src/rotor-conf.h 2008-08-27 20:52:34 UTC (rev 71)
@@ -38,7 +38,8 @@
/** \brief Rotator configuration. */
typedef struct {
gchar *name; /*!< Configuration file name, less .rot */
- gchar *host; /*!< hostname:port */
+ gchar *host; /*!< hostname */
+ gint port; /*!< port number */
gdouble minaz; /*!< Lower azimuth limit */
gdouble maxaz; /*!< Upper azimuth limit */
gdouble minel; /*!< Lower elevation limit */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|