| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/lib/getpass.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||
|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||
| 2 | - | |||||||
| 3 | - | |||||||
| 4 | - | |||||||
| 5 | - | |||||||
| 6 | - | |||||||
| 7 | - | |||||||
| 8 | - | |||||||
| 9 | - | |||||||
| 10 | - | |||||||
| 11 | - | |||||||
| 12 | - | |||||||
| 13 | - | |||||||
| 14 | - | |||||||
| 15 | - | |||||||
| 16 | - | |||||||
| 17 | - | |||||||
| 18 | - | |||||||
| 19 | - | |||||||
| 20 | static void | - | ||||||
| 21 | call_fclose (void *arg) | - | ||||||
| 22 | { | - | ||||||
| 23 | if (arg !=
| 0 | ||||||
| 24 | ((void *)0)
| 0 | ||||||
| 25 | ) | - | ||||||
| 26 | - | |||||||
| 27 | rpl_fclose never executed: rpl_fclose (arg); | 0 | ||||||
| 28 | (arg); never executed: rpl_fclose (arg); | 0 | ||||||
| 29 | } never executed: end of block | 0 | ||||||
| 30 | - | |||||||
| 31 | char * | - | ||||||
| 32 | gnu_getpass (const char *prompt) | - | ||||||
| 33 | { | - | ||||||
| 34 | FILE *tty; | - | ||||||
| 35 | FILE *in, *out; | - | ||||||
| 36 | - | |||||||
| 37 | struct termios s, t; | - | ||||||
| 38 | - | |||||||
| 39 | - | |||||||
| 40 | _Bool | - | ||||||
| 41 | tty_changed = | - | ||||||
| 42 | 0 | - | ||||||
| 43 | ; | - | ||||||
| 44 | static char *buf; | - | ||||||
| 45 | static size_t bufsize; | - | ||||||
| 46 | ssize_t nread; | - | ||||||
| 47 | - | |||||||
| 48 | - | |||||||
| 49 | - | |||||||
| 50 | - | |||||||
| 51 | tty = fopen ("/dev/tty", "w+"); | - | ||||||
| 52 | if (tty ==
| 0 | ||||||
| 53 | ((void *)0)
| 0 | ||||||
| 54 | ) | - | ||||||
| 55 | { | - | ||||||
| 56 | in = | - | ||||||
| 57 | stdin | - | ||||||
| 58 | ; | - | ||||||
| 59 | out = | - | ||||||
| 60 | stderr | - | ||||||
| 61 | ; | - | ||||||
| 62 | } never executed: end of block | 0 | ||||||
| 63 | else | - | ||||||
| 64 | { | - | ||||||
| 65 | - | |||||||
| 66 | __fsetlocking (tty, | - | ||||||
| 67 | FSETLOCKING_BYCALLER | - | ||||||
| 68 | ); | - | ||||||
| 69 | - | |||||||
| 70 | out = in = tty; | - | ||||||
| 71 | } never executed: end of block | 0 | ||||||
| 72 | - | |||||||
| 73 | ((void) 0); | - | ||||||
| 74 | - | |||||||
| 75 | - | |||||||
| 76 | - | |||||||
| 77 | if (tcgetattr (fileno (in), &t) == 0
| 0 | ||||||
| 78 | { | - | ||||||
| 79 | - | |||||||
| 80 | s = t; | - | ||||||
| 81 | - | |||||||
| 82 | t.c_lflag &= ~( | - | ||||||
| 83 | 0000010 | - | ||||||
| 84 | | | - | ||||||
| 85 | 0000001 | - | ||||||
| 86 | ); | - | ||||||
| 87 | tty_changed = (tcsetattr (fileno (in), | - | ||||||
| 88 | 2 | - | ||||||
| 89 | | 0, &t) == 0); | - | ||||||
| 90 | } never executed: end of block | 0 | ||||||
| 91 | - | |||||||
| 92 | - | |||||||
| 93 | - | |||||||
| 94 | fputs_unlocked (prompt, out); | - | ||||||
| 95 | fflush_unlocked (out); | - | ||||||
| 96 | - | |||||||
| 97 | - | |||||||
| 98 | nread = getline (&buf, &bufsize, in); | - | ||||||
| 99 | - | |||||||
| 100 | rpl_fseeko | - | ||||||
| 101 | (out, 0, | - | ||||||
| 102 | 1 | - | ||||||
| 103 | ); | - | ||||||
| 104 | - | |||||||
| 105 | if (buf !=
| 0 | ||||||
| 106 | ((void *)0)
| 0 | ||||||
| 107 | ) | - | ||||||
| 108 | { | - | ||||||
| 109 | if (nread < 0
| 0 | ||||||
| 110 | buf[0] = '\0'; never executed: buf[0] = '\0'; | 0 | ||||||
| 111 | else if (buf[nread - 1] == '\n'
| 0 | ||||||
| 112 | { | - | ||||||
| 113 | - | |||||||
| 114 | buf[nread - 1] = '\0'; | - | ||||||
| 115 | if (tty_changed
| 0 | ||||||
| 116 | { | - | ||||||
| 117 | - | |||||||
| 118 | putc_unlocked ('\n', out); | - | ||||||
| 119 | } never executed: end of block | 0 | ||||||
| 120 | } never executed: end of block | 0 | ||||||
| 121 | } never executed: end of block | 0 | ||||||
| 122 | - | |||||||
| 123 | - | |||||||
| 124 | - | |||||||
| 125 | if (tty_changed
| 0 | ||||||
| 126 | tcsetattr (fileno (in), never executed: tcsetattr (fileno (in), 2 | 0, &s); | 0 | ||||||
| 127 | 2 never executed: tcsetattr (fileno (in), 2 | 0, &s); | 0 | ||||||
| 128 | | 0, &s); never executed: tcsetattr (fileno (in), 2 | 0, &s); | 0 | ||||||
| 129 | - | |||||||
| 130 | - | |||||||
| 131 | ((void) 0); | - | ||||||
| 132 | - | |||||||
| 133 | call_fclose (tty); | - | ||||||
| 134 | - | |||||||
| 135 | return never executed: buf;return buf;never executed: return buf; | 0 | ||||||
| 136 | } | - | ||||||
| Switch to Source code | Preprocessed file |