Source:Hack 1.0/hack.rip.c
Revision as of 22:34, 3 March 2008 by Kernigh bot (talk | contribs) (Hack 1.0/hack.rip.c moved to Source:Hack 1.0/hack.rip.c: Robot: moved page)
Below is the full text to hack.rip.c from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/hack.rip.c#line123]], for example.
Warning! This is the source code from an old release. For the latest release, see Source code
Screenshots and source code from Hack are used under the CWI license.
1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984. */ 2. 3. #include <sys/types.h> /* for time_t */ 4. #include <stdio.h> 5. #include "hack.h" 6. #ifdef BSD 7. #include <sys/time.h> 8. #else 9. #include <time.h> 10. #endif BSD 11. 12. extern char plname[]; 13. 14. static char *rip[] = { 15. " ----------", 16. " / \\", 17. " / REST \\", 18. " / IN \\", 19. " / PEACE \\", 20. " / \\", 21. " | |", 22. " | |", 23. " | |", 24. " | |", 25. " | |", 26. " | 1001 |", 27. " *| * * * | *", 28. " _________)/\\\\_//(\\/(/\\)/\\//\\/|_)_______\n", 29. 0 30. }; 31. 32. outrip(){ 33. register char **dp = rip; 34. register char *dpx; 35. register struct tm *lt; 36. time_t date; 37. char buf[BUFSZ]; 38. struct tm *localtime(); 39. register x,y; 40. 41. cls(); 42. (void) time(&date); 43. lt = localtime(&date); 44. (void) strcpy(buf, plname); 45. buf[16] = 0; 46. center(6, buf); 47. (void) sprintf(buf, "%ld AU", u.ugold); 48. center(7, buf); 49. (void) sprintf(buf, "killed by%s", 50. !strncmp(killer, "the ", 4) ? "" : 51. !strcmp(killer, "starvation") ? "" : 52. index(vowels, *killer) ? " an" : " a"); 53. center(8, buf); 54. (void) strcpy(buf, killer); 55. if(strlen(buf) > 16) { 56. register int i,i0,i1; 57. i0 = i1 = 0; 58. for(i = 0; i <= 16; i++) 59. if(buf[i] == ' ') i0 = i, i1 = i+1; 60. if(!i0) i0 = i1 = 16; 61. buf[i1 + 16] = 0; 62. center(10, buf+i1); 63. buf[i0] = 0; 64. } 65. center(9, buf); 66. (void) sprintf(buf, "19%2d", lt->tm_year); 67. center(11, buf); 68. for(y=8; *dp; y++,dp++){ 69. x = 0; 70. dpx = *dp; 71. while(dpx[x]) { 72. while(dpx[x] == ' ') x++; 73. curs(x,y); 74. while(dpx[x] && dpx[x] != ' '){ 75. extern int done_stopprint; 76. if(done_stopprint) 77. return; 78. curx++; 79. (void) putchar(dpx[x++]); 80. } 81. } 82. } 83. getret(); 84. } 85. 86. center(line, text) int line; char *text; { 87. register char *ip,*op; 88. ip = text; 89. op = &rip[line][28 - ((strlen(text)+1)/2)]; 90. while(*ip) *op++ = *ip++; 91. }