1 /*
2  * err.c: libpty error strings
3  *
4  * Copyright 2009 by the Massachusetts Institute of Technology.
5  *
6  *
7  * Permission to use, copy, modify, and distribute this software and
8  * its documentation for any purpose and without fee is hereby
9  * granted, provided that the above copyright notice appear in all
10  * copies and that both that copyright notice and this permission
11  * notice appear in supporting documentation, and that the name of
12  * M.I.T. not be used in advertising or publicity pertaining to
13  * distribution of the software without specific, written prior
14  * permission.  Furthermore if you modify this software you must label
15  * your software as modified software and not distribute it in such a
16  * fashion that it might be confused with the original M.I.T. software.
17  * M.I.T. makes no representations about the suitability
18  * of this software for any purpose.  It is provided "as is" without
19  * express or implied warranty.
20  *
21  */
22 
23 #include "libpty.h"
24 
25 /* Keep in sync with error codes in libpty.h. */
26 const char *error_table[] = {
27     "Success",
28     "Failed to unlock or grant streams pty.",
29     "fstat of master pty failed",
30     "All terminal ports in use",
31     "Buffer to hold slave pty name is too short",
32     "Failed to open slave side of pty",
33     "Failed to chmod slave side of pty",
34     "Unable to set controlling terminal",
35     "Failed to chown slave side of pty",
36     "Call to line_push failed to push streams on slave pty",
37     "Failed to push stream on slave side of pty",
38     "Failed to revoke slave side of pty",
39     "Bad process type passed to pty_update_utmp",
40     "Slave pty name is zero-length"
41 };
42 
pty_error_message(long code)43 const char *pty_error_message(long code)
44 {
45     if (code < 0 ||
46 	(size_t) code >= (sizeof(error_table) / sizeof(*error_table)))
47         return "Unknown libpty error code";
48     return error_table[code];
49 }
50