version 1.3, 2007/01/11 16:22:09
|
version 1.4, 2007/02/13 19:00:55
|
|
|
int clientStatus, | int clientStatus, |
String &pidFile) | String &pidFile) |
{ | { |
String line, searchString, subLine; |
|
int indx = 0; |
|
char pid_str[15]; | char pid_str[15]; |
char status_str[15]; | char status_str[15]; |
char time_str[32]; | char time_str[32]; |
| |
searchString.append(clientId.getCString()); |
|
|
|
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
int offset = 2; | int offset = 2; |
#else | #else |
int offset = 1; | int offset = 1; |
#endif | #endif |
| |
Uint32 whileCount = 0; |
|
|
|
// | // |
// Get current time for time stamp | // Get current time for time stamp |
// | // |
|
|
| |
Boolean addClient= false; | Boolean addClient= false; |
| |
#ifdef PEGASUS_OS_TYPE_WINDOWS |
if (!!pFile) |
if (pFile.is_open()) |
|
#else |
|
if (pFile) |
|
#endif |
|
{ | { |
while(!pFile.eof()) |
String line; |
|
while(!pFile.eof() && GetLine(pFile, line)) |
{ | { |
whileCount++; |
String subLine; |
GetLine (pFile,line); |
|
indx=line.find(':'); |
Uint32 indx=line.find(':'); |
if (indx > 0) |
if (indx != PEG_NOT_FOUND) |
{ | { |
subLine.append(line.subString(0, indx)); |
subLine = line.subString(0, indx); |
} | } |
if (String::compare(subLine, searchString) == 0) |
|
|
if (String::compare(subLine, clientId) == 0) |
{ | { |
long pos; | long pos; |
addClient = true; | addClient = true; |
pos = (long)pFile.tellp(); | pos = (long)pFile.tellp(); |
pFile.seekp(pos - line.size()-offset); | pFile.seekp(pos - line.size()-offset); |
String newLine = String(clientId.getCString()); |
String newLine = clientId; |
newLine.append("::"); | newLine.append("::"); |
newLine.append(pid_str); | newLine.append(pid_str); |
newLine.append("::"); | newLine.append("::"); |
newLine.append(status_str); | newLine.append(status_str); |
newLine.append("::"); | newLine.append("::"); |
newLine.append(time_str); | newLine.append(time_str); |
if (line.size() > newLine.size()) |
|
{ |
Sint32 jSize = line.size() - newLine.size(); |
Uint32 jSize = line.size() - newLine.size(); |
CString newLineCString = newLine.getCString(); |
pFile.write(newLine.getCString(),newLine.size()); |
pFile.write(newLineCString, strlen(newLineCString)); |
for (Uint32 i =0;i<jSize;i++) |
for (Sint32 i = 0; i < jSize; i++) |
{ | { |
pFile.write(" ",1); | pFile.write(" ",1); |
} | } |
} |
|
else |
|
{ |
|
pFile.write(newLine.getCString(),newLine.size()); |
|
} |
|
break; | break; |
} | } |
subLine.clear(); |
|
line.clear(); |
|
} | } |
if(!addClient) | if(!addClient) |
{ | { |