ptsname.c (687B)
1 #include <unistd.h> /* write() */ 2 #include <stdlib.h> /* ptsname() */ 3 #include <string.h> 4 5 #include <skalibs/types.h> 6 #include <skalibs/strerr.h> 7 8 #define USAGE "ptsname ptmx_fd" 9 #define PROG "ptsname" 10 11 12 int main (int argc, char const *const *argv) 13 { 14 unsigned int ptmx_fd; 15 const char *pts_name; 16 if ((argc != 2)) strerr_dieusage(100, USAGE) ; 17 if (!uint0_scan(argv[1], &ptmx_fd)) strerr_dieusage(100, USAGE) ; 18 19 pts_name = ptsname(ptmx_fd); 20 if (pts_name == NULL) { 21 strerr_dief1sys(111, "ptsname()"); 22 } 23 24 if (write(1, pts_name, strlen(pts_name)) <= 0) { 25 strerr_dief1sys(111, "write()"); 26 } 27 if (write(1, "\n", 1) <= 0) { 28 strerr_dief1sys(111, "write()"); 29 } 30 }