void pppdVersion(int *version, int *modification, int *patch) { char buffer[30]; const char *pppd; char *query; *version = *modification = *patch = 0; // locate pppd if(!(pppd = pppdPath())) return; // call pppd with --version option if(!(query = new char[strlen(pppd)+25])) return; strcpy(query, pppd); // had to add a dummy device to prevent a "no device specified // and stdin is not a tty" error from newer pppd versions. strcat(query, " --version /dev/tty 2>&1"); fflush(0L); FILE *output = popen(query, "r"); delete [] query; if(!output) return; // read output int size = fread(buffer, sizeof(char), 29, output); if(ferror(output)) { pclose(output); return; } pclose(output); buffer[size] = '\0'; // find position of version number x.y.z char *p = buffer; while(*p && !isdigit(*p)) p++; if (*p == 0) return; char *p2 = p; while(*p2 == '.' || isdigit(*p2)) p2++; *p2 = '\0'; decode_version(p, version, modification, patch); }
//! Main function to decode edid data void edid_decode(edid1_info *edid, const edid1_raw *raw) { int i; memset(edid, 0, sizeof(edid)); decode_vendor(&edid->vendor, &raw->vendor); decode_version(&edid->version, &raw->version); decode_display(&edid->display, &raw->display); edid->established_timing = raw->established_timing; for (i = 0; i < EDID1_NUM_STD_TIMING; ++i) { decode_std_timing(&edid->std_timing[i], &raw->std_timing[i]); } decode_detailed_monitor(edid->detailed_monitor, raw->detailed_monitor, edid->version.version == 1 && edid->version.revision >= 1); }
int ppp_available(void) { return 1; #if 0 int s, ok; struct ifreq ifr; char abBuffer [1024]; int size; int my_version, my_modification, my_patch; /* * Open a socket for doing the ioctl operations. */ s = socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) { return 0; } strncpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; /* * If the device did not exist then attempt to create one by putting the * current tty into the PPP discipline. If this works then obtain the * flags for the device again. */ if (!ok) { if (ppp_registered()) { strncpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; } } /* * Ensure that the hardware address is for PPP and not something else */ if (ok) { ok = ioctl (s, SIOCGIFHWADDR, (caddr_t) &ifr) >= 0; } if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP)) { ok = 0; } if (!ok) { return 0; } /* * This is the PPP device. Validate the version of the driver at this * point to ensure that this program will work with the driver. */ ifr.ifr_data = abBuffer; size = ioctl (s, SIOCGPPPVER, (caddr_t) &ifr); ok = size >= 0; if (ok) { decode_version (abBuffer, &driver_version, &driver_modification, &driver_patch); } if (!ok) { driver_version = driver_modification = driver_patch = 0; } /* * Validate the version of the driver against the version that we used. */ decode_version (PPP_VERSION, &my_version, &my_modification, &my_patch); /* The version numbers must match */ if (driver_version != my_version) { ok = 0; } /* The modification levels must be legal */ if (driver_modification < my_modification) { ok = 0; } if (!ok) { extern char *no_ppp_msg; no_ppp_msg = route_buffer; sprintf(no_ppp_msg, "Sorry - PPP driver version %d.%d.%d is out of date\n", driver_version, driver_modification, driver_patch); ok = 0; } close(s); return ok; #endif }