home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1999 May / pcp151c.iso / misc / src / install / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-26  |  993 b   |  54 lines

  1. #include <errno.h>
  2. #include <newt.h>
  3. #include <stdarg.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7.  
  8. #include "intl.h"
  9. #include "windows.h"
  10.  
  11. void errorWindow(char * str) {
  12.     char * a;
  13.  
  14.     a = alloca(strlen(str) + 5);
  15.     strcpy(a, str);
  16.     strcat(a, ": %s");
  17.  
  18.     newtWinMessage(_("Error"), _("Ok"), str, strerror(errno));
  19. }
  20.  
  21. void winStatus(int width, int height, char * title,
  22.         char * text, ...) {
  23.     newtComponent t, f;
  24.     char * buf = NULL;
  25.     int size = 0;
  26.     int i = 0;
  27.     va_list args;
  28.  
  29.     va_start(args, text);
  30.  
  31.     do {
  32.     size += 1000;
  33.     if (buf) free(buf);
  34.     buf = malloc(size);
  35.     i = vsnprintf(buf, size, text, args);
  36.     } while (i == size);
  37.  
  38.     va_end(args);
  39.  
  40.     newtCenteredWindow(width, height, title);
  41.  
  42.     t = newtTextbox(1, 1, width - 2, height - 2, NEWT_TEXTBOX_WRAP);
  43.     newtTextboxSetText(t, buf);
  44.     f = newtForm(NULL, NULL, 0);
  45.  
  46.     free(buf);
  47.  
  48.     newtFormAddComponent(f, t);
  49.  
  50.     newtDrawForm(f);
  51.     newtRefresh();
  52.     newtFormDestroy(f);
  53. }
  54.