*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
g_free(option);
}
+static gboolean compare_short_option(gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ LttvOption *option = value;
+ const char short_option = *(const char *)user_data;
+
+
+ if(option->char_name == short_option) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
void lttv_option_add(const char *long_name, const char char_name,
const char *description, const char *arg_description,
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Add option %s", long_name);
if(g_hash_table_lookup(options, long_name) != NULL) {
- g_warning("duplicate option");
+ g_warning("duplicate long-option: %s", long_name);
return;
}
+ if(char_name && g_hash_table_find(options, compare_short_option, (gpointer)&char_name) != NULL) {
+ g_warning("duplicate short-option: %c for option %s",
+ char_name,
+ long_name);
+ return;
+ }
+
option = g_new(LttvOption, 1);
option->long_name = g_strdup(long_name);