Example #1
0
void* sender(void *ptr) 
{
	struct socketstuff *s = (struct socketstuff *)ptr;
	int ch;
	while (1) {
		if(s->writechan == -1) 
			break;
		if (i > CHATLEN - 1) 
			i = 0;
		mybuf[i] = ch = wgetch(me);
		if (ch == KEY_RESIZE) {
			clear();
			endwin();
			setupscreen();
			putchars(me,mybuf);
			putchars(them,tmbuf);
			refresh(); /* redraw screen on resize */
		} else {
			putch(me, (char)ch);
			write(s->writechan, &ch, 1);
		}
		i++;
	}
	pthread_cancel(sendthread);
	return 0;
}
Example #2
0
int main()
    //@ requires true;
    //@ ensures true;
{
    char *array = malloc(100);
    getchars(array, 100);
    putchars(array, 100);
    putchars(array, 100);
    //@ leak characters(array, 100);
    return 0;
}
Example #3
0
size_t CharacterProtocol::print(const PrintProtocol& f)
{
    const char *cp = f._print();

    if(cp == NULL)
        return putchar(0);

    return putchars(cp);
}
Example #4
0
// Tile screen with one letter
void aTile(unsigned char AscChar)
{
	unsigned i;
	
	// Display "ABC"
	for (i = 0; i < TxtRows; i++)
	{
		LCD_SetXY(LCD_PMAX - 1 - i*FontSize, 0);
		putchars(AscChar, TxtCols);
	}
}
Example #5
0
static int
back_updatePositions (const widechar * outChars, int inLength, int outLength)
{
  int k;
  if ((dest + outLength) > destmax || (src + inLength) > srcmax)
    return 0;
  if (!cursorStatus && cursorPosition >= src &&
      cursorPosition < (src + inLength))
    {
      cursorPosition = dest + outLength / 2;
      cursorStatus = 1;
    }
  if (inputPositions != NULL || outputPositions != NULL)
    {
      if (outLength <= inLength)
	{
	  for (k = 0; k < outLength; k++)
	    {
	      if (inputPositions != NULL)
		inputPositions[dest + k] = srcMapping[src + k];
	      if (outputPositions != NULL)
		outputPositions[srcMapping[src + k]] = dest + k;
	    }
	  for (k = outLength; k < inLength; k++)
	    if (outputPositions != NULL)
	      outputPositions[srcMapping[src + k]] = dest + outLength - 1;
	}
      else
	{
	  for (k = 0; k < inLength; k++)
	    {
	      if (inputPositions != NULL)
		inputPositions[dest + k] = srcMapping[src + k];
	      if (outputPositions != NULL)
		outputPositions[srcMapping[src + k]] = dest + k;
	    }
	  for (k = inLength; k < outLength; k++)
	    if (inputPositions != NULL)
	      inputPositions[dest + k] = srcMapping[src + inLength - 1];
	}
    }
  return putchars (outChars, outLength);
}
Example #6
0
int
vfprintf(int8_t *fmt, va_list va)
{
	int8_t bf[24];
	int8_t ch;
	int64_t count = 0;
	int64_t len;

	while ((ch=*(fmt++))) {
		if (ch!='%') {
			putchar(ch);
			count++;
		}
		else {
			int8_t zero_pad = 0;
			int8_t *ptr;
			uint64_t len;

			ch=*(fmt++);

			/* Zero padding requested */
			if (ch=='0') {
				ch=*(fmt++);
				if (ch == '\0')
					goto end;
				if (ch >= '0' && ch <= '9')
					zero_pad = ch - '0';
				ch=*(fmt++);
			}

			switch (ch) {
				case 0:
					goto end;

				case 'u':
				case 'd':
					len = itoa(va_arg(va, uint64_t), 10, 0, (ch=='u'), bf, zero_pad);
					putchars(bf, len);
					count+=len;
					break;

				case 'x':
				case 'X':
					len = itoa(va_arg(va, uint64_t), 16, (ch=='X'), 1, bf, zero_pad);
					putchars(bf, len);
					count += len;
					break;

				case 'c' :
					putchar((int8_t)(va_arg(va, int)));
					count++;
					break;

				case 's' :
					ptr = va_arg(va, int8_t*);
					len = strlen(ptr);
					putchars(ptr, len);
					count += len;
					break;

				default:
					putchar(ch);
					count++;
					break;
			}
		}
	}
end:
	return count;
}