traversity/traversity

099f256aa59a
Implement traversity_core_get_local_ips for UNIX systems

This is basically an import from the original code in purple2 with some clean
ups.

Testing Done:
ran traversity-test on Debian Bookworm AMD64, OpenBSD 7.1 64bit, Freebsd 13.1 32bit, macOS Monterey 64bit, and Haiku OS (not sure version/arch).

I also force the ioctl path on all of them, Haiku only uses the ioctl path, but OpenBSD does not support the ioctl path.

Reviewed at https://reviews.imfreedom.org/r/1963/
project('libtraversity', 'C',
license : 'LGPL-2.0-or-later',
version : '0.0.1',
meson_version : '>=0.63.0',
default_options : ['c_std=c99', 'warning_level=2'])
###############################################################################
# Version Stuff
###############################################################################
traversity_soversion = 0
parts = meson.project_version().split('-')
if parts.length() > 1
traversity_extra_version = parts[1]
else
traversity_extra_version = ''
endif
parts = parts[0].split('.')
traversity_major_version = parts[0]
traversity_minor_version = parts[1]
traversity_micro_version = parts[2]
LIBTRAVERSITY_VERSION = '@0@.@1@.@2@'.format(traversity_soversion,
traversity_minor_version,
traversity_micro_version)
conf = configuration_data()
conf.set_quoted('PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('DISPLAY_VERSION', meson.project_version())
version_conf = configuration_data()
version_conf.set('TRAVERSITY_MAJOR_VERSION', traversity_major_version)
version_conf.set('TRAVERSITY_MINOR_VERSION', traversity_minor_version)
version_conf.set('TRAVERSITY_MICRO_VERSION', traversity_micro_version)
version_conf.set('TRAVERSITY_EXTRA_VERSION', traversity_extra_version)
version_conf.set('TRAVERSITY_VERSION', meson.project_version())
version_conf.set('TRAVERSITY_API_VERSION', traversity_soversion)
###############################################################################
# Module imports
###############################################################################
gnome = import('gnome')
pkgconfig = import('pkgconfig')
###############################################################################
# Basic Variables
###############################################################################
toplevel_inc = include_directories('.')
###############################################################################
# Main Dependencies
###############################################################################
GLIB = dependency('glib-2.0', version : '>=2.70.0')
add_project_arguments(
'-D_GNU_SOURCE',
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_70',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_70',
'-DHAVE_CONFIG_H=1',
language : 'c',
)
GOBJECT = dependency('gobject-2.0', version : '>=2.70.0')
TEMPLATE_GLIB = dependency('template-glib-1.0', version : '>=3.30.0')
###############################################################################
# compile features
###############################################################################
cc = meson.get_compiler('c')
conf.set('HAVE_GETIFADDRS', cc.has_function('getifaddrs'))
conf.set('HAVE_INET_NTOP', cc.has_function('inet_ntop'))
###############################################################################
# Documentation
###############################################################################
if get_option('doc') and not get_option('introspection')
error('Documentation requires GObject Introspection.')
endif
gidocgen_dep = dependency(
'gi-docgen', version: '>= 2021.1',
fallback: ['gi-docgen', 'dummy_dep'],
required: get_option('doc')
)
gidocgen = find_program('gi-docgen', required : get_option('doc'))
docs_dir = get_option('prefix') / get_option('datadir') / 'doc'
###############################################################################
# Subdirectories
###############################################################################
subdir('traversity')
subdir('traversity-test')
# Output our configuration file.
configure_file(output : 'config.h', configuration : conf)