Mercurial > hg > early-roguelike
comparison arogue7/save.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 |
|---|---|
| 40 #ifndef ENCREAD | 40 #ifndef ENCREAD |
| 41 #define ENCREAD encread | 41 #define ENCREAD encread |
| 42 #define ENCWRITE encwrite | 42 #define ENCWRITE encwrite |
| 43 #endif | 43 #endif |
| 44 | 44 |
| 45 bool save_file(int savefd); | |
| 46 | |
| 45 typedef struct stat STAT; | 47 typedef struct stat STAT; |
| 46 | 48 |
| 47 extern char version[], encstr[]; | 49 extern char version[], encstr[]; |
| 48 /* extern bool _endwin; */ | 50 /* extern bool _endwin; */ |
| 49 extern int errno; | 51 extern int errno; |
| 50 | 52 |
| 51 STAT sbuf; | 53 STAT sbuf; |
| 52 | 54 |
| 53 bool | 55 bool |
| 54 save_game() | 56 save_game(void) |
| 55 { | 57 { |
| 56 register int savefd; | 58 register int savefd; |
| 57 register int c; | 59 register int c; |
| 58 char buf[LINELEN]; | 60 char buf[LINELEN]; |
| 59 | 61 |
| 120 /* | 122 /* |
| 121 * automatically save a file. This is used if a HUP signal is | 123 * automatically save a file. This is used if a HUP signal is |
| 122 * recieved | 124 * recieved |
| 123 */ | 125 */ |
| 124 void | 126 void |
| 125 auto_save(sig) | 127 auto_save(int sig) |
| 126 int sig; | |
| 127 { | 128 { |
| 128 register int savefd; | 129 register int savefd; |
| 129 register int i; | 130 register int i; |
| 130 | 131 |
| 131 for (i = 0; i < NSIG; i++) | 132 for (i = 0; i < NSIG; i++) |
| 143 | 144 |
| 144 /* | 145 /* |
| 145 * write the saved game on the file | 146 * write the saved game on the file |
| 146 */ | 147 */ |
| 147 bool | 148 bool |
| 148 save_file(savefd) | 149 save_file(int savefd) |
| 149 register int savefd; | |
| 150 { | 150 { |
| 151 register unsigned num_to_write, num_written; | 151 register unsigned num_to_write, num_written; |
| 152 FILE *savef; | 152 FILE *savef; |
| 153 int ret; | 153 int ret; |
| 154 | 154 |
| 165 fclose(savef); | 165 fclose(savef); |
| 166 if (num_to_write == num_written && ret == 0) return(TRUE); | 166 if (num_to_write == num_written && ret == 0) return(TRUE); |
| 167 else return(FALSE); | 167 else return(FALSE); |
| 168 } | 168 } |
| 169 | 169 |
| 170 restore(file, envp) | 170 bool |
| 171 register char *file; | 171 restore(char *file, char *envp[]) |
| 172 char **envp; | |
| 173 { | 172 { |
| 174 register int inf; | 173 register int inf; |
| 175 extern char **environ; | 174 extern char **environ; |
| 176 char buf[LINELEN]; | 175 char buf[LINELEN]; |
| 177 STAT sbuf2; | 176 STAT sbuf2; |
| 263 | 262 |
| 264 #define ENCWBSIZ 1024 | 263 #define ENCWBSIZ 1024 |
| 265 /* | 264 /* |
| 266 * perform an encrypted write | 265 * perform an encrypted write |
| 267 */ | 266 */ |
| 268 encwrite(start, size, outf) | 267 int |
| 269 register char *start; | 268 encwrite(char *start, unsigned int size, int outf) |
| 270 register unsigned size; | |
| 271 register int outf; | |
| 272 { | 269 { |
| 273 register char *ep; | 270 register char *ep; |
| 274 register int i = 0; | 271 register int i = 0; |
| 275 int num_written = 0; | 272 int num_written = 0; |
| 276 auto char buf[ENCWBSIZ]; | 273 auto char buf[ENCWBSIZ]; |
| 296 } | 293 } |
| 297 | 294 |
| 298 /* | 295 /* |
| 299 * perform an encrypted read | 296 * perform an encrypted read |
| 300 */ | 297 */ |
| 301 encread(start, size, inf) | 298 int |
| 302 register char *start; | 299 encread(char *start, unsigned int size, int inf) |
| 303 register unsigned size; | |
| 304 register int inf; | |
| 305 { | 300 { |
| 306 register char *ep; | 301 register char *ep; |
| 307 register int read_size; | 302 register int read_size; |
| 308 | 303 |
| 309 if ((read_size = read(inf, start, size)) == -1 || read_size == 0) | 304 if ((read_size = read(inf, start, size)) == -1 || read_size == 0) |
