comparison arogue7/mdport.c @ 219:f9ef86cf22b2

Advanced Rogue 7: convert to ANSI-style function declarations. Almost 1500 lines of compiler warnings remain, and the GCC developers are already working on a new version with even more warnings turned on by default.
author John "Elwin" Edwards
date Fri, 19 Feb 2016 21:02:28 -0500
parents aa8e1fc62926
children 3d4252fa2ed3
comparison
equal deleted inserted replaced
218:56e748983fa8 219:f9ef86cf22b2
63 #if defined(_WIN32) 63 #if defined(_WIN32)
64 #include <process.h> 64 #include <process.h>
65 #endif 65 #endif
66 66
67 #include <stdio.h> 67 #include <stdio.h>
68 #include <ctype.h>
68 #include <string.h> 69 #include <string.h>
69 #include <fcntl.h> 70 #include <fcntl.h>
70 #include <limits.h> 71 #include <limits.h>
71 #include <sys/stat.h> 72 #include <sys/stat.h>
72 #include <signal.h> 73 #include <signal.h>
73 74
74 #define MOD_MOVE(c) (toupper(c) ) 75 #define MOD_MOVE(c) (toupper(c) )
75 76
76 void 77 void
77 md_init() 78 md_init(void)
78 { 79 {
79 #ifdef __INTERIX 80 #ifdef __INTERIX
80 char *term; 81 char *term;
81 82
82 term = getenv("TERM"); 83 term = getenv("TERM");
105 } 106 }
106 107
107 static int md_standout_mode = 0; 108 static int md_standout_mode = 0;
108 109
109 int 110 int
110 md_raw_standout() 111 md_raw_standout(void)
111 { 112 {
112 #ifdef _WIN32 113 #ifdef _WIN32
113 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 114 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
114 HANDLE hStdout; 115 HANDLE hStdout;
115 int fgattr,bgattr; 116 int fgattr,bgattr;
128 fflush(stdout); 129 fflush(stdout);
129 #endif 130 #endif
130 } 131 }
131 132
132 int 133 int
133 md_raw_standend() 134 md_raw_standend(void)
134 { 135 {
135 #ifdef _WIN32 136 #ifdef _WIN32
136 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 137 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
137 HANDLE hStdout; 138 HANDLE hStdout;
138 int fgattr,bgattr; 139 int fgattr,bgattr;
207 return(fd); 208 return(fd);
208 } 209 }
209 210
210 211
211 int 212 int
212 md_normaluser() 213 md_normaluser(void)
213 { 214 {
214 #ifndef _WIN32 215 #ifndef _WIN32
215 setuid(getuid()); 216 setuid(getuid());
216 setgid(getgid()); 217 setgid(getgid());
217 #endif 218 #endif
218 } 219 }
219 220
220 int 221 int
221 md_getuid() 222 md_getuid(void)
222 { 223 {
223 #ifndef _WIN32 224 #ifndef _WIN32
224 return( getuid() ); 225 return( getuid() );
225 #else 226 #else
226 return(42); 227 return(42);
227 #endif 228 #endif
228 } 229 }
229 230
230 char * 231 char *
231 md_getusername() 232 md_getusername(void)
232 { 233 {
233 static char login[80]; 234 static char login[80];
234 char *l = NULL; 235 char *l = NULL;
235 #ifdef _WIN32 236 #ifdef _WIN32
236 LPSTR mybuffer; 237 LPSTR mybuffer;
261 262
262 return(login); 263 return(login);
263 } 264 }
264 265
265 char * 266 char *
266 md_gethomedir() 267 md_gethomedir(void)
267 { 268 {
268 static char homedir[PATH_MAX]; 269 static char homedir[PATH_MAX];
269 char *h = NULL; 270 char *h = NULL;
270 size_t len; 271 size_t len;
271 #if defined(_WIN32) 272 #if defined(_WIN32)
316 317
317 return(homedir); 318 return(homedir);
318 } 319 }
319 320
320 char * 321 char *
321 md_getshell() 322 md_getshell(void)
322 { 323 {
323 static char shell[PATH_MAX]; 324 static char shell[PATH_MAX];
324 char *s = NULL; 325 char *s = NULL;
325 #ifdef _WIN32 326 #ifdef _WIN32
326 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE"; 327 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE";
344 345
345 return(shell); 346 return(shell);
346 } 347 }
347 348
348 int 349 int
349 md_shellescape() 350 md_shellescape(void)
350 { 351 {
351 #if (!defined(_WIN32) && !defined(__DJGPP__)) 352 #if (!defined(_WIN32) && !defined(__DJGPP__))
352 int ret_status; 353 int ret_status;
353 int pid; 354 int pid;
354 void (*myquit)(int); 355 void (*myquit)(int);
406 407
407 return(0); 408 return(0);
408 } 409 }
409 410
410 char * 411 char *
411 md_getroguedir() 412 md_getroguedir(void)
412 { 413 {
413 static char path[1024]; 414 static char path[1024];
414 char *end,*home; 415 char *end,*home;
415 416
416 if ( (home = getenv("ROGUEHOME")) != NULL) 417 if ( (home = getenv("ROGUEHOME")) != NULL)
470 { 471 {
471 return( xcrypt(key,salt) ); 472 return( xcrypt(key,salt) );
472 } 473 }
473 474
474 char * 475 char *
475 md_getpass(prompt) 476 md_getpass(char *prompt)
476 char *prompt;
477 { 477 {
478 #ifdef _WIN32 478 #ifdef _WIN32
479 static char password_buffer[9]; 479 static char password_buffer[9];
480 char *p = password_buffer; 480 char *p = password_buffer;
481 int c, count = 0; 481 int c, count = 0;
566 return( htonl(x) ); 566 return( htonl(x) );
567 #endif 567 #endif
568 } 568 }
569 569
570 int 570 int
571 md_rand() 571 md_rand(void)
572 { 572 {
573 #ifdef _WIN32 573 #ifdef _WIN32
574 return(rand()); 574 return(rand());
575 #else 575 #else
576 return(random()); 576 return(random());
577 #endif 577 #endif
578 } 578 }
579 579
580 int 580 int
581 md_srand(seed) 581 md_srand(int seed)
582 register int seed;
583 { 582 {
584 #ifdef _WIN32 583 #ifdef _WIN32
585 srand(seed); 584 srand(seed);
586 #else 585 #else
587 srandom(seed); 586 srandom(seed);
588 #endif 587 #endif
589 } 588 }
590 589
591 long 590 long
592 md_memused() 591 md_memused(void)
593 { 592 {
594 #ifdef _WIN32 593 #ifdef _WIN32
595 MEMORYSTATUS stat; 594 MEMORYSTATUS stat;
596 595
597 GlobalMemoryStatus(&stat); 596 GlobalMemoryStatus(&stat);
601 return( (long)sbrk(0) ); 600 return( (long)sbrk(0) );
602 #endif 601 #endif
603 } 602 }
604 603
605 char * 604 char *
606 md_gethostname() 605 md_gethostname(void)
607 { 606 {
608 static char nodename[80]; 607 static char nodename[80];
609 char *n = NULL; 608 char *n = NULL;
610 #if !defined(_WIN32) && !defined(__DJGPP__) 609 #if !defined(_WIN32) && !defined(__DJGPP__)
611 struct utsname ourname; 610 struct utsname ourname;
623 622
624 return(nodename); 623 return(nodename);
625 } 624 }
626 625
627 int 626 int
628 md_erasechar() 627 md_erasechar(void)
629 { 628 {
630 #ifdef BSD 629 #ifdef BSD
631 return(_tty.sg_erase); /* process erase character */ 630 return(_tty.sg_erase); /* process erase character */
632 #elif defined(USG5_0) 631 #elif defined(USG5_0)
633 return(_tty.c_cc[VERASE]); /* process erase character */ 632 return(_tty.c_cc[VERASE]); /* process erase character */
635 return( erasechar() ); /* process erase character */ 634 return( erasechar() ); /* process erase character */
636 #endif 635 #endif
637 } 636 }
638 637
639 int 638 int
640 md_killchar() 639 md_killchar(void)
641 { 640 {
642 #ifdef BSD 641 #ifdef BSD
643 return(_tty.sg_kill); 642 return(_tty.sg_kill);
644 #elif defined(USG5_0) 643 #elif defined(USG5_0)
645 return(_tty.c_cc[VKILL]); 644 return(_tty.c_cc[VKILL]);
652 * unctrl: 651 * unctrl:
653 * Print a readable version of a certain character 652 * Print a readable version of a certain character
654 */ 653 */
655 654
656 char * 655 char *
657 md_unctrl(ch) 656 md_unctrl(char ch)
658 char ch;
659 { 657 {
660 #if USG5_0 658 #if USG5_0
661 extern char *_unctrl[]; /* Defined in curses library */ 659 extern char *_unctrl[]; /* Defined in curses library */
662 660
663 return _unctrl[ch&0177]; 661 return _unctrl[ch&0177];
665 return( unctrl(ch) ); 663 return( unctrl(ch) );
666 #endif 664 #endif
667 } 665 }
668 666
669 void 667 void
670 md_flushinp() 668 md_flushinp(void)
671 { 669 {
672 #ifdef BSD 670 #ifdef BSD
673 ioctl(0, TIOCFLUSH); 671 ioctl(0, TIOCFLUSH);
674 #elif defined(USG5_0) 672 #elif defined(USG5_0)
675 ioctl(_tty_ch,TCFLSH,0) 673 ioctl(_tty_ch,TCFLSH,0)