a few gripes: atoi: personally I prefer strtol and range-checks on the result and/or errno. getenv(LINES) is a start, but you might also want to offer ioctl(TIOCGWINSZ) where available. always NULL-check the return value of getenv. what does your pager do on binary input and unexpected things? does it filter ansi escape sequences? how does it treat lines wider than the screen width, and how does that influence the line count calculation?
cheers! mar77i