Diffstat (limited to 'gammu/emb/common/device/devfunc.c') (more/less context) (ignore whitespace changes)
-rw-r--r-- | gammu/emb/common/device/devfunc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/gammu/emb/common/device/devfunc.c b/gammu/emb/common/device/devfunc.c index d31ebbf..c58a01f 100644 --- a/gammu/emb/common/device/devfunc.c +++ b/gammu/emb/common/device/devfunc.c | |||
@@ -1,12 +1,20 @@ | |||
1 | /* Some source from Gnokii (www.gnokii.org) | ||
2 | * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot | ||
3 | * GNU GPL version 2 or later | ||
4 | */ | ||
5 | /* Some source from Minicom (http://alioth.debian.org/projects/minicom) | ||
6 | * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg | ||
7 | * GNU GPL version 2 | ||
8 | */ | ||
1 | 9 | ||
2 | #include <string.h> | 10 | #include <string.h> |
3 | #ifdef WIN32 | 11 | #ifdef WIN32 |
4 | # include <io.h> | 12 | # include <io.h> |
5 | #else | 13 | #else |
6 | # include <errno.h> | 14 | # include <errno.h> |
7 | # include <signal.h> | 15 | # include <signal.h> |
8 | #endif | 16 | #endif |
9 | 17 | ||
10 | #include "../gsmstate.h" | 18 | #include "../gsmstate.h" |
11 | 19 | ||
12 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE | 20 | #ifdef GSM_ENABLE_BLUETOOTHDEVICE |
@@ -96,25 +104,25 @@ bool unlock_device(char **lock_file) | |||
96 | } | 104 | } |
97 | 105 | ||
98 | #else | 106 | #else |
99 | 107 | ||
100 | #define max_buf_len 128 | 108 | #define max_buf_len 128 |
101 | #define lock_path "/var/lock/LCK.." | 109 | #define lock_path "/var/lock/LCK.." |
102 | 110 | ||
103 | /* Lock the device. Allocated string with a lock name is returned | 111 | /* Lock the device. Allocated string with a lock name is returned |
104 | * in lock_device | 112 | * in lock_device |
105 | */ | 113 | */ |
106 | GSM_Error lock_device(const char* port, char **lock_device) | 114 | GSM_Error lock_device(const char* port, char **lock_device) |
107 | { | 115 | { |
108 | #ifndef WIN32 | 116 | #if !defined(WIN32) && !defined(DJGPP) |
109 | char *lock_file = NULL; | 117 | char *lock_file = NULL; |
110 | char buffer[max_buf_len]; | 118 | char buffer[max_buf_len]; |
111 | const char *aux; | 119 | const char *aux; |
112 | int fd, len; | 120 | int fd, len; |
113 | GSM_Errorerror = ERR_NONE; | 121 | GSM_Errorerror = ERR_NONE; |
114 | 122 | ||
115 | dbgprintf("Locking device\n"); | 123 | dbgprintf("Locking device\n"); |
116 | 124 | ||
117 | aux = strrchr(port, '/'); | 125 | aux = strrchr(port, '/'); |
118 | /* Remove leading '/' */ | 126 | /* Remove leading '/' */ |
119 | if (aux) { | 127 | if (aux) { |
120 | aux++; | 128 | aux++; |
@@ -209,25 +217,25 @@ failed: | |||
209 | free(lock_file); | 217 | free(lock_file); |
210 | *lock_device = 0; | 218 | *lock_device = 0; |
211 | return error; | 219 | return error; |
212 | #else | 220 | #else |
213 | *lock_device = 0; | 221 | *lock_device = 0; |
214 | return ERR_NONE; | 222 | return ERR_NONE; |
215 | #endif | 223 | #endif |
216 | } | 224 | } |
217 | 225 | ||
218 | /* Removes lock and frees memory */ | 226 | /* Removes lock and frees memory */ |
219 | bool unlock_device(char **lock_file) | 227 | bool unlock_device(char **lock_file) |
220 | { | 228 | { |
221 | #ifndef WIN32 | 229 | #if !defined(WIN32) && !defined(DJGPP) |
222 | int err; | 230 | int err; |
223 | 231 | ||
224 | if (!lock_file) { | 232 | if (!lock_file) { |
225 | dbgprintf("Cannot unlock device\n"); | 233 | dbgprintf("Cannot unlock device\n"); |
226 | return false; | 234 | return false; |
227 | } | 235 | } |
228 | err = unlink(*lock_file); | 236 | err = unlink(*lock_file); |
229 | free(*lock_file); | 237 | free(*lock_file); |
230 | *lock_file = NULL; | 238 | *lock_file = NULL; |
231 | return (err + 1); | 239 | return (err + 1); |
232 | #else | 240 | #else |
233 | return true; | 241 | return true; |