int show_gopher() { extern int page, range; int i; GOPHER *tmpnode; printgopher_title(); move(3, 0); clrtobot(); get_records(gophertmpfile, cur_page, sizeof(GOPHER), page + 1, 19); for (i = page; i < page + 19 && i < range; i++) { tmpnode = nth_item(i - page); move(i - page + 3, 0); prints(" %4d [[1m%9s[m] %-65s\n", i + 1, ((tmpnode->title[0] == '0') ? "[32mÁ¬ÎÄ" : "[33mÁ¬Ä¿"), tmpnode->title + 1); refresh(); } }
int deal_gopherkey(char ch, int allnum, int pagenum) { char fname[STRLEN], fpath[STRLEN]; #ifdef INTERNET_EMAIL struct shortfile fhdr; #endif switch (ch) { case 'h': case 'H': show_help("help/announcereadhelp"); g_refresh(); break; case 'E': case 'e': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { vedit(fname, NA, YEA); unlink(fname); g_refresh(); } show_message(NULL); break; case '=': { tmpitem = nth_item(allnum - pagenum); move(2, 0); clrtobot(); prints("[1;44;37m"); printdash("BBS Gopher Îï¼þ»ù±¾×ÊÁÏ"); prints("[m"); prints("ÀàÐÍ£º%c (%s)\n", tmpitem->title[0], (tmpitem->title[0] == '0') ? "Îļþ" : "Ŀ¼"); prints("±êÌ⣺%s\n", tmpitem->title + 1); prints("·¾¶£º%s\n", tmpitem->file); prints("λÖãº%s\n", tmpitem->server); prints("ʹÓãº%d²º\n", tmpitem->port); pressanykey(); g_refresh(); } break; case Ctrl('P'): tmpitem = nth_item(allnum - pagenum); if (!HAS_PERM(PERM_POST)) break; setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { char bname[30]; clear(); if (get_a_boardname(bname, "ÇëÊäÈëҪתÌùµÄÌÖÂÛÇøÃû³Æ: ")) { move(1, 0); sprintf(fpath, "ÄãÈ·¶¨Òª×ªÌùµ½ %s °åÂð", bname); if (askyn(fpath, NA, NA) == 1) { move(2, 0); Postfile(fname, bname, tmpitem->title + 1, 2); sprintf(fpath, "[1mÒѾ°ïÄãתÌùµ½ %s °åÁË...[m", bname); prints(fpath); refresh(); sleep(1); } } } unlink(fname); g_refresh(); return 1; #ifdef INTERNET_EMAIL case 'U': case 'F': case 'u': case 'f': case 'z': case 'Z': tmpitem = nth_item(allnum - pagenum); setuserfile(fname, "gopher.tmp"); if (tmpitem->title[0] != '0') { return 1; } if (get_con(tmpitem->server, tmpitem->port) == -1) return 1; enterdir(tmpitem->file); savetmpfile(fname); if (dashf(fname)) { strncpy(fhdr.title, tmpitem->title + 1, 70); strncpy(fhdr.filename, "gopher.tmp", STRLEN); sethomepath(fpath, currentuser.userid); // if (ch == 'Z' || ch == 'z') // a_download(fname); // else { switch (doforward(fpath, &fhdr, (ch == 'u' || ch == 'U') ? 1 : 0)) { case 0: show_message("ÎÄÕÂת¼ÄÍê³É!"); break; case -1: show_message("system error!!."); break; case -2: show_message("invalid address."); break; default: show_message("È¡Ïûת¼Ä¶¯×÷."); } // } refresh(); pressanykey(); g_refresh(); unlink(fname); return 1; } else return 1; break; #endif default: return 0; } return 1; }
int main(void) { int heat_deg_days, /* average for coldest month */ solar_insol, /* average daily solar radiation per ft^2 for coldest month */ coldest_mon, /* coldest month: number in range 1..12 */ heating_req, /* Btu / degree day ft^2 requirement for given type of construction */ efficiency, /* % of solar insolation converted to usable heat */ collect_area, /* ft^2 needed to provide heat for coldest month */ ct, /* position in file */ status, /* file status variable */ next_hdd; /* one heating degree days value */ double floor_space, /* ft^2 */ heat_loss, /* Btu's lost in coldest month */ energy_resrc; /* Btu's heat obtained from 1 ft^2 collecting area in coldest month */ FILE *hdd_file; /* average heating degree days for each of 12 months */ FILE *solar_file; /* average solar insolation for each of 12 months */ /* Get average heating degree days for coldest month from file */ hdd_file = fopen("hdd.txt", "r"); fscanf(hdd_file, "%d", &heat_deg_days); coldest_mon = 1; ct = 2; status = fscanf(hdd_file, "%d", &next_hdd); while (status == 1) { if (next_hdd > heat_deg_days) { heat_deg_days = next_hdd; coldest_mon = ct; } ++ct; status = fscanf(hdd_file, "%d", &next_hdd); } fclose(hdd_file); /* Get corresponding average daily solar insolation from other file */ solar_file = fopen("solar.txt", "r"); solar_insol = nth_item(solar_file, coldest_mon); fclose(solar_file); /* Get from user specifics of this house */ printf("What is the approximate heating requirement (Btu / "); printf("degree day ft^2)\nof this type of construction?\n=> "); scanf("%d", &heating_req); printf("What percent of solar insolation will be converted "); printf("to usable heat?\n=> "); scanf("%d", &efficiency); printf("What is the floor space (ft^2)?\n=> "); scanf("%lf", &floor_space); /* Project collecting area needed */ heat_loss = heating_req * floor_space * heat_deg_days; energy_resrc = efficiency * 0.01 * solar_insol * days_in_month(coldest_mon); collect_area = (int)(heat_loss / energy_resrc + 0.5); /* Display results */ printf("To replace heat loss of %.0f Btu in the ", heat_loss); printf("coldest month (month %d)\nwith available ", coldest_mon); printf("solar insolation of %d Btu / ft^2 / day,", solar_insol); printf(" and an\nefficiency of %d percent,", efficiency); printf(" use a solar collecting area of %d", collect_area); printf(" ft^2.\n"); return 0; }