comparison arogue5/mdport.c @ 218:56e748983fa8

Advanced Rogue 5: convert to ANSI function declarations. This still leaves over a thousand lines of warning messages, mostly related to the return types of daemons and fuses.
author John "Elwin" Edwards
date Sun, 07 Feb 2016 14:39:21 -0500
parents 61d1c9ac9be7
children 3d4252fa2ed3
comparison
equal deleted inserted replaced
217:94a0d9dd5ce1 218:56e748983fa8
53 #include <unistd.h> 53 #include <unistd.h>
54 #endif 54 #endif
55 55
56 #include <stdlib.h> 56 #include <stdlib.h>
57 #include <string.h> 57 #include <string.h>
58 #include <ctype.h>
58 59
59 #if defined(_WIN32) && !defined(__MINGW32__) 60 #if defined(_WIN32) && !defined(__MINGW32__)
60 #define PATH_MAX MAX_PATH 61 #define PATH_MAX MAX_PATH
61 #endif 62 #endif
62 63
79 #include <signal.h> 80 #include <signal.h>
80 81
81 #define MOD_MOVE(c) (toupper(c) ) 82 #define MOD_MOVE(c) (toupper(c) )
82 83
83 void 84 void
84 md_init() 85 md_init(void)
85 { 86 {
86 #ifdef __INTERIX 87 #ifdef __INTERIX
87 char *term; 88 char *term;
88 89
89 term = getenv("TERM"); 90 term = getenv("TERM");
130 } 131 }
131 132
132 static int md_standout_mode = 0; 133 static int md_standout_mode = 0;
133 134
134 int 135 int
135 md_raw_standout() 136 md_raw_standout(void)
136 { 137 {
137 #ifdef _WIN32 138 #ifdef _WIN32
138 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 139 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
139 HANDLE hStdout; 140 HANDLE hStdout;
140 int fgattr,bgattr; 141 int fgattr,bgattr;
153 fflush(stdout); 154 fflush(stdout);
154 #endif 155 #endif
155 } 156 }
156 157
157 int 158 int
158 md_raw_standend() 159 md_raw_standend(void)
159 { 160 {
160 #ifdef _WIN32 161 #ifdef _WIN32
161 CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 162 CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
162 HANDLE hStdout; 163 HANDLE hStdout;
163 int fgattr,bgattr; 164 int fgattr,bgattr;
221 return( fdopen(fd, mode) ); 222 return( fdopen(fd, mode) );
222 #endif 223 #endif
223 } 224 }
224 225
225 int 226 int
226 md_normaluser() 227 md_normaluser(void)
227 { 228 {
228 #ifndef _WIN32 229 #ifndef _WIN32
229 setuid(getuid()); 230 setuid(getuid());
230 setgid(getgid()); 231 setgid(getgid());
231 #endif 232 #endif
232 } 233 }
233 234
234 int 235 int
235 md_getuid() 236 md_getuid(void)
236 { 237 {
237 #ifndef _WIN32 238 #ifndef _WIN32
238 return( getuid() ); 239 return( getuid() );
239 #else 240 #else
240 return(42); 241 return(42);
241 #endif 242 #endif
242 } 243 }
243 244
244 char * 245 char *
245 md_getusername() 246 md_getusername(void)
246 { 247 {
247 static char login[80]; 248 static char login[80];
248 char *l = NULL; 249 char *l = NULL;
249 #ifdef _WIN32 250 #ifdef _WIN32
250 LPSTR mybuffer; 251 LPSTR mybuffer;
277 278
278 return(login); 279 return(login);
279 } 280 }
280 281
281 char * 282 char *
282 md_gethomedir() 283 md_gethomedir(void)
283 { 284 {
284 static char homedir[PATH_MAX]; 285 static char homedir[PATH_MAX];
285 char *h = NULL; 286 char *h = NULL;
286 size_t len; 287 size_t len;
287 #if defined(_WIN32) 288 #if defined(_WIN32)
333 334
334 return(homedir); 335 return(homedir);
335 } 336 }
336 337
337 char * 338 char *
338 md_getshell() 339 md_getshell(void)
339 { 340 {
340 static char shell[PATH_MAX]; 341 static char shell[PATH_MAX];
341 char *s = NULL; 342 char *s = NULL;
342 #ifdef _WIN32 343 #ifdef _WIN32
343 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE"; 344 char *def = "C:\\WINDOWS\\SYSTEM32\\CMD.EXE";
363 364
364 return(shell); 365 return(shell);
365 } 366 }
366 367
367 int 368 int
368 md_shellescape() 369 md_shellescape(void)
369 { 370 {
370 #if (!defined(_WIN32) && !defined(__DJGPP__)) 371 #if (!defined(_WIN32) && !defined(__DJGPP__))
371 int ret_status; 372 int ret_status;
372 int pid; 373 int pid;
373 void (*myquit)(int); 374 void (*myquit)(int);
425 426
426 return(0); 427 return(0);
427 } 428 }
428 429
429 char * 430 char *
430 md_getroguedir() 431 md_getroguedir(void)
431 { 432 {
432 static char path[1024]; 433 static char path[1024];
433 char *end,*home; 434 char *end,*home;
434 435
435 if ( (home = getenv("ROGUEHOME")) != NULL) 436 if ( (home = getenv("ROGUEHOME")) != NULL)
489 { 490 {
490 return( xcrypt(key,salt) ); 491 return( xcrypt(key,salt) );
491 } 492 }
492 493
493 char * 494 char *
494 md_getpass(prompt) 495 md_getpass(char *prompt)
495 char *prompt;
496 { 496 {
497 #ifdef _WIN32 497 #ifdef _WIN32
498 static char password_buffer[9]; 498 static char password_buffer[9];
499 char *p = password_buffer; 499 char *p = password_buffer;
500 int c, count = 0; 500 int c, count = 0;
585 return( htonl(x) ); 585 return( htonl(x) );
586 #endif 586 #endif
587 } 587 }
588 588
589 int 589 int
590 md_rand() 590 md_rand(void)
591 { 591 {
592 #ifdef _WIN32 592 #ifdef _WIN32
593 return(rand()); 593 return(rand());
594 #else 594 #else
595 return(lrand48() & 0x7fffffff); 595 return(lrand48() & 0x7fffffff);
596 #endif 596 #endif
597 } 597 }
598 598
599 int 599 int
600 md_srand(seed) 600 md_srand(int seed)
601 register int seed;
602 { 601 {
603 #ifdef _WIN32 602 #ifdef _WIN32
604 srand(seed); 603 srand(seed);
605 #else 604 #else
606 srand48(seed); 605 srand48(seed);
607 #endif 606 #endif
608 } 607 }
609 608
610 long 609 long
611 md_memused() 610 md_memused(void)
612 { 611 {
613 #ifdef _WIN32 612 #ifdef _WIN32
614 MEMORYSTATUS stat; 613 MEMORYSTATUS stat;
615 614
616 GlobalMemoryStatus(&stat); 615 GlobalMemoryStatus(&stat);
620 return( (long)sbrk(0) ); 619 return( (long)sbrk(0) );
621 #endif 620 #endif
622 } 621 }
623 622
624 char * 623 char *
625 md_gethostname() 624 md_gethostname(void)
626 { 625 {
627 static char nodename[80]; 626 static char nodename[80];
628 char *n = NULL; 627 char *n = NULL;
629 #if !defined(_WIN32) && !defined(__DJGPP__) 628 #if !defined(_WIN32) && !defined(__DJGPP__)
630 struct utsname ourname; 629 struct utsname ourname;
642 641
643 return(nodename); 642 return(nodename);
644 } 643 }
645 644
646 int 645 int
647 md_erasechar() 646 md_erasechar(void)
648 { 647 {
649 #ifdef BSD 648 #ifdef BSD
650 return(_tty.sg_erase); /* process erase character */ 649 return(_tty.sg_erase); /* process erase character */
651 #elif defined(USG5_0) 650 #elif defined(USG5_0)
652 return(_tty.c_cc[VERASE]); /* process erase character */ 651 return(_tty.c_cc[VERASE]); /* process erase character */
654 return( erasechar() ); /* process erase character */ 653 return( erasechar() ); /* process erase character */
655 #endif 654 #endif
656 } 655 }
657 656
658 int 657 int
659 md_killchar() 658 md_killchar(void)
660 { 659 {
661 #ifdef BSD 660 #ifdef BSD
662 return(_tty.sg_kill); 661 return(_tty.sg_kill);
663 #elif defined(USG5_0) 662 #elif defined(USG5_0)
664 return(_tty.c_cc[VKILL]); 663 return(_tty.c_cc[VKILL]);
671 * unctrl: 670 * unctrl:
672 * Print a readable version of a certain character 671 * Print a readable version of a certain character
673 */ 672 */
674 673
675 char * 674 char *
676 md_unctrl(ch) 675 md_unctrl(char ch)
677 char ch;
678 { 676 {
679 #if USG5_0 677 #if USG5_0
680 extern char *_unctrl[]; /* Defined in curses library */ 678 extern char *_unctrl[]; /* Defined in curses library */
681 679
682 return _unctrl[ch&0177]; 680 return _unctrl[ch&0177];
684 return( unctrl(ch) ); 682 return( unctrl(ch) );
685 #endif 683 #endif
686 } 684 }
687 685
688 void 686 void
689 md_flushinp() 687 md_flushinp(void)
690 { 688 {
691 #ifdef BSD 689 #ifdef BSD
692 ioctl(0, TIOCFLUSH); 690 ioctl(0, TIOCFLUSH);
693 #elif defined(USG5_0) 691 #elif defined(USG5_0)
694 ioctl(_tty_ch,TCFLSH,0) 692 ioctl(_tty_ch,TCFLSH,0)