+/*
+ * Format TIME ONLY for output
+ */
+void fmt_time(char *buf, time_t thetime) {
+ struct tm *tm;
+ int hour;
+
+ strcpy(buf, "");
+ tm = localtime(&thetime);
+ hour = tm->tm_hour;
+ if (hour == 0) hour = 12;
+ else if (hour > 12) hour = hour - 12;
+
+ sprintf(buf, "%d:%02d%s",
+ hour,
+ tm->tm_min,
+ ( (tm->tm_hour > 12) ? "pm" : "am" )
+ );
+}
+
+
+
/*
* Format a date/time stamp to the format used in HTTP headers
}
+
+/*
+ * Read binary data from server into memory
+ */
+void read_server_binary(char *buffer, size_t total_len) {
+ char buf[SIZ];
+ size_t bytes = 0;
+ size_t thisblock = 0;
+
+ while (bytes < total_len) {
+ thisblock = 4095;
+ if ((total_len - bytes) < thisblock) {
+ thisblock = total_len - bytes;
+ }
+ serv_printf("READ %d|%d", (int)bytes, (int)thisblock);
+ serv_gets(buf);
+ if (buf[0] == '6') {
+ thisblock = (size_t)atoi(&buf[4]);
+ serv_read(&buffer[bytes], thisblock);
+ bytes += thisblock;
+ }
+ else {
+ wprintf("Error: %s<BR>\n", &buf[4]);
+ }
+ }
+}
+
+
+
+/*
+ * Strip a boundarized substring out of a string (for example, remove
+ * parentheses and anything inside them).
+ *
+ * This improved version can strip out *multiple* boundarized substrings.
+ */
+void stripout(char *str, char leftboundary, char rightboundary) {
+ int a;
+ int lb = (-1);
+ int rb = (-1);
+
+ do {
+ lb = (-1);
+ rb = (-1);
+
+ for (a = 0; a < strlen(str); ++a) {
+ if (str[a] == leftboundary) lb = a;
+ if (str[a] == rightboundary) rb = a;
+ }
+
+ if ( (lb > 0) && (rb > lb) ) {
+ strcpy(&str[lb - 1], &str[rb + 1]);
+ }
+
+ } while ( (lb > 0) && (rb > lb) );
+
+}
+
+