1 /* This program is free software; you can redistribute it and/or modify
2 * it under the terms of the GNU General Public License as published by
3 * the Free Software Foundation; either version 2 of the License, or
4 * (at your option) any later version.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 * GNU General Public License for more details.
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 * Copyright (c) 2010 - 2011 Michal Cihar <michal@cihar.com>
19 #include <glib-object.h>
26 #include <gammu.h> /* For PRINTF_STYLE and locales */
27 #include "../helper/locales.h" /* For gettext */
39 #include "win32-serial.h"
50 gint no_win32_serial
= 0;
52 gint show_version
= 0;
54 static GOptionEntry entries
[] = {
55 {"debug", 'd', 0, G_OPTION_ARG_NONE
, &debug
, N_("Show debugging output for detecting devices."), NULL
},
56 {"version", 'v', 0, G_OPTION_ARG_NONE
, &show_version
, N_("Show version information and compiled in features."), NULL
},
58 {"no-udev", 'u', 0, G_OPTION_ARG_NONE
, &no_udev
, N_("Disables scanning of udev."), NULL
},
61 {"no-bluez", 'b', 0, G_OPTION_ARG_NONE
, &no_bluez
, N_("Disables scanning using Bluez."), NULL
},
64 {"no-win32-serial", 'w', 0, G_OPTION_ARG_NONE
, &no_win32_serial
, N_("Disables scanning of Windows serial ports."), NULL
},
66 {NULL
, 0, 0, G_OPTION_ARG_NONE
, NULL
, "", NULL
}
69 void print_version(void)
71 printf(_("Gammu-detect version %s"), GAMMU_VERSION
);
73 printf(_("Built %s on %s using %s"), __TIME__
, __DATE__
, GetCompiler());
76 printf("%s\n", _("Compiled in features:"));
78 printf(" - %s\n", _("udev probing"));
81 printf(" - %s\n", _("Bluez probing"));
84 printf(" - %s\n", _("Windows serial port probing"));
87 printf("%s\n", _("Copyright (C) 2010 - 2011 Michal Cihar <michal@cihar.com> and other authors."));
89 printf("%s\n", _("License GPLv2: GNU GPL version 2 <http://creativecommons.org/licenses/GPL/2.0/>."));
90 printf("%s\n", _("This is free software: you are free to change and redistribute it."));
91 printf("%s\n", _("There is NO WARRANTY, to the extent permitted by law."));
93 printf("%s\n", _("Check <http://wammu.eu/gammu/> for updates."));
97 void print_config(const gchar
*device
, const gchar
*name
, const gchar
*connection
)
99 static gint section
= 0;
102 g_print("; %s\n", _("Configuration file generated by gammu-detect."));
103 g_print("; %s\n", _("Please check The Gammu Manual for more information."));
105 g_print("[gammu]\n");
107 g_print("[gammu%d]\n", section
);
112 g_print("device = %s\n", device
);
114 g_print("name = %s\n", name
);
116 if (connection
!= NULL
) {
117 g_print("connection = %s\n", connection
);
122 int main(int argc
, char *argv
[])
124 GError
*error
= NULL
;
126 INI_Section
*cfg
= NULL
;
127 char *locales_path
= NULL
;
129 GOptionContext
*context
;
131 gerror
= GSM_FindGammuRC(&cfg
, NULL
);
132 if (gerror
== ERR_NONE
) {
133 locales_path
= INI_GetValue(cfg
, "gammu", "gammuloc", FALSE
);
137 GSM_InitLocales(locales_path
);
138 #ifdef LIBINTL_LIB_FOUND
139 if (locales_path
!= NULL
) {
140 bindtextdomain("gammu", locales_path
);
142 #if defined(LOCALE_PATH)
143 bindtextdomain("gammu", LOCALE_PATH
);
145 bindtextdomain("gammu", ".");
157 context
= g_option_context_new("");
158 g_option_context_add_main_entries(context
, entries
, "gammu");
159 if (!g_option_context_parse(context
, &argc
, &argv
, &error
)) {
160 g_printerr(_("option parsing failed: %s\n"), error
->message
);
180 if (!no_win32_serial
) {
181 win32_serial_detect();
188 /* How should editor hadle tabs in this file? Add editor commands here.
189 * vim: noexpandtab sw=8 ts=8 sts=8: