本文整理汇总了C++中PUTC函数的典型用法代码示例。如果您正苦于以下问题:C++ PUTC函数的具体用法?C++ PUTC怎么用?C++ PUTC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PUTC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wr_fputs
/*
* wr_fputs - like fputs(), but makes control characters visible and
* turns \n into \r\n
*/
static void
wr_fputs(unsigned char *s)
{
#define PUTC(c) if (putchar(c) == EOF) err(1, NULL);
for (; *s != '\0'; ++s) {
if (*s == '\n') {
PUTC('\r');
} else if (((*s & 0x80) && *s < 0xA0) ||
/* disable upper controls */
(!isprint(*s) && !isspace(*s) &&
*s != '\a' && *s != '\b')
) {
if (*s & 0x80) {
*s &= ~0x80;
PUTC('M');
PUTC('-');
}
if (iscntrl(*s)) {
*s ^= 0x40;
PUTC('^');
}
}
PUTC(*s);
}
return;
#undef PUTC
}
示例2: HTTPMakeResponse
/* HTTPMakeResponse
** ----------------
** Makes a HTTP/1.0-1.1 response header.
*/
PRIVATE int HTTPMakeResponse (HTStream * me, HTRequest * request)
{
char crlf[3];
HTRsHd response_mask = HTRequest_rsHd(request);
*crlf = CR; *(crlf+1) = LF; *(crlf+2) = '\0';
if (response_mask & HT_S_LOCATION) { /* @@@ */
}
if (response_mask & HT_S_PROXY_AUTH) { /* @@@ */
}
if (response_mask & HT_S_PUBLIC) { /* @@@ */
}
if (response_mask & HT_S_RETRY_AFTER) { /* @@@ */
}
if (response_mask & HT_S_SERVER) {
PUTS("Server: ");
PUTS(HTLib_appName());
PUTC('/');
PUTS(HTLib_appVersion());
PUTC(' ');
PUTS(HTLib_name());
PUTC('/');
PUTS(HTLib_version());
PUTBLOCK(crlf, 2);
}
if (response_mask & HT_S_WWW_AUTH) { /* @@@ */
}
HTTRACE(PROT_TRACE, "HTTP........ Generating Response Headers\n");
return HT_OK;
}
示例3: lept_encode_utf8
static void lept_encode_utf8(lept_context* c, unsigned u) {
if (u <= 0x7F)
PUTC(c, u & 0xFF);
else if (u <= 0x7FF) {
PUTC(c, 0xC0 | ((u >> 6) & 0xFF));
PUTC(c, 0x80 | ( u & 0x3F));
}
示例4: wr_fputs
/*
* wr_fputs - like fputs(), but makes control characters visible and
* turns \n into \r\n
*/
void
wr_fputs(char *s)
{
#define PUTC(c) if (putchar(c) == EOF) goto err;
for (; *s != '\0'; ++s) {
if (*s == '\n') {
PUTC('\r');
PUTC('\n');
continue;
}
if (isu8cont(*s))
continue;
if (isprint(*s) || isspace(*s) || *s == '\a') {
PUTC(*s);
} else {
PUTC('?');
}
}
return;
err: err(1, NULL);
#undef PUTC
}
示例5: main
int main (int argc, char **argv)
{
STATIC int w, h, bit_num;
STATIC unsigned char byte_acc;
STATIC int i;
STATIC int iter = 50;
STATIC double x, y;
STATIC double Zr, Zi, Cr, Ci, Tr, Ti;
STATIC double limit = 2.0;
#ifdef COMMAND
w = argc > 1 ? atoi(argv[1]) : 60;
h = argc > 2 ? atoi(argv[2]) : w;
#else
w = h = 60;
#endif
PRINTF3("P4\n%d %d\n",w,h);
TIMER_START();
for(y=0;y<h;++y)
{
for(x=0;x<w;++x)
{
Zr = Zi = Tr = Ti = 0.0;
Cr = (2.0*x/w - 1.5); Ci=(2.0*y/h - 1.0);
for (i=0;i<iter && (Tr+Ti <= limit*limit);++i)
{
Zi = 2.0*Zr*Zi + Ci;
Zr = Tr - Ti + Cr;
Tr = Zr * Zr;
Ti = Zi * Zi;
}
byte_acc <<= 1;
if(Tr+Ti <= limit*limit) byte_acc |= 0x01;
++bit_num;
if(bit_num == 8)
{
PUTC(byte_acc,stdout);
byte_acc = 0;
bit_num = 0;
}
else if(x == w-1)
{
byte_acc <<= (8-w%8);
PUTC(byte_acc,stdout);
byte_acc = 0;
bit_num = 0;
}
}
}
TIMER_STOP();
}
示例6: _parse_entry_multivalue
static int _parse_entry_multivalue(struct vparse_state *state)
{
state->entry->multivalue = 1;
state->entry->v.values = strarray_new();
NOTESTART();
while (*state->p) {
switch (*state->p) {
/* only one type of quoting */
case '\\':
/* seen in the wild - \n split by line wrapping */
if (state->p[1] == '\r') INC(1);
if (state->p[1] == '\n') {
if (state->p[2] != ' ' && state->p[2] != '\t')
return PE_BACKQUOTE_EOF;
INC(2);
}
if (!state->p[1])
return PE_BACKQUOTE_EOF;
if (state->p[1] == 'n' || state->p[1] == 'N')
PUTC('\n');
else
PUTC(state->p[1]);
INC(2);
break;
case ';':
strarray_appendm(state->entry->v.values, buf_dup_cstring(&state->buf));
INC(1);
break;
case '\r':
INC(1);
break; /* just skip */
case '\n':
if (state->p[1] == ' ' || state->p[1] == '\t') {/* wrapped line */
INC(2);
break;
}
/* otherwise it's the end of the value */
INC(1);
goto out;
default:
PUTC(*state->p);
INC(1);
break;
}
}
out:
/* reaching the end of the file isn't a failure here,
* it's just another type of end-of-value */
strarray_appendm(state->entry->v.values, buf_dup_cstring(&state->buf));
return 0;
}
示例7: bgl_write_string
/*---------------------------------------------------------------------*/
obj_t
bgl_write_string( obj_t o, bool_t esc, obj_t op ) {
if( esc ) PUTC( op, '#' );
PUTC( op, '"' );
bgl_display_string( o, op );
PUTC( op, '"' );
return op;
}
示例8: cache_print_set
static FcBool
cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose)
{
FcChar8 *dir;
const FcChar8 *base;
int n;
int ndir = 0;
FcStrList *list;
list = FcStrListCreate (dirs);
if (!list)
goto bail2;
while ((dir = FcStrListNext (list)))
{
base = file_base_name (base_name, dir);
if (!write_string (stdout, base))
goto bail3;
if (PUTC (' ', stdout) == EOF)
goto bail3;
if (!write_int (stdout, 0))
goto bail3;
if (PUTC (' ', stdout) == EOF)
goto bail3;
if (!write_string (stdout, FC_FONT_FILE_DIR))
goto bail3;
if (PUTC ('\n', stdout) == EOF)
goto bail3;
ndir++;
}
for (n = 0; n < set->nfont; n++)
{
FcPattern *font = set->fonts[n];
FcChar8 *s;
s = FcPatternFormat (font, (const FcChar8 *) "%{=fccat}\n");
if (s)
{
printf ("%s", s);
FcStrFree (s);
}
}
if (verbose && !set->nfont && !ndir)
printf ("<empty>\n");
FcStrListDone (list);
return FcTrue;
bail3:
FcStrListDone (list);
bail2:
return FcFalse;
}
示例9: doprint
int doprint(char *fmt, va_list ap)
{
int ret = 0;
int code;
int value = 0;
char *p = NULL;
char string[24] = { 0 };
for (; ; ) {
while (((code = *fmt) != '\0') && (code != '%')) {
PUTC(code);
fmt++;
ret++;
}
if (code == '\0')
goto out;
switch (code = *++fmt) {
case 'd':
value = va_arg(ap, int);
p = itoa(string, value, 24);
break;
case 'o':
value = va_arg(ap, int);
p = otoa(string, value, 24);
break;
case 'x':
value = va_arg(ap, int);
p = xtoa(string, value, 24);
break;
case 's':
p = va_arg(ap, char *);
break;
case 'c':
value = va_arg(ap, int);
string[0] = (char )value;
string[1] = '\0';
p = string;
break;
default:
p = NULL;
break;
}
while (p && (*p != '\0')) {
PUTC(*p);
p++, ret++;
}
fmt++;
}
out:
return ret;
}
示例10: process
void process (struct iop *io) {
while (1) {
int c = GETC (io);
if (c == EOF) break;
usleep (3000);
PUTC (io, c);
FLUSH (io);
}
if (io->fd == -1) {
PUTC (io, '\n');
}
}
示例11: write_string
static FcBool
write_string (FILE *f, const FcChar8 *string)
{
if (PUTC ('"', f) == EOF)
return FcFalse;
if (!write_chars (f, string))
return FcFalse;
if (PUTC ('"', f) == EOF)
return FcFalse;
return FcTrue;
}
示例12: malloc
void CContainers::writeMemBuffers(int preprocFlag, int PPMDlib_order, int comprLevel, Encoder* PAQ_encoder, unsigned char* zlibBuffer,COutFileStream* outStream)
{
std::map<std::string,CMemoryBuffer*>::iterator it;
int fileLen=0;
int len=0;
int lenCompr=0;
int allocated=0;
#ifdef USE_LZMA_LIBRARY
if (IF_OPTION(OPTION_LZMA))
{
Byte **Data;
size_t* Size;
int count;
count=(int)memmap.size();
Size=new size_t[count];
Data=(unsigned char**) malloc(sizeof(unsigned char*)*count);
if (Data==NULL)
OUT_OF_MEMORY();
int i=0;
for (it=memmap.begin(); it!=memmap.end(); it++)
{
CMemoryBuffer* b=it->second;
fileLen=b->Size();
if (fileLen>0)
{
Size[i]=fileLen;
Data[i]=b->TargetBuf;
i++;
PUTC((int)it->first.size());
for (int i=0; i<(int)it->first.size(); i++)
PUTC(it->first[i]);
PUTC(fileLen>>24);
PUTC(fileLen>>16);
PUTC(fileLen>>8);
PUTC(fileLen);
}
}
PUTC(0);
count=i;
int last=LZMAlib_GetOutputFilePos(outStream);
LZMAlib_EncodeSolidMemToFile(Data,Size,count,outStream);
printStatus(0,LZMAlib_GetOutputFilePos(outStream)-last,true);
}
示例13: write_f_add_cr
static int
write_f_add_cr(void *vfp, char* buf, size_t len)
{
size_t i;
ASSERT(vfp);
for (i = 0; i < len; i++) {
if (buf[i] == '\n' && PUTC('\r', (FILE *) vfp) == EOF)
return get_error_result();
if (PUTC(buf[i], (FILE *) vfp) == EOF)
return get_error_result();
}
return 0;
}
示例14: process
void process (struct iop *io) {
while (1) {
int d;
int c = GETC (io);
if (c == EOF) break;
if (c >= '!' && c <= '~') {
c = ('!' + '~') - c;
}
PUTC (io, c);
}
if (io->fd == -1) {
PUTC (io, '\n');
}
}
示例15: kgdb_recv
/*
* Receive a packet.
*/
static int
kgdb_recv(u_char *bp, int maxlen)
{
u_char *p;
int c, csum;
int len;
do {
p = bp;
csum = len = 0;
while ((c = GETC()) != KGDB_START)
;
while ((c = GETC()) != KGDB_END && len < maxlen) {
c &= 0x7f;
csum += c;
*p++ = c;
len++;
}
csum &= 0xff;
*p = '\0';
if (len >= maxlen) {
PUTC(KGDB_BADP);
continue;
}
csum -= digit2i(GETC()) * 16;
csum -= digit2i(GETC());
if (csum == 0) {
PUTC(KGDB_GOODP);
/* Sequence present? */
if (bp[2] == ':') {
PUTC(bp[0]);
PUTC(bp[1]);
len -= 3;
kgdb_copy(bp + 3, bp, len);
}
break;
}
PUTC(KGDB_BADP);
} while (1);
#ifdef DEBUG_KGDB
printf("kgdb_recv: %s\n", bp);
#endif
return (len);
}