void AstroTest::TestCoverage(void) { UErrorCode status = U_ZERO_ERROR; initAstro(status); ASSERT_OK(status); GregorianCalendar *cal = new GregorianCalendar(1958, UCAL_AUGUST, 15,status); UDate then = cal->getTime(status); CalendarAstronomer *myastro = new CalendarAstronomer(then); ASSERT_OK(status); //Latitude: 34 degrees 05' North //Longitude: 118 degrees 22' West double laLat = 34 + 5./60, laLong = 360 - (118 + 22./60); CalendarAstronomer *myastro2 = new CalendarAstronomer(laLong, laLat); double eclLat = laLat * CalendarAstronomer::PI / 360; double eclLong = laLong * CalendarAstronomer::PI / 360; CalendarAstronomer::Ecliptic ecl(eclLat, eclLong); CalendarAstronomer::Equatorial eq; CalendarAstronomer::Horizon hor; logln("ecliptic: " + ecl.toString()); CalendarAstronomer *myastro3 = new CalendarAstronomer(); myastro3->setJulianDay((4713 + 2000) * 365.25); CalendarAstronomer *astronomers[] = { myastro, myastro2, myastro3, myastro2 // check cache }; for (uint32_t i = 0; i < UPRV_LENGTHOF(astronomers); ++i) { CalendarAstronomer *anAstro = astronomers[i]; //logln("astro: " + astro); logln((UnicodeString)" date: " + anAstro->getTime()); logln((UnicodeString)" cent: " + anAstro->getJulianCentury()); logln((UnicodeString)" gw sidereal: " + anAstro->getGreenwichSidereal()); logln((UnicodeString)" loc sidereal: " + anAstro->getLocalSidereal()); logln((UnicodeString)" equ ecl: " + (anAstro->eclipticToEquatorial(eq,ecl)).toString()); logln((UnicodeString)" equ long: " + (anAstro->eclipticToEquatorial(eq, eclLong)).toString()); logln((UnicodeString)" horiz: " + (anAstro->eclipticToHorizon(hor, eclLong)).toString()); logln((UnicodeString)" sunrise: " + (anAstro->getSunRiseSet(TRUE))); logln((UnicodeString)" sunset: " + (anAstro->getSunRiseSet(FALSE))); logln((UnicodeString)" moon phase: " + anAstro->getMoonPhase()); logln((UnicodeString)" moonrise: " + (anAstro->getMoonRiseSet(TRUE))); logln((UnicodeString)" moonset: " + (anAstro->getMoonRiseSet(FALSE))); logln((UnicodeString)" prev summer solstice: " + (anAstro->getSunTime(CalendarAstronomer::SUMMER_SOLSTICE(), FALSE))); logln((UnicodeString)" next summer solstice: " + (anAstro->getSunTime(CalendarAstronomer::SUMMER_SOLSTICE(), TRUE))); logln((UnicodeString)" prev full moon: " + (anAstro->getMoonTime(CalendarAstronomer::FULL_MOON(), FALSE))); logln((UnicodeString)" next full moon: " + (anAstro->getMoonTime(CalendarAstronomer::FULL_MOON(), TRUE))); } delete myastro2; delete myastro3; delete myastro; delete cal; closeAstro(status); ASSERT_OK(status); }
/* processDHCP(): * Actually this is processBOOTP, but we call it processDHCP here so that * the same code in enetcore.c can be used to call either function (depending * on what has been configured into the uMon build). */ int processDHCP(struct ether_header *ehdr,ushort size) { char getbootfile = 0; struct ip *ihdr; struct Udphdr *uhdr; struct bootphdr *bhdr; ulong ip, temp_ip, cookie; uchar buf[16], bootsrvrip[16], *op; ihdr = (struct ip *)(ehdr + 1); uhdr = (struct Udphdr *)((char *)ihdr + IP_HLEN(ihdr)); bhdr = (struct bootphdr *)(uhdr+1); /* Verify incoming transaction id matches the previous outgoing value: */ if (xidCheck((char *)&bhdr->transaction_id,1) < 0) return(-1); /* If bootfile is nonzero, store it into BOOTFILE shell var: */ if (bhdr->bootfile[0]) getbootfile++; /* Assign IP "server_ip" to the BOOTSRVR shell var (if non-zero): */ memcpy((char *)&temp_ip,(char *)&bhdr->server_ip,4); if (temp_ip) getbootfile++; IpToString(temp_ip,(char *)bootsrvrip); /* Assign IP address loaded in "your_ip" to the IPADD shell var: */ memcpy((char *)BinIpAddr,(char *)&bhdr->your_ip,4); memcpy((char *)&temp_ip,(char *)&bhdr->your_ip,4); printf("IP: %s\n",IpToString(temp_ip,(char *)buf)); /* If STANDARD_MAGIC_COOKIE exists, then process options... */ memcpy((char *)&cookie,(char *)bhdr->vsa,4); if (cookie == ecl(STANDARD_MAGIC_COOKIE)) { /* Assign subnet mask option to NETMASK shell var (if found): */ op = DhcpGetOption(DHCPOPT_SUBNETMASK,&bhdr->vsa[4]); if (op) { memcpy((char *)BinNetMask,(char *)op+2,4); memcpy((char *)&ip,(char *)op+2,4); printf("NETMASK: %s\n",IpToString(ip,(char *)buf)); } /* Assign first router option to GIPADD shell var (if found): */ /* (the router option can have multiple entries, and they are */ /* supposed to be in order of preference, so use the first one) */ op = DhcpGetOption(DHCPOPT_ROUTER,&bhdr->vsa[4]); if (op) { memcpy((char *)BinGipAddr,(char *)op+2,4); memcpy((char *)&ip,(char *)op+2,4); printf("GIPADD: %s\n",IpToString(ip,(char *)buf)); } } /* Call loadBootFile() which will then kick off a tftp client * transfer if both BOOTFILE and BOOTSRVR shell variables are * loaded; otherwise, we are done. */ /* If the bootp server gave us the bootfile and boot server IP, * then call loadBootFile()... */ if (getbootfile == 2) loadBootFile((char *)bhdr->bootfile,(char *)bootsrvrip); else DHCPState = BOOTPSTATE_COMPLETE; return(0); }