summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2007-05-16 16:29:22 -0400
committerRay Strode <rstrode@redhat.com>2007-05-16 16:29:22 -0400
commit73879cdf3c4e7c5bd386800809a120c73ed930a1 (patch)
treea91fc864e762d73cc507c18c0e3933679a7751fe /src
parente7c3b04e4f9293d01f494bafb84243b02abb22ad (diff)
Improve the ply-terminal api
Previously, the api for creating the pseudo-terminal was ply_terminal_open (). This is a bit confusing of an api because often a program will want to open the pseudo-terminal after creating it, so you end up with: ply_terminal_open (terminal); pts_fd = open (ply_terminal_get_name (terminal), O_RDWR); or whatever. Now it would be something like: ply_terminal_create_device (terminal); device_name = ply_terminal_get_device_name (terminal); pts_fd = open (device_name, O_RDWR); which I think is a little clearer.
Diffstat (limited to 'src')
-rw-r--r--src/ply-terminal.c22
-rw-r--r--src/ply-terminal.h8
2 files changed, 15 insertions, 15 deletions
diff --git a/src/ply-terminal.c b/src/ply-terminal.c
index 196ff3a..1f0f113 100644
--- a/src/ply-terminal.c
+++ b/src/ply-terminal.c
@@ -58,17 +58,17 @@ ply_terminal_free (ply_terminal_t *terminal)
{
assert (terminal != NULL);
- ply_terminal_close (terminal);
+ ply_terminal_destroy_device (terminal);
free (terminal);
}
bool
-ply_terminal_open (ply_terminal_t *terminal)
+ply_terminal_create_device (ply_terminal_t *terminal)
{
int saved_errno;
assert (terminal != NULL);
- assert (!ply_terminal_is_open (terminal));
+ assert (!ply_terminal_has_device (terminal));
terminal->fd = posix_openpt (O_RDWR | O_NOCTTY);
@@ -78,7 +78,7 @@ ply_terminal_open (ply_terminal_t *terminal)
if (grantpt (terminal->fd) < 0)
{
saved_errno = errno;
- ply_terminal_close (terminal);
+ ply_terminal_destroy_device (terminal);
errno = saved_errno;
return false;
}
@@ -86,7 +86,7 @@ ply_terminal_open (ply_terminal_t *terminal)
if (unlockpt (terminal->fd) < 0)
{
saved_errno = errno;
- ply_terminal_close (terminal);
+ ply_terminal_destroy_device (terminal);
errno = saved_errno;
return false;
}
@@ -97,7 +97,7 @@ ply_terminal_open (ply_terminal_t *terminal)
}
bool
-ply_terminal_is_open (ply_terminal_t *terminal)
+ply_terminal_has_device (ply_terminal_t *terminal)
{
assert (terminal != NULL);
@@ -105,7 +105,7 @@ ply_terminal_is_open (ply_terminal_t *terminal)
}
void
-ply_terminal_close (ply_terminal_t *terminal)
+ply_terminal_destroy_device (ply_terminal_t *terminal)
{
assert (terminal != NULL);
@@ -125,10 +125,10 @@ ply_terminal_get_fd (ply_terminal_t *terminal)
}
const char *
-ply_terminal_get_name (ply_terminal_t *terminal)
+ply_terminal_get_device_name (ply_terminal_t *terminal)
{
assert (terminal != NULL);
- assert (ply_terminal_is_open (terminal));
+ assert (ply_terminal_has_device (terminal));
assert (terminal->name != NULL);
return terminal->name;
@@ -151,14 +151,14 @@ main (int argc,
terminal = ply_terminal_new ();
- if (!ply_terminal_open (terminal))
+ if (!ply_terminal_create_device (terminal))
{
exit_code = errno;
perror ("could not open new terminal");
return exit_code;
}
- name = ply_terminal_get_name (terminal);
+ name = ply_terminal_get_device_name (terminal);
printf ("terminal name is '%s'\n", name);
while (read (ply_terminal_get_fd (terminal),
diff --git a/src/ply-terminal.h b/src/ply-terminal.h
index 4821ed2..ae9aa33 100644
--- a/src/ply-terminal.h
+++ b/src/ply-terminal.h
@@ -31,11 +31,11 @@ typedef struct _ply_terminal ply_terminal_t;
#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_terminal_t *ply_terminal_new ();
void ply_terminal_free (ply_terminal_t *terminal);
-bool ply_terminal_open (ply_terminal_t *terminal);
-bool ply_terminal_is_open (ply_terminal_t *terminal);
-void ply_terminal_close (ply_terminal_t *terminal);
+bool ply_terminal_create_device (ply_terminal_t *terminal);
+bool ply_terminal_has_device (ply_terminal_t *terminal);
+void ply_terminal_destroy_device (ply_terminal_t *terminal);
int ply_terminal_get_fd (ply_terminal_t *terminal);
-const char *ply_terminal_get_name (ply_terminal_t *terminal);
+const char *ply_terminal_get_device_name (ply_terminal_t *terminal);
#endif
#endif /* PLY_TERMINAL_H */