Ejemplo n.º 1
0
int
MyFPrintF(FILE *file, const char *fmt, ...)
{
	int count;
	va_list args;

	va_start(args, fmt);
	if (isterm(file)) {
		char *buf;

		count = vsnprintf(NULL, 0, fmt, args) + 1;
		if (count == 0)
			count = MAXPRINTF;
		va_end(args);
		va_start(args, fmt);
		buf = (char *) malloc(count * sizeof(char));
		count = vsnprintf(buf, count, fmt, args);
		TextPutS(&textwin, buf);
		free(buf);
	} else {
		count = vfprintf(file, fmt, args);
	}
	va_end(args);
	return count;
}
Ejemplo n.º 2
0
int
MyVFPrintF(FILE *file, const char *fmt, va_list args)
{
    int count;

    if (isterm(file)) {
        char *buf;

#ifdef __MSC__
        count = _vscprintf(fmt, args) + 1;
#else
        va_list args_copied;
        va_copy(args_copied, args);
        count = vsnprintf(NULL, 0U, fmt, args_copied) + 1;
        if (count == 0) count = MAXPRINTF;
        va_end(args_copied);
#endif
        buf = (char *)malloc(count * sizeof(char));
        count = vsnprintf(buf, count, fmt, args);
        TextPutS(&textwin, buf);
        free(buf);
    } else
        count = vfprintf(file, fmt, args);
    return count;
}
Ejemplo n.º 3
0
int
MyPutS(char *str)
{
    TextPutS(&textwin, str);
    MyPutCh('\n');
    TextMessage();
    return 0;   /* different from Borland library */
}
Ejemplo n.º 4
0
char *
MyGetS(char *str)
{
    TextPutS(&textwin,"\nDANGER: gets() used\n");
    MyFGetS(str,80,stdin);
    if (strlen(str) > 0
        && str[strlen(str)-1]=='\n')
        str[strlen(str)-1] = '\0';
    return str;
}
Ejemplo n.º 5
0
int
MyFPutS(const char *str, FILE *file)
{
    if (isterm(file)) {
        TextPutS(&textwin, (char*) str);
#ifndef WGP_CONSOLE
        TextMessage();
#endif
        return (*str);  /* different from Borland library */
    }
    return fputs(str,file);
}
Ejemplo n.º 6
0
int
MyPrintF(const char *fmt, ...)
{
	int count;
	char *buf;
	va_list args;

	va_start(args, fmt);
	count = vsnprintf(NULL, 0, fmt, args) + 1;
	if (count == 0)
		count = MAXPRINTF;
	va_end(args);
	va_start(args, fmt);
	buf = (char *) malloc(count * sizeof(char));
	count = vsnprintf(buf, count, fmt, args);
	TextPutS(&textwin, buf);
	free(buf);
	va_end(args);
	return count;
}