#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
/*}}}*/
using namespace std;
+const char *Machine_;
+const char *SerialNumber_;
+
void CfrsError(const char *name, CFReadStreamRef rs) {
CFStreamError se = CFReadStreamGetError(rs);
char *url = strdup(Queue->Uri.c_str());
url:
- URI uri = Queue->Uri;
+ URI uri = std::string(url);
std::string hs = uri.Host;
struct hostent *he = gethostbyname(hs.c_str());
CFRelease(sr);
}
+ sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se);
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr);
+ CFRelease(sr);
+
+ sr = CFStringCreateWithCString(kCFAllocatorDefault, SerialNumber_, se);
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Serial-Number"), sr);
+ CFRelease(sr);
+
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.98"));
sr = CFStringCreateWithCString(kCFAllocatorDefault, hs.c_str(), se);
setlocale(LC_ALL, "");
HttpMethod Mth;
+
+ size_t size;
+ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+ char *machine = new char[size];
+ sysctlbyname("hw.machine", machine, &size, NULL, 0);
+ Machine_ = machine;
+
+ if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice"))
+ if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) {
+ if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) {
+ SerialNumber_ = strdup(CFStringGetCStringPtr((CFStringRef) serial, CFStringGetSystemEncoding()));
+ CFRelease(serial);
+ }
+
+ IOObjectRelease(service);
+ }
return Mth.Loop();
}
#include <apt-pkg/error.h>
#include <apt-pkg/hashes.h>
+#include <sys/sysctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
/*}}}*/
using namespace std;
+const char *Machine_;
+const char *SerialNumber_;
+
void CfrsError(const char *name, CFReadStreamRef rs) {
CFStreamError se = CFReadStreamGetError(rs);
char *url = strdup(Queue->Uri.c_str());
url:
- URI uri = Queue->Uri;
+ URI uri = std::string(url);
std::string hs = uri.Host;
struct hostent *he = gethostbyname(hs.c_str());
CFRelease(sr);
}
+ sr = CFStringCreateWithCString(kCFAllocatorDefault, Machine_, se);
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Machine"), sr);
+ CFRelease(sr);
+
+ sr = CFStringCreateWithCString(kCFAllocatorDefault, SerialNumber_, se);
+ CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("X-Serial-Number"), sr);
+ CFRelease(sr);
+
CFHTTPMessageSetHeaderFieldValue(hm, CFSTR("User-Agent"), CFSTR("Telesphoreo APT-HTTP/1.0.98"));
sr = CFStringCreateWithCString(kCFAllocatorDefault, hs.c_str(), se);
setlocale(LC_ALL, "");
HttpMethod Mth;
+
+ size_t size;
+ sysctlbyname("hw.machine", NULL, &size, NULL, 0);
+ char *machine = new char[size];
+ sysctlbyname("hw.machine", machine, &size, NULL, 0);
+ Machine_ = machine;
+
+ if (CFMutableDictionaryRef dict = IOServiceMatching("IOPlatformExpertDevice"))
+ if (io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, dict)) {
+ if (CFTypeRef serial = IORegistryEntryCreateCFProperty(service, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0)) {
+ SerialNumber_ = strdup(CFStringGetCStringPtr((CFStringRef) serial, CFStringGetSystemEncoding()));
+ CFRelease(serial);
+ }
+
+ IOObjectRelease(service);
+ }
return Mth.Loop();
}
# The http method
PROGRAM=http
-SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CFNetwork -framework CoreFoundation -framework SystemConfiguration
+SLIBS = -lapt-pkg $(SOCKETLIBS) -framework CFNetwork -framework CoreFoundation -framework SystemConfiguration -framework IOKit
LIB_MAKES = apt-pkg/makefile
SOURCE = http.cc rfc2553emu.cc connect.cc
include $(PROGRAM_H)