msg.c (161060) | msg.c (161099) |
---|---|
1/* | 1/* |
2 * $FreeBSD: head/usr.sbin/sade/msg.c 161060 2006-08-07 23:35:49Z netchild $ | 2 * $FreeBSD: head/usr.sbin/sade/msg.c 161099 2006-08-08 13:45:46Z delphij $ |
3 * 4 * Copyright (c) 1995 5 * Jordan Hubbard. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 39{ 40 char *cp; 41 42 return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no"); 43} 44 45/* Whack up an informational message on the status line, in stand-out */ 46void | 3 * 4 * Copyright (c) 1995 5 * Jordan Hubbard. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 39{ 40 char *cp; 41 42 return (cp = variable_get(VAR_DEBUG)) && strcmp(cp, "no"); 43} 44 45/* Whack up an informational message on the status line, in stand-out */ 46void |
47msgYap(char *fmt, ...) | 47msgYap(const char *fmt, ...) |
48{ 49 va_list args; 50 char *errstr; 51 int attrs; 52 53 errstr = (char *)alloca(FILENAME_MAX); 54 va_start(args, fmt); 55 vsnprintf(errstr, FILENAME_MAX, fmt, args); 56 va_end(args); 57 attrs = getattrs(stdscr); 58 attrset(A_REVERSE); 59 mvaddstr(StatusLine, 0, errstr); 60 attrset(attrs); 61 refresh(); 62} 63 64/* Whack up an informational message on the status line */ 65void | 48{ 49 va_list args; 50 char *errstr; 51 int attrs; 52 53 errstr = (char *)alloca(FILENAME_MAX); 54 va_start(args, fmt); 55 vsnprintf(errstr, FILENAME_MAX, fmt, args); 56 va_end(args); 57 attrs = getattrs(stdscr); 58 attrset(A_REVERSE); 59 mvaddstr(StatusLine, 0, errstr); 60 attrset(attrs); 61 refresh(); 62} 63 64/* Whack up an informational message on the status line */ 65void |
66msgInfo(char *fmt, ...) | 66msgInfo(const char *fmt, ...) |
67{ 68 va_list args; 69 char *errstr; 70 int i, attrs; 71 char line[81]; 72 73 attrs = getattrs(stdscr); 74 /* NULL is a special convention meaning "erase the old stuff" */ --- 18 unchanged lines hidden (view full) --- 93 mvaddstr(StatusLine, 0, line); 94 attrset(attrs); 95 move(StatusLine, 79); 96 refresh(); 97} 98 99/* Whack up a warning on the status line */ 100void | 67{ 68 va_list args; 69 char *errstr; 70 int i, attrs; 71 char line[81]; 72 73 attrs = getattrs(stdscr); 74 /* NULL is a special convention meaning "erase the old stuff" */ --- 18 unchanged lines hidden (view full) --- 93 mvaddstr(StatusLine, 0, line); 94 attrset(attrs); 95 move(StatusLine, 79); 96 refresh(); 97} 98 99/* Whack up a warning on the status line */ 100void |
101msgWarn(char *fmt, ...) | 101msgWarn(const char *fmt, ...) |
102{ 103 va_list args; 104 char *errstr; 105 int attrs; 106 107 errstr = (char *)alloca(FILENAME_MAX); 108 strcpy(errstr, "Warning: "); 109 va_start(args, fmt); --- 6 unchanged lines hidden (view full) --- 116 attrset(attrs); 117 refresh(); 118 if (OnVTY && isDebug()) 119 msgDebug("Warning message `%s'\n", errstr); 120} 121 122/* Whack up an error on the status line */ 123void | 102{ 103 va_list args; 104 char *errstr; 105 int attrs; 106 107 errstr = (char *)alloca(FILENAME_MAX); 108 strcpy(errstr, "Warning: "); 109 va_start(args, fmt); --- 6 unchanged lines hidden (view full) --- 116 attrset(attrs); 117 refresh(); 118 if (OnVTY && isDebug()) 119 msgDebug("Warning message `%s'\n", errstr); 120} 121 122/* Whack up an error on the status line */ 123void |
124msgError(char *fmt, ...) | 124msgError(const char *fmt, ...) |
125{ 126 va_list args; 127 char *errstr; 128 int attrs; 129 130 errstr = (char *)alloca(FILENAME_MAX); 131 strcpy(errstr, "Error: "); 132 va_start(args, fmt); --- 6 unchanged lines hidden (view full) --- 139 attrset(attrs); 140 refresh(); 141 if (OnVTY && isDebug()) 142 msgDebug("Error message `%s'\n", errstr); 143} 144 145/* Whack up a fatal error on the status line */ 146void | 125{ 126 va_list args; 127 char *errstr; 128 int attrs; 129 130 errstr = (char *)alloca(FILENAME_MAX); 131 strcpy(errstr, "Error: "); 132 va_start(args, fmt); --- 6 unchanged lines hidden (view full) --- 139 attrset(attrs); 140 refresh(); 141 if (OnVTY && isDebug()) 142 msgDebug("Error message `%s'\n", errstr); 143} 144 145/* Whack up a fatal error on the status line */ 146void |
147msgFatal(char *fmt, ...) | 147msgFatal(const char *fmt, ...) |
148{ 149 va_list args; 150 char *errstr; 151 int attrs; 152 153 errstr = (char *)alloca(FILENAME_MAX); 154 strcpy(errstr, "Fatal Error: "); 155 va_start(args, fmt); --- 13 unchanged lines hidden (view full) --- 169 refresh(); 170 if (OnVTY) 171 msgDebug("Fatal error `%s'!\n", errstr); 172 getch(); 173} 174 175/* Put up a message in a popup confirmation box */ 176void | 148{ 149 va_list args; 150 char *errstr; 151 int attrs; 152 153 errstr = (char *)alloca(FILENAME_MAX); 154 strcpy(errstr, "Fatal Error: "); 155 va_start(args, fmt); --- 13 unchanged lines hidden (view full) --- 169 refresh(); 170 if (OnVTY) 171 msgDebug("Fatal error `%s'!\n", errstr); 172 getch(); 173} 174 175/* Put up a message in a popup confirmation box */ 176void |
177msgConfirm(char *fmt, ...) | 177msgConfirm(const char *fmt, ...) |
178{ 179 va_list args; 180 char *errstr; 181 WINDOW *w = savescr(); 182 183 errstr = (char *)alloca(FILENAME_MAX); 184 va_start(args, fmt); 185 vsnprintf(errstr, FILENAME_MAX, fmt, args); --- 5 unchanged lines hidden (view full) --- 191 msgInfo(NULL); 192 } 193 dialog_notify(errstr); 194 restorescr(w); 195} 196 197/* Put up a message in a popup information box */ 198void | 178{ 179 va_list args; 180 char *errstr; 181 WINDOW *w = savescr(); 182 183 errstr = (char *)alloca(FILENAME_MAX); 184 va_start(args, fmt); 185 vsnprintf(errstr, FILENAME_MAX, fmt, args); --- 5 unchanged lines hidden (view full) --- 191 msgInfo(NULL); 192 } 193 dialog_notify(errstr); 194 restorescr(w); 195} 196 197/* Put up a message in a popup information box */ 198void |
199msgNotify(char *fmt, ...) | 199msgNotify(const char *fmt, ...) |
200{ 201 va_list args; 202 char *errstr; 203 204 errstr = (char *)alloca(FILENAME_MAX); 205 va_start(args, fmt); 206 vsnprintf(errstr, FILENAME_MAX, fmt, args); 207 va_end(args); 208 use_helpline(NULL); 209 use_helpfile(NULL); 210 if (isDebug()) 211 msgDebug("Notify: %s\n", errstr); 212 dialog_msgbox(NULL, errstr, -1, -1, 0); 213} 214 215/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */ 216int | 200{ 201 va_list args; 202 char *errstr; 203 204 errstr = (char *)alloca(FILENAME_MAX); 205 va_start(args, fmt); 206 vsnprintf(errstr, FILENAME_MAX, fmt, args); 207 va_end(args); 208 use_helpline(NULL); 209 use_helpfile(NULL); 210 if (isDebug()) 211 msgDebug("Notify: %s\n", errstr); 212 dialog_msgbox(NULL, errstr, -1, -1, 0); 213} 214 215/* Put up a message in a popup yes/no box and return 0 for YES, 1 for NO */ 216int |
217msgYesNo(char *fmt, ...) | 217msgYesNo(const char *fmt, ...) |
218{ 219 va_list args; 220 char *errstr; 221 int ret; 222 WINDOW *w = savescr(); 223 224 errstr = (char *)alloca(FILENAME_MAX); 225 va_start(args, fmt); --- 9 unchanged lines hidden (view full) --- 235 return 0; /* If non-interactive, return YES all the time */ 236 ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); 237 restorescr(w); 238 return ret; 239} 240 241/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */ 242int | 218{ 219 va_list args; 220 char *errstr; 221 int ret; 222 WINDOW *w = savescr(); 223 224 errstr = (char *)alloca(FILENAME_MAX); 225 va_start(args, fmt); --- 9 unchanged lines hidden (view full) --- 235 return 0; /* If non-interactive, return YES all the time */ 236 ret = dialog_yesno("User Confirmation Requested", errstr, -1, -1); 237 restorescr(w); 238 return ret; 239} 240 241/* Put up a message in a popup no/yes box and return 0 for YES, 1 for NO */ 242int |
243msgNoYes(char *fmt, ...) | 243msgNoYes(const char *fmt, ...) |
244{ 245 va_list args; 246 char *errstr; 247 int ret; 248 WINDOW *w = savescr(); 249 250 errstr = (char *)alloca(FILENAME_MAX); 251 va_start(args, fmt); --- 9 unchanged lines hidden (view full) --- 261 return 1; /* If non-interactive, return NO all the time */ 262 ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1); 263 restorescr(w); 264 return ret; 265} 266 267/* Put up a message in an input box and return the value */ 268char * | 244{ 245 va_list args; 246 char *errstr; 247 int ret; 248 WINDOW *w = savescr(); 249 250 errstr = (char *)alloca(FILENAME_MAX); 251 va_start(args, fmt); --- 9 unchanged lines hidden (view full) --- 261 return 1; /* If non-interactive, return NO all the time */ 262 ret = dialog_noyes("User Confirmation Requested", errstr, -1, -1); 263 restorescr(w); 264 return ret; 265} 266 267/* Put up a message in an input box and return the value */ 268char * |
269msgGetInput(char *buf, char *fmt, ...) | 269msgGetInput(char *buf, const char *fmt, ...) |
270{ 271 va_list args; 272 char *errstr; 273 static char input_buffer[256]; 274 int rval; 275 WINDOW *w = savescr(); 276 277 errstr = (char *)alloca(FILENAME_MAX); --- 15 unchanged lines hidden (view full) --- 293 if (!rval) 294 return input_buffer; 295 else 296 return NULL; 297} 298 299/* Write something to the debugging port */ 300void | 270{ 271 va_list args; 272 char *errstr; 273 static char input_buffer[256]; 274 int rval; 275 WINDOW *w = savescr(); 276 277 errstr = (char *)alloca(FILENAME_MAX); --- 15 unchanged lines hidden (view full) --- 293 if (!rval) 294 return input_buffer; 295 else 296 return NULL; 297} 298 299/* Write something to the debugging port */ 300void |
301msgDebug(char *fmt, ...) | 301msgDebug(const char *fmt, ...) |
302{ 303 va_list args; 304 char *dbg; 305 306 if (DebugFD == -1) 307 return; 308 dbg = (char *)alloca(FILENAME_MAX); 309 strcpy(dbg, "DEBUG: "); 310 va_start(args, fmt); 311 vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); 312 va_end(args); 313 write(DebugFD, dbg, strlen(dbg)); 314} 315 316/* Tell the user there's some output to go look at */ 317void | 302{ 303 va_list args; 304 char *dbg; 305 306 if (DebugFD == -1) 307 return; 308 dbg = (char *)alloca(FILENAME_MAX); 309 strcpy(dbg, "DEBUG: "); 310 va_start(args, fmt); 311 vsnprintf((char *)(dbg + strlen(dbg)), FILENAME_MAX, fmt, args); 312 va_end(args); 313 write(DebugFD, dbg, strlen(dbg)); 314} 315 316/* Tell the user there's some output to go look at */ 317void |
318msgWeHaveOutput(char *fmt, ...) | 318msgWeHaveOutput(const char *fmt, ...) |
319{ 320 va_list args; 321 char *errstr; 322 WINDOW *w = savescr(); 323 324 errstr = (char *)alloca(FILENAME_MAX); 325 va_start(args, fmt); 326 vsnprintf(errstr, FILENAME_MAX, fmt, args); --- 4 unchanged lines hidden (view full) --- 331 dialog_clear_norefresh(); 332 sleep(2); 333 dialog_msgbox(NULL, errstr, -1, -1, 0); 334 restorescr(w); 335} 336 337/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */ 338int | 319{ 320 va_list args; 321 char *errstr; 322 WINDOW *w = savescr(); 323 324 errstr = (char *)alloca(FILENAME_MAX); 325 va_start(args, fmt); 326 vsnprintf(errstr, FILENAME_MAX, fmt, args); --- 4 unchanged lines hidden (view full) --- 331 dialog_clear_norefresh(); 332 sleep(2); 333 dialog_msgbox(NULL, errstr, -1, -1, 0); 334 restorescr(w); 335} 336 337/* Simple versions of msgConfirm() and msgNotify() for calling from scripts */ 338int |
339msgSimpleConfirm(char *str) | 339msgSimpleConfirm(const char *str) |
340{ 341 msgConfirm("%s", str); 342 return DITEM_SUCCESS; 343} 344 345int | 340{ 341 msgConfirm("%s", str); 342 return DITEM_SUCCESS; 343} 344 345int |
346msgSimpleNotify(char *str) | 346msgSimpleNotify(const char *str) |
347{ 348 msgNotify("%s", str); 349 return DITEM_SUCCESS; 350} | 347{ 348 msgNotify("%s", str); 349 return DITEM_SUCCESS; 350} |