diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:49 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:51:49 +0000 |
commit | f46e768107c0250eb0609a89a74b66ab3c9d8cec (patch) | |
tree | a7321ca9fa202a9f0555c3a378170398dba88640 /apt-pkg | |
parent | f00ce0aee4cc79f7511ab942b5e02dddf86beae6 (diff) |
CDROM method
Author: jgg
Date: 1998-12-03 07:29:16 GMT
CDROM method
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/acquire-method.cc | 55 | ||||
-rw-r--r-- | apt-pkg/acquire-method.h | 5 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 9 |
3 files changed, 63 insertions, 6 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index bf2de5448..7c3fdecb3 100644 --- a/apt-pkg/acquire-method.cc +++ b/apt-pkg/acquire-method.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-method.cc,v 1.9 1998/11/29 01:24:15 jgg Exp $ +// $Id: acquire-method.cc,v 1.10 1998/12/03 07:29:16 jgg Exp $ /* ###################################################################### Acquire Method @@ -185,6 +185,59 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt) delete Tmp; } /*}}}*/ +// AcqMethod::MediaFail - Syncronous request for new media /*{{{*/ +// --------------------------------------------------------------------- +/* This sends a 403 Media Failure message to the APT and waits for it + to be ackd */ +void pkgAcqMethod::MediaFail(string Required,string Drive) +{ + char S[1024]; + snprintf(S,sizeof(S),"403 Media Failure\nMedia: %s\nDrive: %s\n\n", + Required.c_str(),Drive.c_str()); + + if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S)) + exit(100); + + vector<string> MyMessages; + + /* Here we read messages until we find a 603, each non 603 message is + appended to the main message list for later processing */ + while (1) + { + if (WaitFd(STDIN_FILENO) == false) + exit(0); + + if (ReadMessages(STDIN_FILENO,MyMessages) == false) + exit(0); + + string Message = MyMessages.front(); + MyMessages.erase(MyMessages.begin()); + + // Fetch the message number + char *End; + int Number = strtol(Message.c_str(),&End,10); + if (End == Message.c_str()) + { + cerr << "Malformed message!" << endl; + exit(100); + } + + // Change ack + if (Number == 603) + { + while (Message.empty() == false) + { + Messages.push_back(MyMessages.front()); + MyMessages.erase(MyMessages.begin()); + } + + return; + } + + Messages.push_back(Message); + } +} + /*}}}*/ // AcqMethod::Configuration - Handle the configuration message /*{{{*/ // --------------------------------------------------------------------- /* This parses each configuration entry and puts it into the _config diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 9e4ac65b6..08c88265c 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-method.h,v 1.4 1998/11/29 01:24:16 jgg Exp $ +// $Id: acquire-method.h,v 1.5 1998/12/03 07:29:17 jgg Exp $ /* ###################################################################### Acquire Method - Method helper class + functions @@ -58,7 +58,8 @@ class pkgAcqMethod void Fail(string Why, bool Transient = false); void URIStart(FetchResult &Res); void URIDone(FetchResult &Res,FetchResult *Alt = 0); - + void MediaFail(string Required,string Drive); + public: enum CnfFlags {SingleInstance = (1<<0), diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index d5f765dd4..273118e9d 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: strutl.cc,v 1.13 1998/11/05 07:21:44 jgg Exp $ +// $Id: strutl.cc,v 1.14 1998/12/03 07:29:18 jgg Exp $ /* ###################################################################### String Util - Some usefull string functions. @@ -630,7 +630,7 @@ void URI::CopyFrom(string U) SingleSlash += 3; for (; SingleSlash < U.end() && *SingleSlash != '/'; SingleSlash++); if (SingleSlash > U.end()) - SingleSlash = U.end(); + SingleSlash = U.end(); // We can now write the access and path specifiers Access = string(U,0,FirstColon - U.begin()); @@ -640,7 +640,10 @@ void URI::CopyFrom(string U) Path = "/"; // Now we attempt to locate a user:pass@host fragment - FirstColon += 3; + if (U[1] == '/' && U[2] == '/') + FirstColon += 3; + else + FirstColon += 1; if (FirstColon >= U.end()) return; |