summaryrefslogtreecommitdiff
path: root/net/iaxmodem/files/patch-iaxmodem.c
blob: 5e3485bd021ac7d148f1f310122cbabeccdd9347 (plain) (blame)
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
63
64
65
66
67
68
--- iaxmodem.c.orig	2007-10-06 12:22:04.000000000 -0400
+++ iaxmodem.c	2007-11-06 23:54:40.000000000 -0500
@@ -21,17 +21,18 @@
 #include <string.h>
 #include <strings.h>
 
-#ifndef __OpenBSD__
+#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
 # ifndef USE_UNIX98_PTY
 #  include <pty.h>
 # endif /* !USE_UNIX98_PTY */
 #else
+#include <termios.h>
+#if !defined(__FreeBSD__)
 # include <util.h>
 #endif
+#endif
 
 
-#include <termios.h>
-
 #include <stdlib.h>
 #include <unistd.h>
 #include <dirent.h>
@@ -53,6 +54,26 @@
 #include <math.h>
 
 #include <stdint.h>
+
+#ifdef __FreeBSD__
+#include <libutil.h>
+char* strndup(const char* string, size_t n)
+{
+        char* copy_string = 0;
+
+        if(0 == string || 0 == n)
+                return 0;
+
+        copy_string = (char*) malloc(n + 1);
+        if(0 == copy_string)
+                return 0;
+
+        memcpy(copy_string, string, n);
+        *(copy_string + n) = '\0';
+
+        return copy_string;
+}
+#endif
 #include <tiffio.h>
 
 #ifndef O_LARGEFILE
@@ -1645,8 +1666,6 @@
 	}
       }
 
-    closedir(cfdir);
-
     if (pid == 0) {
       /* Start the modem */
       iaxmodem(config, 0);
@@ -1654,6 +1673,8 @@
       return 1;
     }
 
+    closedir(cfdir);
+
     return 0;
 }