当前位置: 首页>>代码示例>>C++>>正文


C++ fdprintf函数代码示例

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


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

示例1: parse_backup_messages

void
parse_backup_messages(
    dle_t      *dle,
    int		mesgin)
{
    int goterror;
    char *line;

    amfree(errorstr);

    for(; (line = areads(mesgin)) != NULL; free(line)) {
	process_dumpline(line);
    }

    if(errno) {
	error(_("error [read mesg pipe: %s]"), strerror(errno));
	/*NOTREACHED*/
    }

    goterror = check_result(mesgfd);

    if(errorstr) {
	error(_("error [%s]"), errorstr);
	/*NOTREACHED*/
    } else if(dump_size == -1) {
	error(_("error [no backup size line]"));
	/*NOTREACHED*/
    }

    program->end_backup(dle, goterror);

    fdprintf(mesgfd, _("%s: size %ld\n"), get_pname(), dump_size);
    fdprintf(mesgfd, _("%s: end\n"), get_pname());
}
开发者ID:duckhead,项目名称:amanda,代码行数:34,代码来源:sendbackup.c

示例2: caserd

void
caserd(void)
{

	lgf++;
	skip(0);
	getname();
	if (!iflg) {
		if (quiet) {
#ifdef	NROFF
			echo_off();
			flusho();
#endif	/* NROFF */
			fdprintf(stderr, "\007"); /*bell*/
		} else {
			if (nextf[0]) {
				fdprintf(stderr, "%s:", nextf);
			} else {
				fdprintf(stderr, "\007"); /*bell*/
			}
		}
	}
	collect();
	tty++;
	pushi(-1, PAIR('r','d'), 0);
}
开发者ID:aksr,项目名称:heirloom,代码行数:26,代码来源:n5.c

示例3: smtp_server

static int smtp_server(CLI *c) {
    char line[STRLEN];

    if(RFC2487(c, c->local_rfd.fd)==0)
        return 0; /* Return if RFC 2487 is not used */

    if(fdscanf(c, c->remote_fd.fd, "220%[^\n]", line)!=1) {
        s_log(LOG_ERR, "Unknown server welcome");
        return -1;
    }
    if(fdprintf(c, c->local_wfd.fd, "220%s + stunnel", line)<0)
        return -1;
    if(fdscanf(c, c->local_rfd.fd, "EHLO %[^\n]", line)!=1) {
        s_log(LOG_ERR, "Unknown client EHLO");
        return -1;
    }
    if(fdprintf(c, c->local_wfd.fd, "250-%s Welcome", line)<0)
        return -1;
    if(fdprintf(c, c->local_wfd.fd, "250 STARTTLS")<0)
        return -1;
    if(fdscanf(c, c->local_rfd.fd, "STARTTLS", line)<0) {
        s_log(LOG_ERR, "STARTTLS expected");
        return -1;
    }
    if(fdprintf(c, c->local_wfd.fd, "220 Go ahead")<0)
        return -1;
    return 0;
}
开发者ID:niubl,项目名称:camera_project,代码行数:28,代码来源:protocol.c

示例4: logfdump

/* Store the logf log to logf.txt in the .rockbox directory. The order of the
 * entries will be "reversed" so that the most recently logged entry is on the
 * top of the file */
bool logfdump(void)
{
    int fd;

    splashf(HZ, "Log File Dumped");
    
    /* nothing to print ? */
    if(logfindex == 0 && !logfwrap)
        /* nothing is logged just yet */
        return false;
    
    fd = open(ROCKBOX_DIR "/logf.txt", O_CREAT|O_WRONLY|O_TRUNC);
    if(-1 != fd) {
        int i;
        
        if(logfwrap)
            i = logfindex;
        else
            i = 0;
        
        do {
            if(logfbuffer[i]=='\0')
                fdprintf(fd, "\n");
            else
                fdprintf(fd, "%c", logfbuffer[i]);
                
            i++;
            if(i >= MAX_LOGF_SIZE)
                i = 0;
        } while(i != logfindex);
        
        close(fd);
    }
    return false;
}
开发者ID:BurntBrunch,项目名称:rockbox-fft,代码行数:38,代码来源:logfdisp.c

示例5: smtp_client

static int smtp_client(CLI *c) {
    char line[STRLEN];
    
    do { /* Copy multiline greeting */
        if(fdscanf(c, c->remote_fd.fd, "%[^\n]", line)<0)
            return -1;
        if(fdprintf(c, c->local_wfd.fd, "%s", line)<0)
            return -1;
    } while(strncasecmp(line,"220-",4)==0);

    if(fdprintf(c, c->remote_fd.fd, "EHLO localhost")<0) /* Send an EHLO command */
        return -1;
    do { /* Skip multiline reply */
        if(fdscanf(c, c->remote_fd.fd, "%[^\n]", line)<0)
            return -1;
    } while(strncasecmp(line,"250-",4)==0);
    if(strncasecmp(line,"250 ",4)!=0) { /* Error */
        s_log(LOG_ERR, "Remote server is not RFC 1425 compliant");
        return -1;
    }

    if(fdprintf(c, c->remote_fd.fd, "STARTTLS")<0) /* Send STARTTLS command */
        return -1;
    do { /* Skip multiline reply */
        if(fdscanf(c, c->remote_fd.fd, "%[^\n]", line)<0)
            return -1;
    } while(strncasecmp(line,"220-",4)==0);
    if(strncasecmp(line,"220 ",4)!=0) { /* Error */
        s_log(LOG_ERR, "Remote server is not RFC 2487 compliant");
        return -1;
    }
    return 0;
}
开发者ID:niubl,项目名称:camera_project,代码行数:33,代码来源:protocol.c

示例6: do_show_all

static void
do_show_all(int client, char *buf)
{
    int err;
    DIR *dirp;
    char *c, name[256];

    buf += 8;  // Skip over command
    while (*buf && (*buf == ' ')) buf++;
    if (*buf) {
        // Name provided
        strcpy(name, buf);
    } else {
        strcpy(name, ".");
    }
    
    fdprintf(client, "<INFO> show .jpg files in directory %s\n",name);
    dirp = opendir( name );    
    if( dirp == NULL ) {
        fdprintf(client, "Can't open directory \"%s\"\n", name);
        return;
    }
    for(;;) {
        struct dirent *entry = readdir( dirp );
        struct stat sbuf;
        char fullname[PATH_MAX];
        
        if( entry == NULL )
            break;
        if( name[0] ) {
            strcpy(fullname, name );
            if( !(name[0] == '/' && name[1] == 0 ) )
                strcat(fullname, "/" );
        }
        else fullname[0] = 0;
        strcat(fullname, entry->d_name );
        err = stat( fullname, &sbuf );
        if( err < 0 ) {
            fdprintf(client, "<ERROR> Can't access \"%s\":", fullname);
            if( errno == ENOSYS ) {
                fdprintf(client, " <no status available>");
            } else {
                fdprintf(client, "%s\n", strerror(errno));
            }
        } else {
#if 0
            if (/* hack: !S_ISREG(sbuf.st_mode)*/ (sbuf.st_mode & 0x8000) == 0) {
                continue;
            }
#endif
            if ((c = rindex(fullname, '.')) != (char *)NULL) {
                if (strcmp(c, ".jpg") == 0) {
                    show_jpeg(client, fullname, show_time);
                }
            }
        }
    }
    err = closedir( dirp );
}
开发者ID:EPiCS,项目名称:reconos_v2,代码行数:59,代码来源:img_demo.c

示例7: export_common

static int export_common(Environment &env, bool export_or_unexport, const std::vector<std::string> &tokens, const fdmask &fds) {

	const char *name = export_or_unexport ? "Export" : "Unexport";

	bool _r = false;
	bool _s = false;
	bool error = false;

	auto argv = getopt(tokens, [&](char c){
		switch(tolower(c)) {
			case 'r': _r = true; break;
			case 's': _s = true; break;
			default:
				fdprintf(stderr, "### %s - \"-%c\" is not an option.\n", name, c);
				error = true;
				break;
		}
	});

	if (error) {
		fdprintf(stderr, "# Usage - %s [-r | -s | name...]\n", name);
		return 1;
	}

	if (argv.empty()) {
		if (_r && _s) goto conflict;

		// list of exported vars.
		// -r will generate unexport commands for exported variables.
		// -s will only print the names.


		name = export_or_unexport ? "Export " : "Unexport ";

		for (const auto &kv : env) {
			const std::string& vname = kv.first;
			if (kv.second == export_or_unexport)
				fdprintf(stdout, "%s%s\n", _s ? "" : name, quote(vname).c_str());
		}
		return 0;
	}
	else {
		// mark as exported.

		if (_r || _s) goto conflict;

		for (std::string s : argv) {
			auto iter = env.find(s);
			if (iter != env.end()) iter->second = export_or_unexport;
		}	
		return 0;
	}

conflict:
	fdprintf(stderr, "### %s - Conflicting options or parameters were specified.\n", name);
	fdprintf(stderr, "# Usage - %s [-r | -s | name...]\n", name);
	return 1;
}
开发者ID:ksherlock,项目名称:mpw-shell,代码行数:58,代码来源:builtins.cpp

示例8: builtin_set

int builtin_set(Environment &env, const std::vector<std::string> &tokens, const fdmask &fds) {
	// set var name  -- set
	// set var -- just print the value

	// 3.5 supports -e to also export it.

	//io_helper io(fds);


	if (tokens.size() == 1) {

		for (const auto &kv : env) {
			std::string name = quote(kv.first);
			std::string value = quote(kv.second);

			fdprintf(stdout, "Set %s%s %s\n",
				bool(kv.second) ? "-e " : "", 
				name.c_str(), value.c_str());
		}
		return 0;
	}

	if (tokens.size() == 2) {
		std::string name = tokens[1];
		auto iter = env.find(name);
		if 	(iter == env.end()) {
			fdprintf(stderr, "### Set - No variable definition exists for %s.\n", name.c_str());
			return 2;
		}

		name = quote(name);
		std::string value = quote(iter->second);
		fdprintf(stdout, "Set %s%s %s\n", 
			bool(iter->second) ? "-e " : "", 
			name.c_str(), value.c_str());
		return 0;
	}

	bool exported = false;


	if (tokens.size() == 4 && tokens[1] == "-e") {
		exported = true;
	}

	if (tokens.size() > 3 && !exported) {
		fdputs("### Set - Too many parameters were specified.\n", stderr);
		fdputs("# Usage - set [name [value]]\n", stderr);
		return 1;
	}

	std::string name = tokens[1+exported];
	std::string value = tokens[2+exported];

	env.set(name, value, exported);
	return 0;
}
开发者ID:ksherlock,项目名称:mpw-shell,代码行数:57,代码来源:builtins.cpp

示例9: print_escaped

void print_escaped(char *str, int len)
{
  int i = 0;
  char c[2] = {0}, tmp[2] = {0};
  char *hex_nums = "0123456789ABCDEF";

  while (len--)
  {
    c[0] = str[i++];
    switch (c[0])
    {
      case '"':
        fdprintf(STDOUT, "\\\""); break;
      case '\\':
        fdprintf(STDOUT, "\\\\"); break;
      case '/':
        fdprintf(STDOUT, "\\/");  break;
      case '\b':
        fdprintf(STDOUT, "\\b");  break;
      case '\f':
        fdprintf(STDOUT, "\\f");  break;
      case '\n':
        fdprintf(STDOUT, "\\n");  break;
      case '\r':
        fdprintf(STDOUT, "\\r");  break;
      case '\t':
        fdprintf(STDOUT, "\\t");  break;
      default:
        fdprintf(STDOUT, "%s", c); break;
    }
  }
}
开发者ID:trailofbits,项目名称:cb-multios,代码行数:32,代码来源:kty.c

示例10: settings_write_config

static bool settings_write_config(const char* filename, int options)
{
    int i;
    int fd;
    char value[MAX_PATH];
    fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY, 0666);
    if (fd < 0)
        return false;
    fdprintf(fd, "# .cfg file created by rockbox %s - "
                 "http://www.rockbox.org\r\n\r\n", rbversion);
    for(i=0; i<nb_settings; i++)
    {
        if (settings[i].cfg_name == NULL)
            continue;
        value[0] = '\0';
        if (settings[i].flags & F_DEPRECATED)
            continue;
        
        switch (options)
        {
            case SETTINGS_SAVE_CHANGED:
                if (!is_changed(i))
                    continue;
                break;
            case SETTINGS_SAVE_SOUND:
                if ((settings[i].flags&F_SOUNDSETTING) == 0)
                    continue;
                break;
            case SETTINGS_SAVE_THEME:
                if ((settings[i].flags&F_THEMESETTING) == 0)
                    continue;
                break;
#ifdef HAVE_RECORDING
            case SETTINGS_SAVE_RECPRESETS:
                if ((settings[i].flags&F_RECSETTING) == 0)
                    continue;
                break;
#endif
#if CONFIG_CODEC == SWCODEC
            case SETTINGS_SAVE_EQPRESET:
                if ((settings[i].flags&F_EQSETTING) == 0)
                    continue;
                break;
#endif
        }

        cfg_to_string(i, value, MAX_PATH);
        fdprintf(fd,"%s: %s\r\n",settings[i].cfg_name,value);
    } /* for(...) */
    close(fd);
    return true;
}
开发者ID:Brandon7357,项目名称:rockbox,代码行数:52,代码来源:settings.c

示例11: do_get

static void
do_get(int client, char *buf)
{
    char *fn, *sn, *data;
#ifdef CYGPKG_FS_RAM
    char _fn[PATH_MAX];
#endif
    int fd, len, err;
    struct sockaddr_in srvr_addr;

    buf += 3;  // Skip over command
    fn = strtok(buf, " ,");
    sn = strtok(NULL, " ,");
    if ((fn == (char *)NULL) || (sn == (char *)NULL)) {
        fdprintf(client, "usage: get <file> <server>\n");
        return;
    }
    // For now, only numeric IP addresses
    if (!inet_aton(sn, &srvr_addr.sin_addr)) {
        fdprintf(client, "Can't get host info: %s\n", sn);
        return;
    }
    srvr_addr.sin_port = 0;
    if ((data = (char *)malloc(0x100000)) == (char *)NULL) {
        fdprintf(client, "Can't allocate temp buffer\n");
        return;
    }
    if ((len = tftp_get(fn, &srvr_addr, data, 0x100000, TFTP_OCTET, &err)) > 0) {
        fdprintf(client, "Read %d bytes\n", len);
        fd = open(fn, O_RDWR|O_CREAT);
        if (fd > 0) {
            err = write(fd, data, len);
            if (err != len) {
                fdprintf(client, "Error writing data\n");
            }
            close(fd);
        } else {
            fdprintf(client, "Can't create \"%s\"\n", fn);
        }
#ifdef CYGPKG_FS_RAM
        sprintf(_fn, "/%s", fn);
        fd = open(_fn, O_RDWR|O_CREAT);
        if (fd > 0) {
            err = write(fd, data, len);
            if (err != len) {
                fdprintf(client, "Error writing data\n");
            }
            close(fd);
        } else {
            fdprintf(client, "Can't create \"%s\"\n", _fn);
        }
#endif
    } else {
        fdprintf(client, "Error reading data\n");
    }
    free(data);
}
开发者ID:EPiCS,项目名称:reconos_v2,代码行数:57,代码来源:img_demo.c

示例12: do_line

static void do_line(void *data)
{
	struct double_list *dlist = data;

	if (TT.state>1 && *dlist->data != TT.state)
		fdprintf(TT.state == 2 ? 2 : TT.fileout,
			"%s\n", dlist->data+(TT.state>3 ? 1 : 0));

	if (PATCH_DEBUG) fdprintf(2, "DO %d: %s\n", TT.state, dlist->data);

	free(dlist->data);
	free(dlist);
}
开发者ID:qwerty1023,项目名称:wive-rtnl-firmware,代码行数:13,代码来源:patch.c

示例13: outtp

static void
outtp(tchar i)
{
#ifndef NROFF
	int	j = cbits(i);

#ifdef	EUC
	if (iscopy(i))
		fdprintf(ptid, "%lc", j);
	else
#endif	/* EUC */
		fdprintf(ptid, "%c", j);
#endif
}
开发者ID:saper,项目名称:heirloom-doctools,代码行数:14,代码来源:n2.c

示例14: output_tbl

/*
Inputs:
Outputs:
Effects:
*/
void
output_tbl(int fd, struct user_priority *ppri_tbl)
{
    int		limit;

    fdprintf(fd, "%d\n%d:\n", ppri_tbl->deflt, ppri_tbl->deflt_limit);
    printlist_setup ("	", "\n", "", "");
    for (limit = PRI_MIN; limit <= PRI_MAX; limit++)
	if (ppri_tbl->users[limit - PRI_MIN])
	{
	    fdprintf(fd, "%d:", limit);
	    fdprintlist(fd, ppri_tbl->users[limit - PRI_MIN]);
	}
}
开发者ID:andreiw,项目名称:polaris,代码行数:19,代码来源:storepri.c

示例15: fdprintsdn

void
fdprintsdn(int fd, SCALED sdn)
{
	register char		*dec = "9999.999",
				*z;

	if (sdn.val <= 0)
		return;

	(void)fdprintf (fd, "%s", NB(print_prefix));

	/*
	 * Let's try to be a bit clever in dealing with decimal
	 * numbers. If the number is an integer, don't print
	 * a decimal point. If it isn't an integer, strip trailing
	 * zeros from the fraction part, and don't print more
	 * than the thousandths place.
	 */
	if (-1000. < sdn.val && sdn.val < 10000.) {

		/*
		 * Printing 0 will give us 0.000.
		 */
		sprintf (dec, "%.3f", sdn.val);

		/*
		 * Skip zeroes from the end until we hit
		 * '.' or not-0. If we hit '.', clobber it;
		 * if we hit not-0, it has to be in fraction
		 * part, so leave it.
		 */
		z = dec + strlen(dec) - 1;
		while (*z == '0' && *z != '.')
			z--;
		if (*z == '.')
			*z = '\0';
		else
			*++z = '\0';

		(void)fdprintf(fd, "%s", dec);

	} else
		(void)fdprintf(fd, "%.3f", sdn.val);

	if (sdn.sc == 'i' || sdn.sc == 'c')
		fdputc(sdn.sc, fd);

	(void)fdprintf(fd, "%s%s", NB(print_suffix), NB(print_newline));
	return;
}
开发者ID:AlainODea,项目名称:illumos-gate,代码行数:50,代码来源:sdn.c


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