comparison lib-src/yow.c @ 55442:a47704955f8d

Throughout, replace 0 destined for `exit' arg with `EXIT_SUCCESS'. Likewise, replace 1 with `EXIT_FAILURE'. (main): Use `EXIT_SUCCESS' or `EXIT_FAILURE' for return value.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Sat, 08 May 2004 15:23:35 +0000
parents 695cf19ef79e
children 00adf45090ee 4c90ffeb71c5
comparison
equal deleted inserted replaced
55441:406c79b8022c 55442:a47704955f8d
71 #endif 71 #endif
72 72
73 if ((fp = fopen(file, "r")) == NULL) { 73 if ((fp = fopen(file, "r")) == NULL) {
74 fprintf(stderr, "yow: "); 74 fprintf(stderr, "yow: ");
75 perror(file); 75 perror(file);
76 exit(1); 76 exit(EXIT_FAILURE);
77 } 77 }
78 78
79 /* initialize random seed */ 79 /* initialize random seed */
80 srand((int) (getpid() + time((time_t *) 0))); 80 srand((int) (getpid() + time((time_t *) 0)));
81 81
82 setup_yow(fp); 82 setup_yow(fp);
83 yow(fp); 83 yow(fp);
84 fclose(fp); 84 fclose(fp);
85 return 0; 85 return EXIT_SUCCESS;
86 } 86 }
87 87
88 static long len = -1; 88 static long len = -1;
89 static long header_len; 89 static long header_len;
90 90
111 if (header_len > AVG_LEN) 111 if (header_len > AVG_LEN)
112 header_len -= AVG_LEN; /* allow the first quotation to appear */ 112 header_len -= AVG_LEN; /* allow the first quotation to appear */
113 113
114 if (fseek(fp, 0L, 2) == -1) { 114 if (fseek(fp, 0L, 2) == -1) {
115 perror("yow"); 115 perror("yow");
116 exit(1); 116 exit(EXIT_FAILURE);
117 } 117 }
118 len = ftell(fp) - header_len; 118 len = ftell(fp) - header_len;
119 } 119 }
120 120
121 121
130 unsigned int bufsize; 130 unsigned int bufsize;
131 131
132 offset = rand() % len + header_len; 132 offset = rand() % len + header_len;
133 if (fseek(fp, offset, 0) == -1) { 133 if (fseek(fp, offset, 0) == -1) {
134 perror("yow"); 134 perror("yow");
135 exit(1); 135 exit(EXIT_FAILURE);
136 } 136 }
137 137
138 /* Read until SEP, read next line, print it. 138 /* Read until SEP, read next line, print it.
139 (Note that we will never print anything before the first separator.) 139 (Note that we will never print anything before the first separator.)
140 If we hit EOF looking for the first SEP, just recurse. */ 140 If we hit EOF looking for the first SEP, just recurse. */
178 printf("%s\n", buf); 178 printf("%s\n", buf);
179 } 179 }
180 180
181 /* arch-tag: e40fc0df-bafb-4001-af24-5c883d1c685e 181 /* arch-tag: e40fc0df-bafb-4001-af24-5c883d1c685e
182 (do not change this comment) */ 182 (do not change this comment) */
183
184 /* yow.c ends here */