示例#1
0
文件: winmain.c 项目: Sheetalm9/test
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;
}
示例#2
0
文件: winmain.c 项目: mojca/gnuplot
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;
}
示例#3
0
文件: winmain.c 项目: Sheetalm9/test
int
MyPutS(char *str)
{
    TextPutS(&textwin, str);
    MyPutCh('\n');
    TextMessage();
    return 0;   /* different from Borland library */
}
示例#4
0
文件: winmain.c 项目: Sheetalm9/test
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;
}
示例#5
0
文件: winmain.c 项目: Sheetalm9/test
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);
}
示例#6
0
文件: winmain.c 项目: Sheetalm9/test
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;
}