本文整理汇总了C++中Put函数的典型用法代码示例。如果您正苦于以下问题:C++ Put函数的具体用法?C++ Put怎么用?C++ Put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Put函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Put
BaseFormat& BaseFormat::operator<<(wchar_t Value)
{
return Put(&Value,1);
}
示例2: cmd_oidf
/*
* Finalize an OpenID authentication
*/
void cmd_oidf(char *argbuf) {
long len;
char buf[2048];
char thiskey[1024];
char thisdata[1024];
HashList *keys = NULL;
const char *Key;
void *Value;
ctdl_openid *oiddata = (ctdl_openid *) CC->openid_data;
if (CtdlGetConfigInt("c_disable_newu"))
{
cprintf("%d this system does not support openid.\n",
ERROR + CMD_NOT_SUPPORTED);
return;
}
if (oiddata == NULL) {
cprintf("%d run OIDS first.\n", ERROR + INTERNAL_ERROR);
return;
}
if (StrLength(oiddata->op_url) == 0){
cprintf("%d No OpenID Endpoint URL has been obtained.\n", ERROR + ILLEGAL_VALUE);
return;
}
keys = NewHash(1, NULL);
if (!keys) {
cprintf("%d NewHash() failed\n", ERROR + INTERNAL_ERROR);
return;
}
cprintf("%d Transmit OpenID data now\n", START_CHAT_MODE);
while (client_getln(buf, sizeof buf), strcmp(buf, "000")) {
len = extract_token(thiskey, buf, 0, '|', sizeof thiskey);
if (len < 0) {
len = sizeof(thiskey) - 1;
}
extract_token(thisdata, buf, 1, '|', sizeof thisdata);
Put(keys, thiskey, len, strdup(thisdata), NULL);
}
/* Check to see if this is a correct response.
* Start with verified=1 but then set it to 0 if anything looks wrong.
*/
oiddata->verified = 1;
char *openid_ns = NULL;
if ( (!GetHash(keys, "ns", 2, (void *) &openid_ns))
|| (strcasecmp(openid_ns, "http://specs.openid.net/auth/2.0"))
) {
syslog(LOG_DEBUG, "This is not an an OpenID assertion");
oiddata->verified = 0;
}
char *openid_mode = NULL;
if ( (!GetHash(keys, "mode", 4, (void *) &openid_mode))
|| (strcasecmp(openid_mode, "id_res"))
) {
oiddata->verified = 0;
}
char *openid_claimed_id = NULL;
if (GetHash(keys, "claimed_id", 10, (void *) &openid_claimed_id)) {
FreeStrBuf(&oiddata->claimed_id);
oiddata->claimed_id = NewStrBufPlain(openid_claimed_id, -1);
syslog(LOG_DEBUG, "Provider is asserting the Claimed ID '%s'", ChrPtr(oiddata->claimed_id));
}
/* Validate the assertion against the server */
syslog(LOG_DEBUG, "Validating...");
CURL *curl;
CURLcode res;
struct curl_httppost *formpost = NULL;
struct curl_httppost *lastptr = NULL;
char errmsg[1024] = "";
StrBuf *ReplyBuf = NewStrBuf();
curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "openid.mode",
CURLFORM_COPYCONTENTS, "check_authentication",
CURLFORM_END
);
HashPos *HashPos = GetNewHashPos(keys, 0);
while (GetNextHashPos(keys, HashPos, &len, &Key, &Value) != 0) {
if (strcasecmp(Key, "mode")) {
char k_o_keyname[1024];
snprintf(k_o_keyname, sizeof k_o_keyname, "openid.%s", (const char *)Key);
curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, k_o_keyname,
CURLFORM_COPYCONTENTS, (char *)Value,
CURLFORM_END
);
}
}
DeleteHashPos(&HashPos);
//.........这里部分代码省略.........
示例3: enter_emote
void enter_emote(User *usr) {
char name[MAX_NAME], line[MAX_LINE], *p, *endp;
XMsg *x;
int sent;
if ((x = new_XMsg()) == NULL) {
Put(usr, "<red>Due to an error, you can not send messages now\n");
return;
}
if (edit_recipients(usr, multi_x_access) == -1) {
destroy_XMsg(x);
return;
}
if (usr->recipients.len <= 0) {
destroy_XMsg(x);
return;
}
check_recipients(usr);
if (usr->recipients.len <= 0) {
destroy_XMsg(x);
return;
}
/* enter the message text */
Print(usr, "<cyan>* <white>%s <yellow>", usr->name);
if (edit_line(usr, line, MAX_LINE) == -1 || !line[0]) {
Put(usr, "<red>Message not sent\n");
destroy_XMsg(x);
return;
}
ctrim_line(line);
if (!line[0]) {
Put(usr, "<red>Message not sent\n");
destroy_XMsg(x);
return;
}
if (add_XMsg_line(x, line) == -1) {
Put(usr, "<red>Due to an error, you can not send messages now\n");
destroy_XMsg(x);
return;
}
check_recipients(usr);
if (usr->recipients.len <= 0) {
destroy_XMsg(x);
return;
}
set_XMsg(x, XMSG_EMOTE, usr->name, usr->recipients.str, time(NULL));
sent = 0;
p = usr->recipients.str;
while((endp = cstrchr(p, ',')) != NULL) {
*endp = 0;
cstrcpy(name, p, MAX_NAME);
*endp = ',';
endp++;
p = endp;
sent += send_xmsg(usr, x, name);
}
cstrcpy(name, p, MAX_NAME);
sent += send_xmsg(usr, x, name);
if (sent)
send_xmsg_bcc(usr, x); /* remember message as sent in 'this' user */
else
destroy_XMsg(x);
}
示例4: snprintf
bool cRemote::Put(uint64_t Code, bool Repeat, bool Release)
{
char buffer[32];
snprintf(buffer, sizeof(buffer), "%016llX", Code);
return Put(buffer, Repeat, Release);
}
示例5: helper
/*
select the next helper to ask a question
if we previously called for help, go back to the same helper (if available)
helpers are selected in an LRU manner
silent can be GH_SILENT, which means to be silent
*/
User *get_helper(User *usr, int silent) {
User *u;
PList *pl;
char instead[24] = "";
if (usr == NULL || !PARAM_HAVE_QUESTIONS)
return NULL;
if (usr->question_asked != NULL) {
for(pl = (PList *)helpers.tail; pl != NULL; pl = pl->next) {
u = (User *)pl->p;
if (!strcmp(u->name, usr->name))
continue;
if (!strcmp(usr->question_asked, u->name)) {
(void)remove_PQueue(&helpers, pl);
if (!(u->flags & USR_HELPING_HAND) || u->total_time / SECS_IN_DAY < PARAM_HELPER_AGE) {
u->flags &= ~USR_HELPING_HAND;
destroy_PList(pl);
break;
}
(void)add_PQueue(&helpers, pl);
if (!silent)
Print(usr, "<green>The question goes to <yellow>%s\n", usr->question_asked);
return u;
}
}
Print(usr, "<yellow>%s<red> is no longer available to help you\n", usr->question_asked);
Free(usr->question_asked);
usr->question_asked = NULL;
strcpy(instead, " <green>instead");
}
while(count_Queue(&helpers) > 0) {
if ((pl = pop_PQueue(&helpers)) == NULL) {
Put(usr, "<red>Sorry, but currently there is no one available to help you\n");
return NULL;
}
u = (User *)pl->p;
if (!u->name[0] || !(u->flags & USR_HELPING_HAND) || u->total_time / SECS_IN_DAY < PARAM_HELPER_AGE) {
u->flags &= ~USR_HELPING_HAND;
destroy_PList(pl);
continue;
}
(void)add_PQueue(&helpers, pl);
if (!strcmp(u->name, usr->name)) {
if (count_Queue(&helpers) > 1)
continue;
Put(usr, "<red>Sorry, but currently there is no one available to help you\n");
return NULL;
}
Free(usr->question_asked);
usr->question_asked = cstrdup(u->name);
if (!silent || instead[0])
Print(usr, "<green>The question goes to <yellow>%s%s\n", usr->question_asked, instead);
return u;
}
Put(usr, "<red>Sorry, but currently there is no one available to help you\n");
return NULL;
}
示例6: main
int main() {
// Create the main SFML window
sf::RenderWindow app_window( sf::VideoMode( 800, 600 ), "SFGUI Layout Example", sf::Style::Titlebar | sf::Style::Close );
// We have to do this because we don't use SFML to draw.
app_window.resetGLStates();
// Create an SFGUI. This is required before doing anything with SFGUI.
sfg::SFGUI sfgui;
// Create our main SFGUI window
auto window = sfg::Window::Create();
window->SetTitle( "Resize me!" );
// Create a box with 20 pixels spacing.
auto box = sfg::Box::Create( sfg::Box::Orientation::VERTICAL, 20.f );
// Create some buttons.
auto button_aligned = sfg::Button::Create( "Aligned 0.8f right and bottom" );
auto button_fixed = sfg::Button::Create( "Fixed at (200, 50)" );
// Create a fixed.
auto fixed = sfg::Fixed::Create();
// Add button_fixed to the fixed at (200, 50).
fixed->Put( button_fixed, sf::Vector2f( 200.f, 50.f ) );
// Add our fixed to the box and set not to expand.
box->Pack( fixed, false, true );
// Create a separator.
auto separator = sfg::Separator::Create( sfg::Separator::Orientation::HORIZONTAL );
// Add separator to box and set not to expand.
box->Pack( separator, false, true );
// Create an alignment.
auto alignment = sfg::Alignment::Create();
// Because we want to align our button horizontally, we need
// to place our alignment in a horizontal box set to expand and fill.
auto alignment_box = sfg::Box::Create( sfg::Box::Orientation::HORIZONTAL );
alignment_box->Pack( alignment, true, true );
// Add button_aligned to the alignment.
alignment->Add( button_aligned );
// Set scaling parameters.
// Scaling sets how much of the total space in the alignment
// the child gets to fill up. 1.0f for x and y would mean the
// child gets to use the whole space. Setting it to 0.0f for
// x and y makes the child get as little space as possible.
alignment->SetScale( sf::Vector2f( .0f, .0f ) );
// Set alignment parameters.
// Alignment aligns the child widget within the alignment's area.
// 0.0f for x aligns to the left, 1.0f for x aligns to the right.
// 0.0f for y aligns to the top, 1.0f for y aligns to the bottom.
alignment->SetAlignment( sf::Vector2f( .8f, .8f ) );
// Create our frame.
auto frame = sfg::Frame::Create( "Frame Title" );
// We can align the frame title just like an alignment.
frame->SetAlignment( sf::Vector2f( .8f, .5f ) );
// Add our alignment box into the frame.
frame->Add( alignment_box );
// Add our frame to the box.
box->Pack( frame, true, true );
// Add the box to the window.
window->Add( box );
// Start the game loop
while ( app_window.isOpen() ) {
// Process events
sf::Event event;
while ( app_window.pollEvent( event ) ) {
// Handle events
window->HandleEvent( event );
// Close window : exit
if ( event.type == sf::Event::Closed ) {
app_window.close();
}
}
// Update the GUI, note that you shouldn't normally
// pass 0 seconds to the update method.
window->Update( 0.f );
// Clear screen
app_window.clear();
// Draw the GUI
sfgui.Display( app_window );
//.........这里部分代码省略.........
示例7: sin
const long * KTextPipe::Percent(TCHAR tag, const long * data, const DicItem * dic)
{
static double dummy = sin(0.0); // just to link-in floating point support
int len = 0;
switch ( tag )
{
case '_': len = 4; break; // skip 4 bytes
case '0': WriteDec(data[0]); break; // decimal signed long
case '1': WriteDec(data[1]); break; // decimal signed long
case '2': WriteDec(data[2]); break; // decimal signed long
case '3': WriteDec(data[3]); break; // decimal signed long
case '4': WriteDec(data[4]); break; // decimal signed long
case '5': WriteDec(data[5]); break; // decimal signed long
case '6': WriteDec(data[6]); break; // decimal signed long
case '7': WriteDec(data[7]); break; // decimal signed long
case '8': WriteDec(data[8]); break; // decimal signed long
case '9': WriteDec(data[9]); break; // decimal signed long
case 'b': WriteDec((long)(* ((unsigned char *) data))); // signed char
len = 1;
break;
case 'c':
{
char ch = * data & 0xFF;
if ( (ch>=' ') && (ch<=0x7F) )
Put(ch);
else
Put('.');
len = 1;
}
break;
case 'd': WriteDec( data[0]); len=4; break; // decimal signed long
case 'u': WriteDec((unsigned long) data[0]); len=4; break; // decimal unsigned long
case 'x': WriteHex( data[0]); len=4; break; // hex unsigned long
case 'D': WriteDec((long) (* ((short *) data))); len=2; break; // signed short
case 'U': WriteDec((unsigned long)(* ((unsigned short *) data))); len=2; break; // signed short
case 'X': WriteHex( * ((unsigned short *) data)); len=2; break; // unsigned short
case 'S': WriteString(data, -1, true); break; // wide string
case 's': WriteString(data, -1, false); break; // ascii string
case 'f': { TCHAR t[32]; float f = * (float *) data; _stprintf(t, _T("%8.5f"), f); Write(t); } // float
len = 4;
break;
case 'n': m_nCount++; // sequence count: 1 1 2 2 ...
WriteDec((long)(m_nCount/2));
break;
case 'm': m_mCount++; // sequence count: 1 1 2 2 ...
WriteDec((long)(m_mCount/2));
break;
case 'L': Write(data[0], dic); len = 4; // dic
break;
default : assert(false);
}
return (const long *) ( (const char *) data + len);
}
示例8: Put
nString & nString::operator+=(const nString & right){
for(int i = 0; right.data[i] != '\0'; i++)
Put(right.data[i]);
return *this;
}
示例9: state_help_menu
void state_help_menu(User *usr, char c) {
char filename[MAX_PATHLEN];
if (usr == NULL)
return;
Enter(state_help_menu);
switch(c) {
case INIT_PROMPT:
break;
case INIT_STATE:
usr->runtime_flags |= RTF_BUSY;
buffer_text(usr);
Put(usr, "<magenta>\n"
"<hotkey>Introduction Editing recipient <hotkey>lists\n"
"e<hotkey>Xpress messages Editing with <hotkey>colors\n"
"<hotkey>Friends and enemies <hotkey>Navigating the --More-- prompt\n"
);
Put(usr,
"Reading and posting <hotkey>messages\n"
"The <hotkey>room system\n"
"Customizing your <hotkey>profile <hotkey>Other commands\n"
);
read_menu(usr);
Return;
case ' ':
case KEY_RETURN:
case KEY_CTRL('C'):
case KEY_CTRL('D'):
case KEY_BS:
Put(usr, "\n");
RET(usr);
Return;
case KEY_CTRL('L'):
Put(usr, "\n");
CURRENT_STATE(usr);
Return;
case '`':
CALL(usr, STATE_BOSS);
Return;
case 'i':
case 'I':
Put(usr, "Introduction\n");
HELP_TEXT("intro");
case 'x':
case 'X':
Put(usr, "eXpress Messages\n");
HELP_TEXT("xmsg");
case 'f':
case 'F':
Put(usr, "Friends and Enemies\n");
HELP_TEXT("friends");
case 'm':
case 'M':
Put(usr, "Reading and posting messages\n");
HELP_TEXT("msgs");
case 'r':
case 'R':
Put(usr, "The room system\n");
HELP_TEXT("rooms");
case 'p':
case 'P':
Put(usr, "Customizing your profile\n");
HELP_TEXT("profile");
case 'l':
case 'L':
Put(usr, "Editing recipient lists\n");
HELP_TEXT("recipients");
case 'c':
case 'C':
Put(usr, "Editing with colors\n");
HELP_TEXT("colors");
case 'n':
case 'N':
Put(usr, "Navigating the --More-- prompt\n");
HELP_TEXT("more");
case 'o':
case 'O':
Put(usr, "Other commands\n");
HELP_TEXT("other");
}
Print(usr, "<yellow>\n[Help] %c <white>", (usr->runtime_flags & RTF_SYSOP) ? '#' : '>');
Return;
//.........这里部分代码省略.........
示例10: ProcessLine
/************************************************************************
Function : ProcessLine
Parameters: Line a pointer to the current line of characters to process
Returns : nothing
Analyze line to determine if it is an error message. If so, output
relevant information to the message window.
To be considered an error message, a line must NOT :
. be blank
. start with "Microsoft" or "Copyright" (these lines form the Resource
Compiler header)
Any lines passing the above conditions are considered error messages.
If the line contains a line number, it is of the form:
source-file(LINE #) : message text OR
source-file (LINE #) : message text
that is, it contains a '(' followed by a ':'. The line number
is sent to the Message Window followed by the message text.
If the line does not contain a line number, it is sent verbatim to
the Message Window.
************************************************************************/
void ProcessLine(char *Line)
{
static int HavePutFile = FALSE;
int HasLineNumber;
char Type;
unsigned i;
char *s, *LeftParen, *Colon;
/* if blank line, return */
while( *Line && ( (*Line == '\r') || (*Line == '\n') ) )
Line++;
if( *Line == '\0' )
return;
/* if line starts with "Microsoft" or "Copyright", it's not
an error line */
if( strncmp( Line, "Microsoft", 9 ) == 0 ||
strncmp( Line, "Copyright", 9 ) == 0 )
return;
HasLineNumber = FALSE;
LeftParen = strchr( Line, '(' ); /* if '(' in the line */
if( LeftParen != NULL ) /* Line may contain line number */
HasLineNumber = TRUE;
if( HasLineNumber ) {
Colon = strchr(LeftParen, ':' ); /* if no ':' following the '(' */
if( Colon == NULL ) /* Line doesn't contain line number */
HasLineNumber = FALSE;
}
if( HasLineNumber ) {
s = LeftParen-1; /* position s after last char */
while( *s == ' ' ) /* in filename */
s--;
s++;
*s = 0; /* and null-terminate */
if( strcmp(Line,CurFile) != 0 ) /* if new filename */
{
Type = MsgNewFile; /* indicate by sending type
out to message window */
strcpy(CurFile,Line);
Put(&Type,1);
Put(CurFile,strlen(CurFile)+1); /* along with the new name */
HavePutFile = TRUE;
}
s = strchr(Line,')'); /* find the right paren */
*s = 0; /* and null-terminate line# */
i = atoi(LeftParen+1); /* line# starts after ( */
/* convert line# to integer */
Type = MsgNewLine; /* set type to new line */
Put(&Type,1); /* indicate need for new line */
Put((char *)&i,2); /* put the number out */
i=1; /* set column in message box */
Put((char *)&i,2); /* tab over to put message */
s = Colon+1; /* position s at first */
while( *s == ' ' ) /* non-blank char after : */
s++; /* Rest of line is message */
Put( s,strlen(s)+1); /* output the message */
}
else { /* no line number */
if( !HavePutFile )
{
/* IDE expects the first message to
be preceded by a filename. Since
we don't have one, fake it by
sending a NULL file before the
//.........这里部分代码省略.........
示例11: seed
void AutoSeededRandomPool::Reseed(bool blocking, unsigned int seedSize)
{
SecByteBlock seed(seedSize);
OS_GenerateRandomBlock(blocking, seed, seedSize);
Put(seed, seedSize);
}
示例12: NullToEmpty
BaseFormat& BaseFormat::operator<<(LPCWSTR Data)
{
Data = NullToEmpty(Data);
return Put(Data, StrLength(Data));
}
示例13: DiffersIndex
int AbstractDeltaRowCompressor::CompressRaw(const uchar* row, bool updateSeedRow, bool updateDeltaRow)
{
int index = DiffersIndex(row, 0);
if (index == -1) {
// no differences
return 0;
}
fUpdateDeltaRow = updateDeltaRow;
fDeltaRowIndex = 0;
int seedRowIndex = 0;
do {
int length = DiffersLength(row, index);
// delta starts at index and contains length bytes
do {
// control byte limits data bytes to 8 bytes
int deltaBytes = length;
if (length > 8) {
deltaBytes = 8;
}
// calculate offset
int totalOffset = index - seedRowIndex;
bool needsOffsetBytes = totalOffset > 30;
int offset = totalOffset;
// control byte limits offset value to 31
if (needsOffsetBytes) {
offset = 31;
}
// write control byte (delta bytes bits 5-7; offset bits 0-4)
Put(((deltaBytes-1) << 5) | offset);
if (needsOffsetBytes) {
// write additional offset bytes after control byte
// the last offset byte must be less than 255
totalOffset -= offset;
while (totalOffset >= 255) {
Put(255);
totalOffset -= 255;
}
Put(totalOffset);
}
// write data bytes
for (int i = 0; i < deltaBytes; i ++) {
// copy row to seed row and delta row
uchar byte = row[index];
if (updateSeedRow) {
ASSERT (index < fSize);
fSeedRow[index] = byte;
}
Put(byte);
index ++;
}
seedRowIndex = index;
length -= deltaBytes;
} while (length > 0);
index = DiffersIndex(row, index);
} while (index != -1);
return fDeltaRowIndex;
}
示例14: cmd_gvdn
void cmd_gvdn(char *argbuf)
{
const ConfType *pCfg;
char *confptr;
long min = atol(argbuf);
const char *Pos = NULL;
const char *PPos = NULL;
const char *HKey;
long HKLen;
StrBuf *Line;
StrBuf *Config;
StrBuf *Cfg;
StrBuf *CfgToken;
HashList *List;
HashPos *It;
void *vptr;
List = NewHash(1, NULL);
Cfg = NewStrBufPlain(config.c_fqdn, -1);
Put(List, SKEY(Cfg), Cfg, HFreeStrBuf);
Cfg = NULL;
confptr = CtdlGetSysConfig(INTERNETCFG);
Config = NewStrBufPlain(confptr, -1);
free(confptr);
Line = NewStrBufPlain(NULL, StrLength(Config));
CfgToken = NewStrBufPlain(NULL, StrLength(Config));
while (StrBufSipLine(Line, Config, &Pos))
{
if (Cfg == NULL)
Cfg = NewStrBufPlain(NULL, StrLength(Line));
PPos = NULL;
StrBufExtract_NextToken(Cfg, Line, &PPos, '|');
StrBufExtract_NextToken(CfgToken, Line, &PPos, '|');
if (GetHash(CfgNameHash, SKEY(CfgToken), &vptr) &&
(vptr != NULL))
{
pCfg = (ConfType *) vptr;
if (pCfg->Type <= min)
{
Put(List, SKEY(Cfg), Cfg, HFreeStrBuf);
Cfg = NULL;
}
}
}
cprintf("%d Valid Domains\n", LISTING_FOLLOWS);
It = GetNewHashPos(List, 1);
while (GetNextHashPos(List, It, &HKLen, &HKey, &vptr))
{
cputbuf(vptr);
cprintf("\n");
}
cprintf("000\n");
DeleteHashPos(&It);
DeleteHash(&List);
FreeStrBuf(&Cfg);
FreeStrBuf(&Line);
FreeStrBuf(&CfgToken);
FreeStrBuf(&Config);
}
示例15: push_back
inline TX push_back(TX const & obj) { Put(obj); }