diff --git a/post.c b/post.c index 0abd4ef..29c24bb 100644 --- a/post.c +++ b/post.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "post.h" @@ -513,7 +514,7 @@ static void setpagesize(char *s) return; } } - /* custom paper size in tenth of mm; example: 2100x2970 for a4 */ + /* custom paper size in tenths of mm; example: 2100x2970 for a4. */ if (isdigit(s[0]) && strchr(s, 'x')) { ps_pagewidth = atoi(s); ps_pageheight = atoi(strchr(s, 'x') + 1); @@ -534,6 +535,8 @@ static void setpagesize(char *s) d1 = 9170; d2 = 12970; } + + n = s[1] - '0'; ps_pagewidth = ((n & 1) ? d2 : d1) >> ((n + 1) >> 1); ps_pageheight = ((n & 1) ? d1 : d2) >> (n >> 1); @@ -541,6 +544,12 @@ static void setpagesize(char *s) ps_pageheight -= ps_pageheight % 10; } +static void setlandscape(void) { + int t = ps_pagewidth; + ps_pagewidth = ps_pageheight; + ps_pageheight = t; +} + void *mextend(void *old, long oldsz, long newsz, int memsz) { void *new = malloc(newsz * memsz); @@ -659,5 +668,5 @@ int main(int argc, char *argv[]) free(name_desc); free(name_page); free(name_offset); - return 0; + return EXIT_SUCCESS; }