📄 acllog.cpp
字号:
Error = AclEntryDoc.CreateItem("DelDoc", DelDocFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText CrePAgFld;
if (Entry.GetCanCreatePersonalAgents())
{
Error = CrePAgFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = CrePAgFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("CrePAg", CrePAgFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText CrePFVFld;
if (Entry.GetCanCreatePersonalFolders())
{
Error = CrePFVFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = CrePFVFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("CrePFV", CrePFVFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText CreSFVFld;
if (Entry.GetCanCreateSharedFolders())
{
Error = CreSFVFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = CreSFVFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("CreSFV", CreSFVFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText CreLSAFld;
if (Entry.GetCanCreateLotusScript())
{
Error = CreLSAFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = CreLSAFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("CreLSA", CreLSAFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText ReadDocFld;
if (Entry.GetCanReadPublicDocuments())
{
Error = ReadDocFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = ReadDocFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("ReadDoc", ReadDocFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
LNText WriteDocFld;
if (Entry.GetCanWritePublicDocuments())
{
Error = WriteDocFld.SetValue("Yes");
if (Error)
return Error;
}
else
{
Error = WriteDocFld.SetValue("No");
if (Error)
return Error;
}
Error = AclEntryDoc.CreateItem("WriteDoc", WriteDocFld, LNITEMFLAGS_SUMMARY);
if (Error)
return Error;
// Save the newly created document to disk but leave it open
// for appends to the log entry field.
Error = AclEntryDoc.Save();
if (Error)
return Error;
return LNNOERROR;
} // END ACLLog::AddACLEntry
//---------------------------------------------------------------------------
//
// Name:
// ACLLog::CloseLogEntry
//
// Description:
// Closes the current ACL LogEntry note.
//---------------------------------------------------------------------------
LNSTATUS ACLLog::CloseLogEntry()
{
LNSTATUS Error;
if (! IsDocOpen )
return LNNOERROR;
// Close the new document.
Error = AclEntryDoc.Close();
if (Error)
return Error;
// Reset those flags!
IsDocOpen = FALSE;
return LNNOERROR;
} // END ACLLog::CloseLogEntry
//
// END ACLLog class implementation.
//
//---------------------------------------------------------------------------
//
// Name:
// ProcessArguments
//
// Description:
// Scan the input command line and sort out the input strings.
// If no arguments were supplied, prompt for them.
//
// Throws exceptions:
// char * Argument error description
//---------------------------------------------------------------------------
void ProcessArguments (
int argc,
char *argv[],
LNString *DatabasePath,
LNString *ServerName)
{
LNBOOL Prompt = FALSE;
if (argc < 2)
Prompt = TRUE;
// Set up the default parameters first.
InitDefaultParams();
*DatabasePath = ParamString1;
*ServerName = ParamString2;
if (Prompt)
{
// Get user input data by prompting.
GetArguments();
*DatabasePath = ParamString1;
*ServerName = ParamString2;
}
else
{
// Parse the command line.
*DatabasePath = argv[1];
*ServerName = argv[2];
} // END if (argc < 1) ELSE
} // END ProcessArguments()
//---------------------------------------------------------------------------
//
// Name:
// InitDefaultParams
//
// Description:
// Set up all the default parameter strings and numbers for user
// input. Called by ProcessArguments() if no user input params
// were provided.
//
// NOTE:
// You only need to edit this function and ProcessArguments()
// when creating a new sample. The rest of the user interface
// functions below are called by ProcessArguments() and are
// generic and can stay the same unless you modify the number of
// parameters.
//
//---------------------------------------------------------------------------
void InitDefaultParams()
{
// Initialize default parameter strings.
PromptString1 = "File path name for the database to iterate ACL Entries: [";
ParamString1 = "names.nsf";
PromptString2 = "Server name for the database: [";
ParamString2 = "";
} // END InitDefaultParams()
//---------------------------------------------------------------------------
//
// Name:
// GetArguments
//
// Description:
// Allows the user to change any or all of the input parameter
// IOParameter. The inputs can also be left as they are if desired.
//---------------------------------------------------------------------------
void GetArguments()
{
BOOL IsCorrectData = FALSE;
QueryArguments();
while(! IsCorrectData)
{
PrintArguments();
cout << "Are these current data settings correct? : [Y] ";
cin >> CommandBuf;
switch( CommandBuf[0] )
{
case 'Y':
case 'y':
IsCorrectData = TRUE; // All Done, Get out now!
break;
default:
// Prompt again for anything other than a "Y" or "CARRIAGE RETURN".
if( (CommandBuf) != (const char *)"" )
QueryArguments();
else
IsCorrectData = TRUE; // All Done, Get out now!
} // END switch
} // END while
} // END GetArguments()
//---------------------------------------------------------------------------
//
// Name:
// QueryArguments
//
// Description:
// Queries the user to change any of the input parameters.
// A carriage return on any of the prompts leaves it alone.
//---------------------------------------------------------------------------
void QueryArguments()
{
cout << endl;
cout << "Enter the following parameters (Enter by itself takes the default):" << endl;
cout << endl;
// Prompt for strings.
cout << PromptString1 << ParamString1 << "]> ";
cin >> CommandBuf;
if( (CommandBuf) != (const char *)"" )
ParamString1 = CommandBuf;
cout << PromptString2 << ParamString2 << "]> ";
cin >> CommandBuf;
if( (CommandBuf) != (const char *)"" )
ParamString2 = CommandBuf;
} // END QueryArguments()
//---------------------------------------------------------------------------
//
// Name:
// PrintArguments
//
// Description:
// Prints out all of the current input parameters to use.
//---------------------------------------------------------------------------
void PrintArguments()
{
cout << endl;
cout << "The current default data settings are: " << endl;
cout << endl;
// Print out current parameter strings.
cout << PromptString1 << ParamString1 << "]" << endl;
cout << PromptString2 << ParamString2 << "]" << endl;
} // END PrintArguments()
//===========================================================================
//
// IOPARAMETER Class implementation
//
// Description:
// Implementation for a simple generic string buffer class
// to hold user input and output prompts.
//===========================================================================
//===========================================================================
// Constructors.
//===========================================================================
IOParameter::IOParameter() // Default constructor.
{
Size =1; // null terminator.
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
BufferPointer[0] = '\0';
}
//===========================================================================
IOParameter::IOParameter( const char *Str ) // Init with const string.
{
Size = strlen(Str) + 1; // Size of string + null term.
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Str);
}
//===========================================================================
// Constructs a decimal radix string representation of an integer.
IOParameter::IOParameter( const int Number )
{
char Buffer[16]; // Temporary buffer for characters.
sprintf(Buffer, "%d", Number);
Size = strlen(Buffer) + 1; // Size of string + null term.
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Buffer);
}
//===========================================================================
IOParameter::IOParameter( const IOParameter &Other ) // Copy constructor.
{
Size = Other.Size;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Other.BufferPointer);
}
//===========================================================================
// Constructor using 2 IOParameter objects as input.
IOParameter::IOParameter( const IOParameter& Prefix, const IOParameter& Postfix)
{
Size = Prefix.Size + Postfix.Size - 1;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Prefix.BufferPointer);
strcat(BufferPointer, Postfix.BufferPointer);
}
//===========================================================================
// Subscript, etc.
//===========================================================================
char IOParameter::operator [] (int Index)
{
char Character;
if (Index > Size)
Character = '\0';
else
Character = BufferPointer[Index];
return Character;
}
//===========================================================================
// Assignment.
//===========================================================================
IOParameter IOParameter::operator = ( const IOParameter &Other )
{
if(BufferPointer)
delete [] BufferPointer;
Size = Other.Size;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Other.BufferPointer);
return *this;
}
//===========================================================================
IOParameter IOParameter::operator = ( const char *Str )
{
Size = strlen(Str) +1;
if (BufferPointer)
delete [] BufferPointer;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, Str);
return *this;
}
//===========================================================================
// I/O operators.
//===========================================================================
ostream &operator << ( ostream &Stream, const IOParameter &Other )
{
Stream << Other.BufferPointer;
return Stream;
}
//===========================================================================
istream &operator >> ( istream &Stream, IOParameter &Other )
{
const int BufferLength = 255; // Arbitrary size; change if needed.
char T[BufferLength]; // temp string...
int Length;
for (Length=0; Length<BufferLength; Length++)
{
Stream.get(T[Length]);
if (T[Length] == '\n') // New line character.
break;
if (T[Length] == '\b') // Backspace character.
{
if(Length)
{
Length--;
// cout << "'\b'"; // For debug only.
}
}
}
T[Length] = '\0';
Length++;
if(Other.BufferPointer)
delete [] Other.BufferPointer;
if (! (Other.BufferPointer = new char[Length]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
Other.Size = Length;
strcpy(Other.BufferPointer, T);
return Stream;
} // END istream &operator >>
//===========================================================================
// Concatenate.
//===========================================================================
IOParameter IOParameter::operator + ( const IOParameter &Other ) // Cat 2 IOParameter objects.
{
return IOParameter( *this, Other );
}
//===========================================================================
IOParameter IOParameter::operator + ( const char *Str ) // Cat IOParameter and string.
{
return IOParameter( *this, IOParameter(Str) );
}
//===========================================================================
IOParameter operator + ( char *Str, const IOParameter &Other ) // Cat string with IOParameter.
{
return IOParameter( IOParameter(Str), Other );
}
//===========================================================================
IOParameter& IOParameter::operator << ( const IOParameter &Other ) // Cat 2 IOParameter objects.
{
IOParameter TempString(*this);
Size = TempString.Size + Other.Size - 1;
if (BufferPointer)
delete [] BufferPointer;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, TempString.BufferPointer);
strcat(BufferPointer, Other.BufferPointer);
return *this;
}
//===========================================================================
IOParameter& IOParameter::operator << ( const char *Str ) // Cat IOParameter and string.
{
IOParameter TempString(*this);
IOParameter Other(Str);
Size = TempString.Size + Other.Size - 1;
if (BufferPointer)
delete [] BufferPointer;
if(! (BufferPointer = new char[Size]) )
{
cout << "IOParameter: Allocation Error!!!" << endl;
exit(1);
}
strcpy(BufferPointer, TempString.BufferPointer);
strcat(BufferPointer, Other.BufferPointer);
return *this;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -