diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:23 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-14 16:49:23 +0000 |
commit | ac8c3cf394fb9d0eb57332ea7b2d12fb3c4a396d (patch) | |
tree | 02cb7504dab187ebcae1e7fbb0b002225dda2a73 /lock.c | |
parent | c8ddd5d82a72167de6e0a544b55f9b03ab93053e (diff) |
XFree86 4.3.0.1xf86-4_3_0_1PRE_xf86-4_3_0_1
Diffstat (limited to 'lock.c')
-rw-r--r-- | lock.c | 46 |
1 files changed, 19 insertions, 27 deletions
@@ -23,14 +23,16 @@ Except as contained in this notice, the name of The Open Group shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. ******************************************************************************/ +/* $XFree86: xc/programs/xsm/lock.c,v 3.5 2002/05/31 18:46:14 dawes Exp $ */ #include "xsm.h" +#include "lock.h" +#include "choose.h" #include <sys/types.h> static char * -GetPath () - +GetPath(void) { char *path = (char *) getenv ("SM_SAVE_DIR"); @@ -46,11 +48,7 @@ GetPath () Status -LockSession (session_name, write_id) - -char *session_name; -Bool write_id; - +LockSession(char *session_name, Bool write_id) { char *path; char lock_file[PATH_MAX]; @@ -60,14 +58,18 @@ Bool write_id; path = GetPath (); +#ifndef __UNIXOS2__ sprintf (lock_file, "%s/.XSMlock-%s", path, session_name); sprintf (temp_lock_file, "%s/.XSMtlock-%s", path, session_name); +#else + sprintf (temp_lock_file, "%s/%s.slk", path, session_name); +#endif if ((fd = creat (temp_lock_file, 0444)) < 0) return (0); - if (write_id && - (write (fd, networkIds, strlen (networkIds)) != strlen (networkIds)) || + if ((write_id && + (write (fd, networkIds, strlen (networkIds)) != strlen (networkIds))) || (write (fd, "\n", 1) != 1)) { close (fd); @@ -76,6 +78,7 @@ Bool write_id; close (fd); +#ifndef __UNIXOS2__ status = 1; if (link (temp_lock_file, lock_file) < 0) @@ -83,16 +86,16 @@ Bool write_id; if (unlink (temp_lock_file) < 0) status = 0; +#else + status = 0; +#endif return (status); } void -UnlockSession (session_name) - -char *session_name; - +UnlockSession(char *session_name) { char *path; char lock_file[PATH_MAX]; @@ -106,10 +109,7 @@ char *session_name; char * -GetLockId (session_name) - -char *session_name; - +GetLockId(char *session_name) { char *path; FILE *fp; @@ -137,12 +137,7 @@ char *session_name; Bool -CheckSessionLocked (session_name, get_id, id_ret) - -char *session_name; -Bool get_id; -char **id_ret; - +CheckSessionLocked(char *session_name, Bool get_id, char **id_ret) { if (get_id) *id_ret = GetLockId (session_name); @@ -156,10 +151,7 @@ char **id_ret; void -UnableToLockSession (session_name) - -char *session_name; - +UnableToLockSession(char *session_name) { /* * We should popup a dialog here giving error. |