home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1998 February
/
CHIP_2_98.iso
/
misc
/
src
/
install
/
windows.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-10-09
|
969b
|
53 lines
#include <errno.h>
#include <newt.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windows.h"
void errorWindow(char * str) {
char * a;
a = alloca(strlen(str) + 5);
strcpy(a, str);
strcat(a, ": %s");
newtWinMessage("Error", "Ok", str, strerror(errno));
}
void winStatus(int width, int height, char * title,
char * text, ...) {
newtComponent t, f;
char * buf = NULL;
int size = 0;
int i = 0;
va_list args;
va_start(args, text);
do {
size += 1000;
if (buf) free(buf);
buf = malloc(size);
i = vsnprintf(buf, size, text, args);
} while (i == size);
va_end(args);
newtCenteredWindow(width, height, title);
t = newtTextbox(1, 1, width - 2, height - 2, NEWT_TEXTBOX_WRAP);
newtTextboxSetText(t, buf);
f = newtForm(NULL, NULL, 0);
free(buf);
newtFormAddComponent(f, t);
newtDrawForm(f);
newtRefresh();
newtFormDestroy(f);
}