Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: videolabs/libmicrodns
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.0
Choose a base ref
...
head repository: videolabs/libmicrodns
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 7 commits
  • 8 files changed
  • 5 contributors

Commits on May 27, 2022

  1. add GitHub CI job

    SeanMcG authored and jbkempf committed May 27, 2022
    Copy the full SHA
    e764dd9 View commit details
  2. Document strrcmp()

    So we don't need to reverse-engineer what it does from reading the code.
    The documentation and the argument names are from the Linux kernel.
    
    Closes: #42
    hadess authored and jbkempf committed May 27, 2022
    Copy the full SHA
    f6ee3b3 View commit details
  3. Simplify generation of pkgconfig file

    Use meson's pkgconfig module to generate the pkg-config file, rather
    than using old-school autotools patterns.
    hadess authored and jbkempf committed May 27, 2022
    Copy the full SHA
    28156c8 View commit details
  4. Windows: Require at least Vista

    inet_ntop() and struct pollfd are available since Windows Vista, but
    mingw requires to define _WIN32_WINNT.
    
    Fixes: #46
    xclaesse authored and jbkempf committed May 27, 2022
    Copy the full SHA
    2b4d2cf View commit details
  5. Meson: Simplify pkgconfig generator

    - pkg_cdata is unused and should have been deleted completely
    - libmicrodns should be passed as first positional argument and not in
      libraries: keyword argument.
    - deps should not be specified as public requires, they are private
      dependencies and Meson will add them automatically, no need to mention
      them.
    xclaesse authored and jbkempf committed May 27, 2022
    Copy the full SHA
    2489a7a View commit details
  6. Copy the full SHA
    1d4556e View commit details

Commits on May 23, 2023

  1. Add PIC parameter to fix builds for some platforms

    On some platforms (such as UWP), the static library must have position independent code (PIC) to be included properly in a shared library.
    Sharpe49 authored and jbkempf committed May 23, 2023
    Copy the full SHA
    8cb6b90 View commit details
Showing with 78 additions and 44 deletions.
  1. +37 −0 .github/workflows/build.yml
  2. +2 −1 compat/meson.build
  3. +1 −0 include/microdns/rr.h
  4. +4 −0 include/utils.h
  5. +20 −28 meson.build
  6. +7 −5 src/mdns.c
  7. +7 −0 src/meson.build
  8. +0 −10 src/microdns.pc.in
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
cc: clang
- os: ubuntu-latest
cc: gcc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2

- name: Install Linux dependencies
if: runner.os == 'Linux'
run: |
sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe"
sudo apt-get update -y -qq
sudo apt-get install meson ninja-build
- name: Execute build
env:
CC: ${{ matrix.cc }}
run: |
meson setup build
cd build && ninja
3 changes: 2 additions & 1 deletion compat/meson.build
Original file line number Diff line number Diff line change
@@ -8,5 +8,6 @@ libcompat = static_library('compat', libcompat_sources,
include_directories: incdirs,
dependencies: deps,
c_args: c_args,
link_args: link_flags
link_args: link_flags,
pic: true
)
1 change: 1 addition & 0 deletions include/microdns/rr.h
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@

#if defined (__unix__) || defined (__APPLE__)
# include <arpa/inet.h>
# include <netinet/in.h>
#elif defined(_WIN32)
# include <ws2tcpip.h>
#endif
4 changes: 4 additions & 0 deletions include/utils.h
Original file line number Diff line number Diff line change
@@ -31,6 +31,10 @@
#include <stdio.h>
#include <stdint.h>

#if defined (__unix__) || defined (__APPLE__)
# include <netinet/in.h>
#endif

#include "compat.h"

#define MDNS_DN_MAXSZ 256 // domain name maximum size
48 changes: 20 additions & 28 deletions meson.build
Original file line number Diff line number Diff line change
@@ -59,21 +59,35 @@ add_project_arguments(cc.get_supported_arguments(warning_flags), language: 'c')
cdata = configuration_data()

deps = []
cc_args = []

host_system = host_machine.system()

if host_system == 'windows'
deps += [cc.find_library('ws2_32')]
deps += [cc.find_library('iphlpapi')]
building_for_vista = cc.compiles('''#include <windows.h>
#ifndef WINVER
#error "unknown minimum supported OS version"
#endif
#if (WINVER < _WIN32_WINNT_VISTA)
#error "Windows Vista API is not guaranteed"
#endif
''',
name: 'building for Windows Vista')
if not building_for_vista
cc_args = [
'-D_WIN32_WINNT=_WIN32_WINNT_VISTA',
'-DWINVER=_WIN32_WINNT_VISTA',
]
add_project_arguments(cc_args, language: 'c')
endif
endif

inet_ntop_src = '''
#ifdef _WIN32
#include <ws2tcpip.h>
#include <windows.h>
# if _WIN32_WINNT < 0x600
# error Needs vista+
# endif
#else
#include <sys/socket.h>
#include <arpa/inet.h>
@@ -83,7 +97,7 @@ int main() {
}
'''

if cc.links(inet_ntop_src, dependencies: deps)
if cc.links(inet_ntop_src, dependencies: deps, args: cc_args)
cdata.set('HAVE_INET_NTOP', 1)
endif

@@ -92,9 +106,6 @@ poll_src = '''
#ifdef _WIN32
#include <winsock2.h>
#include <windows.h>
# if _WIN32_WINNT < 0x600
# error Needs vista+
# endif
# if defined(_MSC_VER)
# error
# endif
@@ -106,7 +117,7 @@ int main() {
}
'''

if cc.links(poll_src, dependencies: deps)
if cc.links(poll_src, dependencies: deps, args: cc_args)
cdata.set('HAVE_POLL', 1)
endif

@@ -118,7 +129,7 @@ elif host_system == 'windows'
pollfd_check_prefix += '#include <winsock2.h>'
endif

if cc.has_type('struct pollfd', prefix: pollfd_check_prefix)
if cc.has_type('struct pollfd', prefix: pollfd_check_prefix, args: cc_args)
cdata.set('HAVE_STRUCT_POLLFD', 1)
endif

@@ -175,25 +186,6 @@ subdir('compat')
subdir('include')
subdir('src')

pkg_cdata = configuration_data()

pkg_cdata.set('prefix', join_paths(get_option('prefix')))
pkg_cdata.set('exec_prefix', '${prefix}')
pkg_cdata.set('libdir', '${prefix}/@0@'.format(get_option('libdir')))
pkg_cdata.set('includedir', '${prefix}/@0@'.format(get_option('includedir')))
pkg_cdata.set('VERSION', mdns_version)
pkg_cdata.set('LIBSOCKET', host_system == 'windows' ? '-lws2_32 -liphlpapi': '')

pkg_install_dir = '@0@/pkgconfig'.format(get_option('libdir'))

configure_file(
input: 'src/microdns.pc.in',
output: 'microdns.pc',
configuration: pkg_cdata,
install_dir: pkg_install_dir,
install: true,
)

mdns_dep = declare_dependency(link_with : libmicrodns,
include_directories : incdirs,
dependencies: deps,
12 changes: 7 additions & 5 deletions src/mdns.c
Original file line number Diff line number Diff line change
@@ -713,18 +713,20 @@ mdns_strerror(int r, char *buf, size_t n)
return os_strerror(r, buf, n);
}

/* Test if string s ends in string sub
* return 0 if match */
static int
strrcmp(const char *s1, const char *s2)
strrcmp(const char *s, const char *sub)
{
size_t m, n;

if (!s1 || !s2)
if (!s || !sub)
return (1);
m = strlen(s1);
n = strlen(s2);
m = strlen(s);
n = strlen(sub);
if (n > m)
return (1);
return (strncmp(s1 + m - n, s2, n));
return (strncmp(s + m - n, sub, n));
}

static int
7 changes: 7 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -19,3 +19,10 @@ libmicrodns = library('microdns', libmicrodns_sources,
soversion: mdns_soversion,
version: mdns_soname_version,
)

pkgconf = import('pkgconfig')
pkgconf.generate(libmicrodns,
name: 'microDNS',
description: 'mDNS simple implementation',
filebase: 'microdns',
)
10 changes: 0 additions & 10 deletions src/microdns.pc.in

This file was deleted.