• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Put函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Put函数的典型用法代码示例。如果您正苦于以下问题:C++ Put函数的具体用法?C++ Put怎么用?C++ Put使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Put函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Put

BaseFormat& BaseFormat::operator<<(wchar_t Value)
{
    return Put(&Value,1);
}
开发者ID:rheostat2718,项目名称:conemu-maximus5,代码行数:4,代码来源:format.cpp


示例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);

//.........这里部分代码省略.........
开发者ID:mingodad,项目名称:citadel,代码行数:101,代码来源:serv_openid_rp.c


示例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);
}
开发者ID:walterdejong,项目名称:bbs101,代码行数:73,代码来源:msg_system.c


示例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);
}
开发者ID:Moorviper,项目名称:zen2vdr,代码行数:6,代码来源:remote.c


示例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;
}
开发者ID:walterdejong,项目名称:bbs100,代码行数:73,代码来源:helper.c


示例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 );

//.........这里部分代码省略.........
开发者ID:Cruel,项目名称:SFGUI,代码行数:101,代码来源:Layout.cpp


示例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);
}
开发者ID:b2kguga,项目名称:CodesAndNotes,代码行数:68,代码来源:OutPipe.cpp


示例8: Put

nString & nString::operator+=(const nString & right){
	for(int i = 0; right.data[i] != '\0'; i++)
		Put(right.data[i]);
	return *this;	
}
开发者ID:Kartonschachtel,项目名称:public,代码行数:5,代码来源:nString.C


示例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;
//.........这里部分代码省略.........
开发者ID:walterdejong,项目名称:bbs100,代码行数:101,代码来源:state_help.c


示例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
//.........这里部分代码省略.........
开发者ID:WiLLStenico,项目名称:TestesEOutrasBrincadeiras,代码行数:101,代码来源:rc2msg.c


示例11: seed

void AutoSeededRandomPool::Reseed(bool blocking, unsigned int seedSize)
{
	SecByteBlock seed(seedSize);
	OS_GenerateRandomBlock(blocking, seed, seedSize);
	Put(seed, seedSize);
}
开发者ID:hon1nbo,项目名称:BCTt,代码行数:6,代码来源:osrng.cpp


示例12: NullToEmpty

BaseFormat& BaseFormat::operator<<(LPCWSTR Data)
{
    Data = NullToEmpty(Data);
    return Put(Data, StrLength(Data));
}
开发者ID:rheostat2718,项目名称:conemu-maximus5,代码行数:5,代码来源:format.cpp


示例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;
}
开发者ID:mmanley,项目名称:Antares,代码行数:72,代码来源:DeltaRowCompression.cpp


示例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);
}
开发者ID:henri14,项目名称:citadel,代码行数:63,代码来源:control.c


示例15: push_back

 inline TX push_back(TX const & obj) { Put(obj); }
开发者ID:elfmz,项目名称:far2l,代码行数:1,代码来源:DynamicQueue.hpp


示例16: assert

void KTextPipe::WriteArray(const void * Array, long count, long elmsize, bool decimal)
{
	if ( ! m_bOpened )
		return;

	assert(Array);

	const char  * bArray = (const char *)  Array;
	const short * sArray = (const short *) Array;
	const long  * lArray = (const long *)  Array;
	const RECT  * rArray = (const RECT *)  Array;
	
	Put('{'); Put(' ');
	for (long i=0; i<count; i++)
	{
		if ( i )
		{
			Put(','); 
			
			if ( m_linelen > 78 )
				Newline();
			else
				Put(' ');
		}

		switch ( elmsize )
		{
			case 1:  
				if (decimal) 
					WriteDec((long) bArray[i]); 
				else 
					WriteHex(bArray[i] & 0xFF); 
				break;
			
			case 2:  
				if (decimal) 
					WriteDec((long) sArray[i]); 
				else 
					WriteHex(sArray[i] & 0xFFFF); 
				break;

			case 4:  
				if (decimal) 
					WriteDec(lArray[i]); 
				else 
					WriteHex(lArray[i]); 
				break;

			case sizeof(RECT):
				Write("{ "); WriteDec(rArray[i].left);
				Put(',');    WriteDec(rArray[i].top);
				Put(',');    WriteDec(rArray[i].right);
				Put(',');    WriteDec(rArray[i].bottom);
				Write(" }");
				break;

			default: assert(FALSE);
		}

	}

	Put(' '); Put('}');
}
开发者ID:b2kguga,项目名称:CodesAndNotes,代码行数:63,代码来源:OutPipe.cpp


示例17: while

void cLircRemote::Action(void)
{
  cTimeMs FirstTime;
  cTimeMs LastTime;
  cTimeMs ThisTime;
  char buf[LIRC_BUFFER_SIZE];
  char LastKeyName[LIRC_KEY_BUF] = "";
  bool pressed = false;
  bool repeat = false;
  int timeout = -1;

  while (Running()) {

        bool ready = f >= 0 && cFile::FileReady(f, timeout);
        int ret = ready ? safe_read(f, buf, sizeof(buf)) : -1;

        if (f < 0 || ready && ret <= 0) {
           esyslog("ERROR: lircd connection broken, trying to reconnect every %.1f seconds", float(RECONNECTDELAY) / 1000);
           if (f >= 0)
              close(f);
           f = -1;
           while (Running() && f < 0) {
                 cCondWait::SleepMs(RECONNECTDELAY);
                 if (Connect()) {
                    isyslog("reconnected to lircd");
                    break;
                    }
                 }
           }

        if (ready && ret > 0) {
           buf[ret - 1] = 0;
           int count;
           char KeyName[LIRC_KEY_BUF];
           if (sscanf(buf, "%*x %x %29s", &count, KeyName) != 2) { // '29' in '%29s' is LIRC_KEY_BUF-1!
              esyslog("ERROR: unparseable lirc command: %s", buf);
              continue;
              }
           int Delta = ThisTime.Elapsed(); // the time between two subsequent LIRC events
           ThisTime.Set();
           if (count == 0) {
              if (strcmp(KeyName, LastKeyName) == 0 && FirstTime.Elapsed() < (uint)Setup.RcRepeatDelay)
                 continue; // skip keys coming in too fast
              if (repeat)
                 Put(LastKeyName, false, true);
              strcpy(LastKeyName, KeyName);
              pressed = true;
              repeat = false;
              FirstTime.Set();
              timeout = -1;
              }
           else if (FirstTime.Elapsed() < (uint)Setup.RcRepeatDelay)
              continue; // repeat function kicks in after a short delay
           else if (LastTime.Elapsed() < (uint)Setup.RcRepeatDelta)
              continue; // skip same keys coming in too fast
           else {
              pressed = true;
              repeat = true;
              timeout = Delta * 10 / 9;
              }
           if (pressed) {
              LastTime.Set();
              Put(KeyName, repeat);
              }
           }
        else if (pressed && repeat) { // the last one was a repeat, so let's generate a release
           Put(LastKeyName, false, true);
           pressed = false;
           repeat = false;
           *LastKeyName = 0;
           timeout = -1;
           }
        else {
           pressed = false;
           repeat = false;
           *LastKeyName = 0;
           timeout = -1;
           }
        }
}
开发者ID:flensrocker,项目名称:vdr-yavdr,代码行数:80,代码来源:lirc.c


示例18: main_client

int
main_client(int argc, char *const *argv)
{
	int ch;
	struct ntp_peer *np;
	struct ntp_peerset *npl;
	struct todolist *tdl;
	struct combine_delta *cd;
	int fd;
	int npeer = 0;

	setbuf(stdout, NULL);
	setbuf(stderr, NULL);

	tdl = TODO_NewList();
	Time_Unix(tdl);

	PLL_Init();

	npl = NTP_PeerSet_New(NULL);

	Param_Register(client_param_table);
	NF_Init();

	while ((ch = getopt(argc, argv, "p:t:")) != -1) {
		switch(ch) {
		case 'p':
			Param_Tweak(NULL, optarg);
			break;
		case 't':
			ArgTracefile(optarg);
			break;
		default:
			Fail(NULL, 0,
			    "Usage %s [-p param] [-t tracefile] servers...",
			    argv[0]);
			break;
		}
	}
	argc -= optind;
	argv += optind;

	for (ch = 0; ch < argc; ch++)
		npeer += NTP_PeerSet_Add(NULL, npl, argv[ch]);
	if (npeer == 0)
		Fail(NULL, 0, "No NTP peers found");

	Put(NULL, OCX_TRACE, "# NTIMED Format client 1.0\n");
	Put(NULL, OCX_TRACE, "# Found %d peers\n", npeer);

	Param_Report(NULL, OCX_TRACE);

#ifndef NOIPV6
	/* Attempt IPv6, fall back to IPv4 */
	fd = UdpTimedSocket(NULL, AF_INET6);
	if (fd < 0)
		fd = UdpTimedSocket(NULL, AF_INET);
#else
	fd = UdpTimedSocket(NULL, AF_INET);
#endif
	if (fd < 0)
		Fail(NULL, errno, "Could not open UDP socket");

	cd = CD_New();

	NTP_PeerSet_Foreach(np, npl) {
		NF_New(np);
		np->combiner = CD_AddSource(cd, np->hostname, np->ip);
	}
开发者ID:kkpdk,项目名称:Ntimed,代码行数:69,代码来源:main_client.c


示例19: pop3client_scan_room

/*
 * Scan a room's netconfig to determine whether it requires POP3 aggregation
 */
void pop3client_scan_room(struct ctdlroom *qrbuf, void *data, OneRoomNetCfg *OneRNCFG)
{
	const RoomNetCfgLine *pLine;
	void *vptr;

	pthread_mutex_lock(&POP3QueueMutex);
	if (GetHash(POP3QueueRooms, LKEY(qrbuf->QRnumber), &vptr))
	{
		pthread_mutex_unlock(&POP3QueueMutex);
		EVP3CQ_syslog(LOG_DEBUG,
			      "pop3client: [%ld] %s already in progress.",
			      qrbuf->QRnumber,
			      qrbuf->QRname);
		return;
	}
	pthread_mutex_unlock(&POP3QueueMutex);

	if (server_shutting_down) return;

	pLine = OneRNCFG->NetConfigs[pop3client];

	while (pLine != NULL)
	{
		pop3aggr *cptr;

		cptr = (pop3aggr *) malloc(sizeof(pop3aggr));
		memset(cptr, 0, sizeof(pop3aggr));
		///TODO do we need this? cptr->roomlist_parts=1;
		cptr->RoomName = NewStrBufPlain(qrbuf->QRname, -1);
		cptr->pop3user = NewStrBufDup(pLine->Value[1]);
		cptr->pop3pass = NewStrBufDup(pLine->Value[2]);
		cptr->Url = NewStrBuf();
		cptr->Host = NewStrBufDup(pLine->Value[0]);

		cptr->keep = atol(ChrPtr(pLine->Value[3]));
		cptr->interval = atol(ChrPtr(pLine->Value[4]));

		StrBufAppendBufPlain(cptr->Url, HKEY("pop3://"), 0);
		StrBufUrlescUPAppend(cptr->Url, cptr->pop3user, NULL);
		StrBufAppendBufPlain(cptr->Url, HKEY(":"), 0);
		StrBufUrlescUPAppend(cptr->Url, cptr->pop3pass, NULL);
		StrBufAppendBufPlain(cptr->Url, HKEY("@"), 0);
		StrBufAppendBuf(cptr->Url, cptr->Host, 0);
		StrBufAppendBufPlain(cptr->Url, HKEY("/"), 0);
		StrBufUrlescAppend(cptr->Url, cptr->RoomName, NULL);

		ParseURL(&cptr->IO.ConnectMe, cptr->Url, 110);


#if 0
/* todo: we need to reunite the url to be shure. */

		pthread_mutex_lock(&POP3ueueMutex);
		GetHash(POP3FetchUrls, SKEY(ptr->Url), &vptr);
		use_this_cptr = (pop3aggr *)vptr;

		if (use_this_rncptr != NULL)
		{
			/* mustn't attach to an active session */
			if (use_this_cptr->RefCount > 0)
			{
				DeletePOP3Cfg(cptr);
///						Count->count--;
			}
			else
			{
				long *QRnumber;
				StrBufAppendBufPlain(
					use_this_cptr->rooms,
					qrbuf->QRname,
					-1, 0);
				if (use_this_cptr->roomlist_parts == 1)
				{
					use_this_cptr->OtherQRnumbers
						= NewHash(1, lFlathash);
				}
				QRnumber = (long*)malloc(sizeof(long));
				*QRnumber = qrbuf->QRnumber;
				Put(use_this_cptr->OtherQRnumbers,
				    LKEY(qrbuf->QRnumber),
				    QRnumber,
				    NULL);

				use_this_cptr->roomlist_parts++;
			}
			pthread_mutex_unlock(&POP3QueueMutex);
			continue;
		}
		pthread_mutex_unlock(&RSSQueueMutex);
#endif
		cptr->n = Pop3ClientID++;
		pthread_mutex_lock(&POP3QueueMutex);
		Put(POP3FetchUrls,
		    SKEY(cptr->Url),
		    cptr,
		    DeletePOP3Aggregator);

//.........这里部分代码省略.........
开发者ID:henri14,项目名称:citadel,代码行数:101,代码来源:serv_pop3client.c


示例20: e


//.........这里部分代码省略.........
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }
  if (CTools::IsDefaultValue(m_previousLongitude))
  {
    string msg = "ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - previous longitude value read is inconsistent (is default value)";
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }

  // Compute delta latitude an deltat longitude.
  double deltaLat = (fieldSetLat->m_value - m_previousLatitude) / m_numHighResolutionMeasure;
  double deltaLon = (fieldSetLon->m_value - m_previousLongitude) / m_numHighResolutionMeasure;

  if ( (m_numHighResolutionMeasure * deltaLon) < -1.0)
  {
    deltaLon += 360 / m_numHighResolutionMeasure;
  }
  else if ( (m_numHighResolutionMeasure * deltaLon) > 1.0)
  {
    deltaLon -= 360 / m_numHighResolutionMeasure;
  }

  if ( (m_numHighResolutionMeasure * CTools::Abs(deltaLon)) > 1.0)
  {
    string msg = CTools::Format("ERROR in CProductErs::ProcessHighResolutionWithoutFieldCalculation - delta of longitude is set to an unexpected value: %f "
                                "\n\tcurrent datetime: %f current latitude: %f current longitude: %f"
                                "\n\tprevious datetime: %f previous latitude: %f previous longitude: %f",
                                deltaLon,
                                timeStamp, 
                                fieldSetLat->m_value, 
                                fieldSetLon->m_value,
                                m_previousTimeStamp,
                                m_previousLatitude,
                                m_previousLongitude);
    CProductException e(msg, m_currFileName, GetProductClass(), GetProductType(), BRATHL_INCONSISTENCY_ERROR);
    throw (e);
  }

  CRecordSet::iterator it;
  for (it = recordSetToProcess->begin() ; it != recordSetToProcess->end() ; it++)
  {
    CFieldSet* fieldSet = recordSetToProcess->GetFieldSet(it);
    CFieldSetDbl* fieldSetDbl = dynamic_cast<CFieldSetDbl*>(fieldSet); 
    CFieldSetArrayDbl* fieldSetArrayDbl = dynamic_cast<CFieldSetArrayDbl*>(fieldSet); 

    // the field is hidden, it is just use for calculation, don't set it in output
    if (fieldSet->GetField()->IsHidden())
    {
      continue;
    }    

    // data is an array of double
    if (fieldSetArrayDbl != NULL)
    {
      // field is a high resolution field 
      // transform array of double  in a set of records with a double value
      if ( fieldSetArrayDbl->GetField()->IsHighResolution() )
      {
        PutFlatHighResolution(&dataSetHighResolution, fieldSetArrayDbl);      
      }
      else
      {
        // field is an array
        // put it into the set of records (array is repeated for each record)
        Put(&dataSetHighResolution, fieldSetArrayDbl, m_numHighResolutionMeasure);      
      }
    }
    
    // data is a double
    if (fieldSetDbl != NULL)
    {
      // field is a double
      // put it into the set of records (value is repeated for each record)
      Put(&dataSetHighResolution, fieldSetDbl);      
    }    
  }


  // Compute high resolution fields
  ComputeHighResolutionFields(&dataSetHighResolution, deltaLat, deltaLon);      

  m_previousLatitude = fieldSetLat->m_value;
  m_previousLongitude = fieldSetLon->m_value;
  m_previousTimeStamp = timeStamp;

  // Erase the current recordset in the main dataset 
  m_dataSet.Erase(recordSetToProcess);
  
  recordSetToProcess = NULL;
  
  fieldSetLat = NULL;
  fieldSetLon = NULL;
  fieldSetTimeStampSecond = NULL;
  fieldSetTimeStampMicrosecond = NULL;
   
  // Insert the record of the new dataset in the main dataset
  m_dataSet.InsertDataset(&dataSetHighResolution);
  
}
开发者ID:adakite,项目名称:main,代码行数:101,代码来源:ProductErs.cpp



注:本文中的Put函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PutCh函数代码示例发布时间:2022-05-30
下一篇:
C++ PushValue函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap