Inviato da daniele il Dom, 2006-10-29 10:59

The ./configure script automatically enables those connection types for which it can find the needed libraries and/or include files, but up to version 0.6.14 the config file parse routines wouldn't know which connection types were actually compiled.

These are all the connection types known to libgnokii (all names must be lowercase in gnokiirc):

  • bluetooth *
  • dau9p
  • dku2
  • dku2libusb *
  • dku5
  • dlr3p
  • infrared *
  • irda *
  • m2bus
  • serial
  • tcp **
  • tekram

* automatically enabled at configure time if all dependencies are satisfied
** not available on WIN32 builds

If you have written a program using libgnokii and you wish to know if a given connection is available you can use gn_get_connectiontype(), or you can use gn_lib_get_supported_connection() to get all supported connection types.
Note: this works with libgnokii version 0.6.15 or later.

I've written a small program to be used in scripts to check if a given connection is available.

Example:

conn=bluetooth; get_supported_connection $conn || echo "Sorry $conn is not compiled in your libgnokii"

C source follows:

/*

  $Id:$

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

  Copyright (c) 2006 by Daniele Forsi

  This prints a list of all connections supported by the currently installed libgnokii
  or checks if a given connection is supported (libgnokii later than 0.6.14).

  Compile and test:
  gcc get_supported_connection.c -o get_supported_connection $(pkg-config --libs gnokii)
  conn=bluetooth; get_supported_connection $conn || echo "Sorry $conn is not compiled in your libgnokii"

*/

#include 

#include "gnokii.h"

int main(int argc, char *argv[]) {
	int i;
	const char *conn;

	if (argc == 2) {
		if (!strcmp(argv[1], "-l")) {
			for (i = 0; ; i++) {
				conn = gn_lib_get_supported_connection(i);
				if (!conn) break;
				printf("%s\n", conn);
			}
		} else {
			if (gn_get_connectiontype(argv[1]) == GN_CT_NONE) return 1;
		}
	} else {
		printf("Usage: %s -l|conn\n  -l    list all supported connection types\n  conn  connection type to search\n", argv[0]);
		return 1;
	}

	return 0;
}