summaryrefslogtreecommitdiff
path: root/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'lock.c')
-rw-r--r--lock.c46
1 files changed, 19 insertions, 27 deletions
diff --git a/lock.c b/lock.c
index 46b5083..611acdd 100644
--- a/lock.c
+++ b/lock.c
@@ -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.