Diffstat (limited to 'gammu/emb/common/device/devfunc.c') (more/less context) (show 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,24 +1,32 @@ +/* Some source from Gnokii (www.gnokii.org) + * (C) 1999-2000 Hugh Blemings & Pavel Janik ml. (C) 2001-2004 Pawel Kot + * GNU GPL version 2 or later + */ +/* Some source from Minicom (http://alioth.debian.org/projects/minicom) + * (C) 1991,1992,1993,1994,1995,1996 by Miquel van Smoorenburg + * GNU GPL version 2 + */ #include <string.h> #ifdef WIN32 # include <io.h> #else # include <errno.h> # include <signal.h> #endif #include "../gsmstate.h" #ifdef GSM_ENABLE_BLUETOOTHDEVICE #ifdef BLUETOOTH_RF_SEARCHING GSM_Error bluetooth_checkservicename(GSM_StateMachine *s, char *name) { if (s->ConnectionType == GCT_BLUEPHONET && strstr(name,"Nokia PC Suite")!=NULL) return ERR_NONE; if (s->ConnectionType == GCT_BLUEOBEX && strstr(name,"OBEX") !=NULL) return ERR_NONE; if (s->ConnectionType == GCT_BLUEAT && strstr(name,"COM 1") !=NULL) return ERR_NONE; return ERR_UNKNOWN; } #endif #endif @@ -84,49 +92,49 @@ GSM_Error socket_close(GSM_StateMachine *s, int hPhone) #ifdef ENABLE_LGPL GSM_Error lock_device(const char* port, char **lock_device) { *lock_device = 0; return ERR_NONE; } bool unlock_device(char **lock_file) { return true; } #else #define max_buf_len 128 #define lock_path "/var/lock/LCK.." /* Lock the device. Allocated string with a lock name is returned * in lock_device */ GSM_Error lock_device(const char* port, char **lock_device) { -#ifndef WIN32 +#if !defined(WIN32) && !defined(DJGPP) char *lock_file = NULL; char buffer[max_buf_len]; const char *aux; int fd, len; GSM_Error error = ERR_NONE; dbgprintf("Locking device\n"); aux = strrchr(port, '/'); /* Remove leading '/' */ if (aux) { aux++; } else { /* No / in port */ aux = port; } len = strlen(aux) + strlen(lock_path); memset(buffer, 0, sizeof(buffer)); lock_file = calloc(len + 1, 1); if (!lock_file) { dbgprintf("Out of memory error while locking device\n"); return ERR_MOREMEMORY; } @@ -197,49 +205,49 @@ GSM_Error lock_device(const char* port, char **lock_device) } else { dbgprintf("Unknown error with creating lockfile %s\n", lock_file); error = ERR_UNKNOWN; } goto failed; } sprintf(buffer, "%10ld gammu\n", (long)getpid()); write(fd, buffer, strlen(buffer)); close(fd); *lock_device = lock_file; return ERR_NONE; failed: free(lock_file); *lock_device = 0; return error; #else *lock_device = 0; return ERR_NONE; #endif } /* Removes lock and frees memory */ bool unlock_device(char **lock_file) { -#ifndef WIN32 +#if !defined(WIN32) && !defined(DJGPP) int err; if (!lock_file) { dbgprintf("Cannot unlock device\n"); return false; } err = unlink(*lock_file); free(*lock_file); *lock_file = NULL; return (err + 1); #else return true; #endif } #endif int FindSerialSpeed(char *buffer) { switch (atoi(buffer)) { case 50 : return 50; case 75 : return 75; case 110 : return 110; case 134 : return 134; |