summaryrefslogtreecommitdiff
path: root/support/dktools/dk4socka06.c
blob: b910e3355e031ec6f8e9be134dfda65a3538bf60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Copyright (C) 2015-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/

/*
	WARNING: This file was generated by the dkct program (see
	http://dktools.sourceforge.net/ for details).
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: dk4socka06.ctr
*/

/**	@file dk4socka06.c The dk4socka06 module.
*/


#line 10 "dk4socka06.ctr"


#include "dk4conf.h"
#include "dk4socka.h"
#include "dk4mem.h"





#line 19 "dk4socka06.ctr"



int
dk4socket_connect_app(
  dk4_socket_t		 sock,
  const struct sockaddr	*pAddr,
  size_t		 szAddr,
  dk4_app_t		*app
)
{
  dkChar	 buf[128];
  dk4_er_t	 er;
  const size_t	 szbuf	= DK4_SIZEOF(buf,dkChar);
  int		 back	= DK4_SOCKET_RESULT_FAILED;
  int		 res	= 0;
  dk4error_init(&er);
  back = dk4socket_connect(sock, pAddr, szAddr, &er);
  if (DK4_SOCKET_RESULT_SUCCESS != back) {
    if (0 != dk4app_log_do(app, DK4_LL_ERROR)) {
      res = dk4socket_addr_port_to_text(
        buf, szbuf, pAddr->sa_family, pAddr, szAddr, NULL
      );
      if (DK4_SOCKET_RESULT_SUCCESS == res) {
        dk4socket_log_simple_3(app, DK4_LL_ERROR, 131, 132, buf, &er);
      } else {
        dk4socket_log_simple_1(app, DK4_LL_ERROR, 7, &er);
      }
    }
  }
  return back;
}