Coverage Report

Created: 2026-02-26 07:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/rauc/subprojects/glib-2.76.5/gio/gnetworking.c
Line
Count
Source
1
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2
3
/* GIO - GLib Input, Output and Streaming Library
4
 *
5
 * Copyright (C) 2011 Red Hat, Inc.
6
 *
7
 * SPDX-License-Identifier: LGPL-2.1-or-later
8
 *
9
 * This library is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public
11
 * License as published by the Free Software Foundation; either
12
 * version 2.1 of the License, or (at your option) any later version.
13
 *
14
 * This library is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
 * Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General
20
 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#include "config.h"
24
25
#include "gnetworking.h"
26
27
/**
28
 * SECTION:gnetworking
29
 * @title: gnetworking.h
30
 * @short_description: System networking includes
31
 * @include: gio/gnetworking.h
32
 *
33
 * The `<gio/gnetworking.h>` header can be included to get
34
 * various low-level networking-related system headers, automatically
35
 * taking care of certain portability issues for you.
36
 *
37
 * This can be used, for example, if you want to call setsockopt()
38
 * on a #GSocket.
39
 *
40
 * Note that while WinSock has many of the same APIs as the
41
 * traditional UNIX socket API, most of them behave at least slightly
42
 * differently (particularly with respect to error handling). If you
43
 * want your code to work under both UNIX and Windows, you will need
44
 * to take these differences into account.
45
 *
46
 * Also, under GNU libc, certain non-portable functions are only visible
47
 * in the headers if you define %_GNU_SOURCE before including them. Note
48
 * that this symbol must be defined before including any headers, or it
49
 * may not take effect.
50
 */
51
52
/**
53
 * g_networking_init:
54
 *
55
 * Initializes the platform networking libraries (eg, on Windows, this
56
 * calls WSAStartup()). GLib will call this itself if it is needed, so
57
 * you only need to call it if you directly call system networking
58
 * functions (without calling any GLib networking functions first).
59
 *
60
 * Since: 2.36
61
 */
62
void
63
g_networking_init (void)
64
0
{
65
#ifdef G_OS_WIN32
66
  static gsize inited = 0;
67
68
  if (g_once_init_enter (&inited))
69
    {
70
      WSADATA wsadata;
71
72
      if (WSAStartup (MAKEWORD (2, 0), &wsadata) != 0)
73
        g_error ("Windows Sockets could not be initialized");
74
75
      g_once_init_leave (&inited, 1);
76
    }
77
#endif
78
0
}