1 --- xpbiff.c.orig 1994-10-27 15:42:52.000000000 +0900 2 +++ xpbiff.c 2010-11-17 14:40:26.457077878 +0900 3 @@ -60,6 +60,7 @@ 4 5 #include "config.h" 6 7 +#include <paths.h> /* _PATH_MAILDIR */ 8 #include <X11/Intrinsic.h> 9 #include <X11/StringDefs.h> 10 #include <X11/Shell.h> 11 @@ -74,6 +75,12 @@ 12 #endif 13 #endif /* SUN_AUDIO */ 14 15 +#ifdef BSD_AUDIO 16 +#include <sys/soundcard.h> 17 +#define MAX_SOUND_VOL 95 18 +#define MIN_SOUND_VOL 05 19 +#endif 20 + 21 #ifndef X11R3 22 #include <X11/Xaw/Box.h> 23 #include <X11/Xaw/Label.h> 24 @@ -116,7 +123,11 @@ 25 #include <sys/types.h> 26 #include <sys/stat.h> 27 #include <stdio.h> 28 +#include <stdlib.h> 29 #include <math.h> 30 +#ifdef HAVE_GETPWUID 31 +#include <pwd.h> 32 +#endif /* HAVE_GETPWUID */ 33 34 #ifdef YOUBIN 35 36 @@ -149,11 +160,7 @@ 37 38 #ifndef YOUBIN 39 40 -#ifdef USG 41 -#define SPOOLPATH "/usr/mail/" 42 -#else 43 -#define SPOOLPATH "/usr/spool/mail/" 44 -#endif 45 +#define SPOOLPATH _PATH_MAILDIR 46 47 #else /* YOUBIN */ 48 49 @@ -256,34 +263,11 @@ 50 */ 51 52 GC gcArrive, gcNo, gcAnimate, gcAnimateBack; 53 -#ifdef XPM 54 -Pixmap arrivePixmaps[2], noPixmaps[2]; 55 -#define arrivePixmap arrivePixmaps[0] 56 -#define noPixmap noPixmaps[0] 57 -#else 58 -Pixmap arrivePixmap, noPixmap; 59 -#endif 60 Pixmap workPixmap; 61 int width, height; 62 unsigned char current_status = NO; 63 unsigned char showing_header = 0; 64 long mail_size = 0; 65 -#ifndef YOUBIN 66 -XtIntervalId polling_id; 67 -#endif 68 -Pixel colors[4]; 69 -#ifndef YOUBIN 70 -char spool_path[100]; 71 -int polling_time; 72 -#endif 73 -int popup_time; 74 - 75 -Boolean raise; 76 -Boolean stay_raised; 77 -Boolean animate; 78 -Boolean popup; 79 -Boolean bell; 80 -Boolean popdown; 81 82 unsigned int Arrive_pixmap_width, Arrive_pixmap_height; 83 unsigned int Arrive_pixmap_depth; 84 @@ -291,24 +275,11 @@ 85 unsigned int No_pixmap_width, No_pixmap_height; 86 unsigned int No_pixmap_depth; 87 88 -Boolean mono; 89 -String popupGeometry; 90 - 91 -#ifndef YOUBIN 92 -String prefers; 93 - 94 -String spoolPath; 95 -#endif 96 - 97 -#ifdef MHSCAN 98 -Boolean mhscan; 99 -String scanCommand; 100 -String scanCommandPath; 101 -#endif 102 - 103 -#ifdef SHAPE 104 -Boolean shape; 105 -Pixmap noPixmapMask, arrivePixmapMask; 106 +#ifdef YOUBIN 107 +XtIntervalId timeout_id; 108 +#else 109 +XtIntervalId polling_id; 110 +char spool_path[100]; 111 #endif 112 113 static String fallback_resources[] = { 114 @@ -324,86 +295,125 @@ 115 NULL 116 }; 117 118 -#ifdef SUN_AUDIO 119 -String mail_sndfile; 120 -int volume; 121 +typedef struct _appRes { 122 +#ifdef XPM 123 + Pixmap arrivePixmaps[2]; 124 + Pixmap noPixmaps[2]; 125 +#define arrivePixmap arrivePixmaps[0] 126 +#define noPixmap noPixmaps[0] 127 +#else 128 + Pixmap arrivePixmap; 129 + Pixmap noPixmap; 130 #endif 131 - 132 + Pixel colors[4]; 133 +#ifndef YOUBIN 134 + String prefers; 135 + int polling_time; 136 + String spoolPath; 137 +#endif 138 + Boolean mono; 139 + String popupGeometry; 140 + Boolean raise; 141 + Boolean stay_raised; 142 + Boolean animate; 143 + Boolean popup; 144 + int popup_time; 145 + Boolean bell; 146 + Boolean popdown; 147 #ifdef YOUBIN 148 -Boolean use_pipe; 149 -String server; 150 -Boolean preserve; 151 -XtIntervalId timeout_id; 152 + Boolean use_pipe; 153 + String server; 154 + Boolean preserve; 155 +#endif 156 +#ifdef MHSCAN 157 + Boolean mhscan; 158 + String scanCommand; 159 + String scanCommandPath; 160 #endif 161 +#ifdef SHAPE 162 + Boolean shape; 163 + Pixmap arrivePixmapMask; 164 + Pixmap noPixmapMask; 165 +#endif 166 +#if (defined(SUN_AUDIO) || defined(BSD_AUDIO)) 167 + String mail_sndfile; 168 + int volume; 169 +#endif 170 +} AppResourcesRec, *AppResources; 171 + 172 +#define SetResOffset(n, field) resources[n].resource_offset = ((char *)&appResources.field - (char *)&appResources) 173 +#define offset(field) XtOffset(struct _appRes *, field) 174 + 175 +AppResourcesRec appResources; 176 177 static XtResource resources[] = { 178 {"arrivePixmap", "ArrivePixmap", RPixmap2, sizeof(Pixmap2), 179 - (Cardinal)&arrivePixmap, XtRString, "None"}, 180 + offset(arrivePixmap), XtRString, "None"}, 181 {"nomailPixmap", "NomailPixmap", RPixmap2, sizeof(Pixmap2), 182 - (Cardinal)&noPixmap, XtRString, "None"}, 183 + offset(noPixmap), XtRString, "None"}, 184 {"nomailForeground", "NomailForeground", XtRPixel, sizeof(Pixel), 185 - (Cardinal)&colors[0], XtRString, "black"}, 186 + offset(colors[0]), XtRString, "black"}, 187 {"nomailBackground", "NomailBackground", XtRPixel, sizeof(Pixel), 188 - (Cardinal)&colors[1], XtRString, "cyan"}, 189 + offset(colors[1]), XtRString, "cyan"}, 190 {"arriveForeground", "ArriveForeground", XtRPixel, sizeof(Pixel), 191 - (Cardinal)&colors[2], XtRString, "yellow"}, 192 + offset(colors[2]), XtRString, "yellow"}, 193 {"arriveBackground", "ArriveBackground", XtRPixel, sizeof(Pixel), 194 - (Cardinal)&colors[3], XtRString, "red"}, 195 + offset(colors[3]), XtRString, "red"}, 196 #ifndef YOUBIN 197 {"pollingTime", "PollingTime", XtRInt, sizeof(int), 198 - (Cardinal)&polling_time, XtRImmediate, (XtPointer)15000}, 199 + offset(polling_time), XtRImmediate, (XtPointer)15000}, 200 {"prefer", "Prefer", XtRString, sizeof(String), 201 - (Cardinal)&prefers, XtRString, (XtPointer)"From Subject"}, 202 + offset(prefers), XtRString, (XtPointer)"From Subject"}, 203 {"spoolPath", "SpoolPath", XtRString, sizeof(String), 204 - (Cardinal)&spoolPath, XtRString, None}, 205 + offset(spoolPath), XtRString, None}, 206 #endif 207 {"mono", "Mono", XtRBoolean, sizeof(Boolean), 208 - (Cardinal)&mono, XtRImmediate, (XtPointer)False}, 209 + offset(mono), XtRImmediate, (XtPointer)False}, 210 {"popupGeometry", "PopupGeometry", XtRString, sizeof(String), 211 - (Cardinal)&popupGeometry, XtRString, NULL}, 212 + offset(popupGeometry), XtRString, NULL}, 213 {"raise", "Raise", XtRBoolean, sizeof(Boolean), 214 - (Cardinal)&raise, XtRImmediate, (XtPointer)True}, 215 + offset(raise), XtRImmediate, (XtPointer)True}, 216 {"stayRaised", "StayRaised", XtRBoolean, sizeof(Boolean), 217 - (Cardinal)&stay_raised, XtRImmediate, (XtPointer)False}, 218 + offset(stay_raised), XtRImmediate, (XtPointer)False}, 219 {"animate", "Animate", XtRBoolean, sizeof(Boolean), 220 - (Cardinal)&animate, XtRImmediate, (XtPointer)True}, 221 + offset(animate), XtRImmediate, (XtPointer)True}, 222 {"popup", "Popup", XtRBoolean, sizeof(Boolean), 223 - (Cardinal)&popup, XtRImmediate, (XtPointer)True}, 224 + offset(popup), XtRImmediate, (XtPointer)True}, 225 {"popupTime", "PopupTime", XtRInt, sizeof(int), 226 - (Cardinal)&popup_time, XtRImmediate, (XtPointer)15000}, 227 + offset(popup_time), XtRImmediate, (XtPointer)15000}, 228 {"bell", "Bell", XtRBoolean, sizeof(Boolean), 229 - (Cardinal)&bell, XtRImmediate, (XtPointer)True}, 230 + offset(bell), XtRImmediate, (XtPointer)True}, 231 {"popdown", "Popdown", XtRBoolean, sizeof(Boolean), 232 - (Cardinal)&popdown, XtRImmediate, (XtPointer)True}, 233 + offset(popdown), XtRImmediate, (XtPointer)True}, 234 #ifdef YOUBIN 235 {"pipe", "Pipe", XtRBoolean, sizeof(Boolean), 236 - (Cardinal)&use_pipe, XtRString, "false"}, 237 + offset(use_pipe), XtRString, "false"}, 238 {"server", "Server", XtRString, sizeof(String), 239 - (Cardinal)&server, XtRString, YOUBIN_DEFAULT_SERVER_HOST}, 240 + offset(server), XtRString, YOUBIN_DEFAULT_SERVER_HOST}, 241 {"preserve", "preserve", XtRBoolean, sizeof(Boolean), 242 - (Cardinal)&preserve, XtRString, "true"}, 243 + offset(preserve), XtRString, "true"}, 244 #endif 245 #ifdef MHSCAN 246 {"mhscan", "Mhscan", XtRBoolean, sizeof(Boolean), 247 - (Cardinal)&mhscan, XtRImmediate, (XtPointer)False}, 248 + offset(mhscan), XtRImmediate, (XtPointer)False}, 249 {"scanCommand", "ScanCommand", XtRString, sizeof(String), 250 - (Cardinal)&scanCommand, XtRString, DEFAULT_SCAN_COMMAND}, 251 + offset(scanCommand), XtRString, DEFAULT_SCAN_COMMAND}, 252 {"scanCommandPath", "ScanCommandPath", XtRString, sizeof(String), 253 - (Cardinal)&scanCommandPath, XtRString, DEFAULT_SCAN_COMMAND_PATH}, 254 + offset(scanCommandPath), XtRString, DEFAULT_SCAN_COMMAND_PATH}, 255 #endif 256 #ifdef SHAPE 257 {"shape", "Shape", XtRBoolean, sizeof(Boolean), 258 - (Cardinal)&shape, XtRImmediate, (XtPointer)False}, 259 + offset(shape), XtRImmediate, (XtPointer)False}, 260 {"arrivePixmapMask", "ArrivePixmapMask", XtRBitmap, sizeof(Pixmap), 261 - (Cardinal)&arrivePixmapMask, XtRBitmap, None}, 262 + offset(arrivePixmapMask), XtRBitmap, None}, 263 {"nomailPixmapMask", "NomailPixmapMask", XtRBitmap, sizeof(Pixmap), 264 - (Cardinal)&noPixmapMask, XtRBitmap, None}, 265 + offset(noPixmapMask), XtRBitmap, None}, 266 #endif 267 -#ifdef SUN_AUDIO 268 +#if (defined(SUN_AUDIO) || defined(BSD_AUDIO)) 269 {"mailSndFile", "MailSndFile", XtRString, sizeof(String), 270 - (Cardinal)&mail_sndfile, XtRString, None}, 271 + offset(mail_sndfile), XtRString, None}, 272 {"volume", "Volume", XtRInt, sizeof(int), 273 - (Cardinal)&volume, XtRString, "33"}, 274 + offset(volume), XtRString, "33"}, 275 #endif 276 }; 277 278 @@ -445,7 +455,7 @@ 279 {"-server", "*server", XrmoptionSepArg, NULL}, 280 {"-preserve", "*preserve", XrmoptionNoArg, "true"}, 281 #endif /* YOUBIN */ 282 -#ifdef SUN_AUDIO 283 +#if (defined(SUN_AUDIO) || defined(BSD_AUDIO)) 284 {"-sndfile", "*mailSndFile", XrmoptionSepArg, NULL}, 285 {"-volume", "*volume", XrmoptionSepArg, NULL}, 286 #endif 287 @@ -461,6 +471,7 @@ 288 #ifdef JCONVERT 289 static Locale_ent locale_list[] = { 290 {"ja_JP.EUC", EUC}, 291 + {"ja_JP.eucJP", EUC}, 292 {"ja_JP.SJIS", SJIS}, 293 {"ja_JP.jis7", JIS}, 294 {"ja_JP.jis8", JIS}, 295 @@ -485,9 +496,9 @@ 296 XGCValues values; 297 XtTranslations newTranslations; 298 static XtActionsRec redrawActions[] = { 299 - {"expose", (XtCallbackProc) redraw_callback}, 300 - {"select", (XtCallbackProc) popup_again}, 301 - {"quit", (XtCallbackProc) quit}, 302 + {"expose", (XtActionProc) redraw_callback}, 303 + {"select", (XtActionProc) popup_again}, 304 + {"quit", (XtActionProc) quit}, 305 }; 306 307 static char *overrideTranslations = 308 @@ -498,6 +509,9 @@ 309 int dummy; 310 int i; 311 312 +#ifdef HAVE_GETPWUID 313 + struct passwd *pw; 314 +#endif 315 #ifdef JCONVERT 316 char *locale_name; 317 Locale_ent *p; 318 @@ -514,28 +528,40 @@ 319 #endif /* !YOUBIN */ 320 321 #ifdef YOUBIN 322 - if ((prog_name = strrchr(argv[0], '/')) != NULL) { 323 - prog_name++; 324 - } else { 325 - prog_name = argv[0]; 326 - } 327 + if ((prog_name = strrchr(argv[0], '/')) != NULL) { 328 + prog_name++; 329 + } else { 330 + prog_name = argv[0]; 331 + } 332 #else /* !YOUBIN */ 333 - if (spoolPath != NULL && spoolPath[0] != '\0') 334 - strcpy(spool_path, spoolPath); 335 - else 336 + if (appResources.spoolPath != NULL && appResources.spoolPath[0] != '\0') { 337 + strcpy(spool_path, appResources.spoolPath); 338 + } else { 339 strcpy(spool_path, SPOOLPATH); 340 - if (spool_path[strlen(spool_path) - 1] != '/') 341 + } 342 + if (spool_path[strlen(spool_path) - 1] != '/') { 343 strcat(spool_path, "/"); 344 + } 345 + 346 #ifdef GETENV_MAIL 347 - if (getenv("MAIL") != NULL) 348 + if (getenv("MAIL") != NULL) { 349 strcpy(spool_path, getenv("MAIL")); 350 - else 351 -#endif 352 -#ifndef NO_CUSERID 353 - strcat(spool_path, cuserid(NULL)); 354 -#else 355 + } else { 356 +#endif /* GETENV_MAIL */ 357 + 358 +#ifdef HAVE_GETPWUID 359 + pw = getpwuid(getuid()); 360 + strcat(spool_path, pw->pw_name); 361 +#elif defined(NO_CUSERID) 362 strcat(spool_path, getenv("USER")); 363 -#endif 364 +#else 365 + strcat(spool_path, (char *)cuserid(NULL)); 366 +#endif /* NO_CUSERID && HAVE_GETPWUID */ 367 + 368 +#ifdef GETENV_MAIL 369 + } 370 +#endif /* GETENV_MAIL */ 371 + 372 #endif /* !YOUBIN */ 373 374 #ifdef XI18N 375 @@ -646,7 +672,7 @@ 376 fprintf(stderr, " [-server host]\n"); 377 fprintf(stderr, " [-nopreserve]\n"); 378 #endif 379 -#ifdef SUN_AUDIO 380 +#if (defined(SUN_AUDIO) || defined(BSD_AUDIO)) 381 fprintf(stderr, " [-sndfile audio_file]\n"); 382 fprintf(stderr, " [-volume percentage]\n"); 383 #endif 384 @@ -659,33 +685,33 @@ 385 convertArgs, XtNumber(convertArgs)); 386 #endif 387 388 - XtGetApplicationResources(toplevel, (caddr_t) NULL, 389 + XtGetApplicationResources(toplevel, (XtPointer)&appResources, 390 resources, XtNumber(resources), NULL, 0); 391 392 - if (mono == True) { 393 - colors[0] = colors[3] = BlackPixelOfScreen(XtScreen(toplevel)); 394 - colors[1] = colors[2] = WhitePixelOfScreen(XtScreen(toplevel)); 395 + if (appResources.mono == True) { 396 + appResources.colors[0] = appResources.colors[3] = BlackPixelOfScreen(XtScreen(toplevel)); 397 + appResources.colors[1] = appResources.colors[2] = WhitePixelOfScreen(XtScreen(toplevel)); 398 } 399 400 #ifndef YOUBIN 401 - split_prefer(prefers); 402 + split_prefer(appResources.prefers); 403 #endif 404 405 #ifdef XPM 406 - if (arrivePixmapMask == None) 407 - arrivePixmapMask = arrivePixmaps[1]; 408 - if (noPixmapMask == None) 409 - noPixmapMask = noPixmaps[1]; 410 + if (appResources.arrivePixmapMask == None) 411 + appResources.arrivePixmapMask = appResources.arrivePixmaps[1]; 412 + if (appResources.noPixmapMask == None) 413 + appResources.noPixmapMask = appResources.noPixmaps[1]; 414 #endif 415 416 #ifdef SHAPE 417 - if (shape == True 418 + if (appResources.shape == True 419 && !XShapeQueryExtension(XtDisplay(toplevel), &dummy, &dummy)) 420 - shape = False; 421 + appResources.shape = False; 422 #endif 423 424 - if (noPixmap == None) { 425 - noPixmap = XCreatePixmapFromBitmapData 426 + if (appResources.noPixmap == None) { 427 + appResources.noPixmap = XCreatePixmapFromBitmapData 428 (XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), 429 no_bits, no_width, no_height, 1, 0, 1); 430 No_pixmap_width = no_width; 431 @@ -695,14 +721,14 @@ 432 else { 433 Window r; 434 unsigned int x, y, bw; 435 - XGetGeometry(XtDisplay(toplevel), noPixmap, 436 + XGetGeometry(XtDisplay(toplevel), appResources.noPixmap, 437 &r, &x, &y, 438 &No_pixmap_width, &No_pixmap_height, 439 &bw, &No_pixmap_depth); 440 } 441 442 - if (arrivePixmap == None) { 443 - arrivePixmap = XCreatePixmapFromBitmapData 444 + if (appResources.arrivePixmap == None) { 445 + appResources.arrivePixmap = XCreatePixmapFromBitmapData 446 (XtDisplay(toplevel), RootWindowOfScreen(XtScreen(toplevel)), 447 arrive_bits, arrive_width, arrive_height, 448 1, 0, 1); 449 @@ -713,7 +739,7 @@ 450 else { 451 Window r; 452 unsigned int x, y, bw; 453 - XGetGeometry(XtDisplay(toplevel), arrivePixmap, 454 + XGetGeometry(XtDisplay(toplevel), appResources.arrivePixmap, 455 &r, &x, &y, 456 &Arrive_pixmap_width, &Arrive_pixmap_height, 457 &bw, &Arrive_pixmap_depth); 458 @@ -741,14 +767,14 @@ 459 460 /* Get graphic context */ 461 462 - values.foreground = colors[0]; 463 - values.background = colors[1]; 464 + values.foreground = appResources.colors[0]; 465 + values.background = appResources.colors[1]; 466 values.graphics_exposures = False; 467 gcNo = XtGetGC(toplevel, 468 GCForeground | GCBackground | GCGraphicsExposures, 469 &values); 470 - values.foreground = colors[2]; 471 - values.background = colors[3]; 472 + values.foreground = appResources.colors[2]; 473 + values.background = appResources.colors[3]; 474 values.graphics_exposures = False; 475 gcArrive = XtGetGC(toplevel, 476 GCForeground | GCBackground | GCGraphicsExposures, 477 @@ -760,13 +786,13 @@ 478 Arrive_pixmap_width, Arrive_pixmap_height, 479 DefaultDepthOfScreen(XtScreen(toplevel))); 480 481 - values.foreground = colors[2]; 482 + values.foreground = appResources.colors[2]; 483 values.graphics_exposures = False; 484 gcAnimate = XtGetGC(toplevel, 485 GCForeground | GCGraphicsExposures, 486 &values); 487 488 - values.foreground = colors[3]; 489 + values.foreground = appResources.colors[3]; 490 values.graphics_exposures = False; 491 gcAnimateBack = XtGetGC(toplevel, 492 GCForeground | GCGraphicsExposures, 493 @@ -775,11 +801,11 @@ 494 /* Interval timer start */ 495 #ifndef YOUBIN 496 polling_id = XtAppAddTimeOut(app_con, 497 - (unsigned long) polling_time, Polling, NULL); 498 + (unsigned long) appResources.polling_time, (XtTimerCallbackProc) Polling, NULL); 499 #else /* YOUBIN */ 500 - if (server == NULL) { 501 + if (appResources.server == NULL) { 502 gethostname(serv_name, sizeof(serv_name)); 503 - server = serv_name; 504 + appResources.server = serv_name; 505 } 506 507 /* make new process group */ 508 @@ -789,9 +815,9 @@ 509 exit(EXIT_FAILURE); 510 } 511 512 - if (use_pipe == False) { 513 + if (appResources.use_pipe == False) { 514 sprintf(child_process, "%s/%s -b -s %s", 515 - BINDIR, CHILD_PROGRAM_NAME, server); 516 + BINDIR, CHILD_PROGRAM_NAME, appResources.server); 517 if ((pfile = popen(child_process, "r")) == NULL) { 518 perror("popen"); 519 exit(EXIT_FAILURE); 520 @@ -831,21 +857,21 @@ 521 { 522 if (current_status == ARRIVE) { 523 if (Arrive_pixmap_depth == 1) 524 - XCopyPlane(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), 525 + XCopyPlane(XtDisplay(toplevel), appResources.arrivePixmap, XtWindow(biff), 526 gcArrive, 527 0, 0, Arrive_pixmap_width, Arrive_pixmap_height, 0, 0, 1); 528 else 529 - XCopyArea(XtDisplay(toplevel), arrivePixmap, XtWindow(biff), 530 + XCopyArea(XtDisplay(toplevel), appResources.arrivePixmap, XtWindow(biff), 531 gcArrive, 532 0, 0, Arrive_pixmap_width, Arrive_pixmap_height, 0, 0); 533 } 534 else { 535 if (No_pixmap_depth == 1) 536 - XCopyPlane(XtDisplay(toplevel), noPixmap, XtWindow(biff), 537 + XCopyPlane(XtDisplay(toplevel), appResources.noPixmap, XtWindow(biff), 538 gcNo, 539 0, 0, No_pixmap_width, No_pixmap_height, 0, 0, 1); 540 else 541 - XCopyArea(XtDisplay(toplevel), noPixmap, XtWindow(biff), 542 + XCopyArea(XtDisplay(toplevel), appResources.noPixmap, XtWindow(biff), 543 gcNo, 0, 0, No_pixmap_width, No_pixmap_height, 0, 0); 544 } 545 } 546 @@ -853,9 +879,9 @@ 547 #ifdef SHAPE 548 void shape_window() 549 { 550 - if (shape == True) { 551 + if (appResources.shape == True) { 552 if (current_status == ARRIVE) { 553 - if (arrivePixmapMask == None) { 554 + if (appResources.arrivePixmapMask == None) { 555 XRectangle rect; 556 rect.x = rect.y = 0; 557 rect.width = Arrive_pixmap_width; 558 @@ -866,11 +892,11 @@ 559 } 560 else 561 XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), 562 - ShapeBounding, 0, 0, arrivePixmapMask, 563 + ShapeBounding, 0, 0, appResources.arrivePixmapMask, 564 ShapeSet); 565 } 566 else { 567 - if (noPixmapMask == None) { 568 + if (appResources.noPixmapMask == None) { 569 XRectangle rect; 570 rect.x = rect.y = 0; 571 rect.width = No_pixmap_width; 572 @@ -881,7 +907,7 @@ 573 } 574 else 575 XShapeCombineMask(XtDisplay(toplevel), XtWindow(toplevel), 576 - ShapeBounding, 0, 0, noPixmapMask, 577 + ShapeBounding, 0, 0, appResources.noPixmapMask, 578 ShapeSet); 579 } 580 } 581 @@ -915,53 +941,54 @@ 582 /* NEW mail !! */ 583 current_status = ARRIVE; 584 mail_size = file_stat.st_size; 585 - if (popup == True) 586 + if (appResources.popup == True) 587 mail_header = GetMailHeader(); 588 XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1); 589 XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0); 590 - if (raise == True) 591 + if (appResources.raise == True) 592 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 593 - if (animate == True) 594 + if (appResources.animate == True) 595 AnimateBiff(); 596 redraw_window(); 597 #ifdef SHAPE 598 shape_window(); 599 #endif 600 - if (popup == True) 601 + if (appResources.popup == True) 602 PopupMailHeader(mail_header); 603 XSync(XtDisplay(toplevel), 0); 604 - if (bell == True) 605 - beep(XtDisplay(toplevel), 0); 606 + if (appResources.bell == True) 607 + beep(XtDisplay(toplevel)); 608 /* XBell(XtDisplay(toplevel), 0); */ 609 } 610 else if (file_stat.st_size > mail_size) { 611 mail_size = file_stat.st_size; 612 - if (popup == True) 613 + if (appResources.popup == True) 614 mail_header = GetMailHeader(); 615 /* more come! only ringing bell. */ 616 - if (popup == True) 617 + if (appResources.popup == True) 618 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 619 XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1); 620 XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0); 621 - if (raise == True) 622 + if (appResources.raise == True) 623 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 624 - if (animate == True) 625 + if (appResources.animate == True) 626 AnimateBiff(); 627 redraw_window(); 628 #ifdef SHAPE 629 shape_window(); 630 #endif 631 - if (popup == True) 632 + if (appResources.popup == True) 633 PopupMailHeader(mail_header); 634 XSync(XtDisplay(toplevel), 0); 635 - if (bell == True) 636 - XBell(XtDisplay(toplevel), 0); 637 + if (appResources.bell == True) 638 + beep(XtDisplay(toplevel)); 639 + /* XBell(XtDisplay(toplevel), 0); */ 640 } 641 else { 642 mail_size = file_stat.st_size; 643 - if (raise == True && stay_raised == False) 644 + if (appResources.raise == True && appResources.stay_raised == False) 645 XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); 646 - if (popup == True) 647 + if (appResources.popup == True) 648 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 649 } 650 } else 651 @@ -974,15 +1001,15 @@ 652 #ifdef SHAPE 653 shape_window(); 654 #endif 655 - if (raise == True && stay_raised == False) 656 + if (appResources.raise == True && appResources.stay_raised == False) 657 XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); 658 - if (popup == True) 659 + if (appResources.popup == True) 660 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 661 } 662 /* No arrive */ 663 664 polling_id = XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel), 665 - (unsigned long) polling_time, Polling, NULL); 666 + (unsigned long) appResources.polling_time, (XtTimerCallbackProc) Polling, NULL); 667 668 } 669 #endif /* !YOUBIN */ 670 @@ -995,7 +1022,7 @@ 671 double r, angle, t1, t2, t3, t4; 672 673 #ifdef SHAPE 674 - if(shape == True) { 675 + if(appResources.shape == True) { 676 XRectangle rect; 677 rect.x = rect.y = 0; 678 rect.width = Arrive_pixmap_width; 679 @@ -1038,9 +1065,9 @@ 680 681 /* Create Popup Shell */ 682 683 - if (popupGeometry != NULL) { 684 + if (appResources.popupGeometry != NULL) { 685 arg_count = 0; 686 - XtSetArg(args[arg_count], XtNgeometry, popupGeometry); 687 + XtSetArg(args[arg_count], XtNgeometry, appResources.popupGeometry); 688 arg_count++; 689 } 690 else { 691 @@ -1068,10 +1095,10 @@ 692 info_base = XtCreateManagedWidget("info_base", boxWidgetClass, header, args, 693 arg_count); 694 695 - if (popdown == True) { 696 + if (appResources.popdown == True) { 697 popdown_button = XtCreateManagedWidget("popdown_button", commandWidgetClass, info_base, NULL, 698 ZERO); 699 - XtAddCallback(popdown_button, XtNcallback, BreakPopup, (XtPointer) NULL); 700 + XtAddCallback(popdown_button, XtNcallback, (XtCallbackProc) BreakPopup, (XtPointer) NULL); 701 } 702 arg_count = 0; 703 XtSetArg(args[arg_count], XtNlabel, head); 704 @@ -1131,37 +1158,38 @@ 705 /* the click catchs new mail */ 706 current_status = ARRIVE; 707 mail_size = file_stat.st_size; 708 - if (popup == True) 709 + if (appResources.popup == True) 710 mail_header = GetMailHeader(); 711 XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1); 712 XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0); 713 - if (raise == True) 714 + if (appResources.raise == True) 715 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 716 - if (animate == True) 717 + if (appResources.animate == True) 718 AnimateBiff(); 719 redraw_window(); 720 #ifdef SHAPE 721 shape_window(); 722 #endif 723 - if (popup == True) 724 + if (appResources.popup == True) 725 PopupMailHeader(mail_header); 726 XSync(XtDisplay(toplevel), 0); 727 - if (bell == True) 728 - XBell(XtDisplay(toplevel), 0); 729 + if (appResources.bell == True) 730 + beep(XtDisplay(toplevel)); 731 + /* XBell(XtDisplay(toplevel), 0); */ 732 } 733 else { 734 mail_size = file_stat.st_size; 735 - if (popup == True) 736 + if (appResources.popup == True) 737 mail_header = GetMailHeader(); 738 - if (popup == True && showing_header) 739 + if (appResources.popup == True && showing_header) 740 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 741 - if (raise == True) 742 + if (appResources.raise == True) 743 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 744 redraw_window(); 745 #ifdef SHAPE 746 shape_window(); 747 #endif 748 - if (popup == True) 749 + if (appResources.popup == True) 750 PopupMailHeader(mail_header); 751 XSync(XtDisplay(toplevel), 0); 752 } 753 @@ -1169,7 +1197,7 @@ 754 755 XtRemoveTimeOut(polling_id); 756 polling_id = XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel), 757 - (unsigned long) polling_time, Polling, NULL); 758 + (unsigned long) appResources.polling_time, (XtTimerCallbackProc) Polling, NULL); 759 } 760 #endif /* !YOUBIN */ 761 762 @@ -1749,14 +1777,23 @@ 763 static void beep (display) 764 Display *display; 765 { 766 -#ifdef SUN_AUDIO 767 +#if defined(SUN_AUDIO) || defined(BSD_AUDIO) 768 int audiofd, filefd; 769 - int rn, wn, len; 770 + int rn; 771 +#ifdef SUN_AUDIO 772 + int wn, len; 773 unsigned char buf[256]; 774 Audio_filehdr *au_hdr; 775 audio_info_t ais; 776 - 777 - if (mail_sndfile) { 778 +#elif defined(BSD_AUDIO) 779 + int mixerfd, mixerid, supported; 780 + static int bsize; 781 + static char *buf; 782 + struct stat sbuf; 783 + int level, level_tmp; 784 +#endif 785 + 786 + if (appResources.mail_sndfile) { 787 audiofd = open( "/dev/audio", O_WRONLY | O_NDELAY ); 788 if (audiofd < 0) 789 { 790 @@ -1766,6 +1803,7 @@ 791 return; 792 } 793 794 +#ifdef SUN_AUDIO 795 if( ioctl( audiofd, AUDIO_GETINFO, &ais ) ) 796 { 797 fprintf(stderr, "%s: Problem retrieving /dev/audio info.\n", 798 @@ -1782,15 +1820,34 @@ 799 return; 800 } 801 802 - filefd = open(mail_sndfile, O_RDONLY); 803 +#elif defined(BSD_AUDIO) 804 + /* Open the mixer device */ 805 + mixerfd = open ("/dev/mixer", O_RDWR, 0); 806 + if (mixerfd > 0) 807 + { 808 + if (appResources.volume > MAX_SOUND_VOL) 809 + appResources.volume = MAX_SOUND_VOL; 810 + else if (appResources.volume < MIN_SOUND_VOL) 811 + appResources.volume = MIN_SOUND_VOL; 812 + mixerid = SOUND_MIXER_PCM; 813 + /* storing volume level */ 814 + ioctl(mixerfd,MIXER_READ(mixerid),&level_tmp); 815 + 816 + level = (appResources.volume << 8) | appResources.volume; 817 + ioctl(mixerfd,MIXER_WRITE(mixerid),&level); 818 + } 819 +#endif 820 + 821 + filefd = open(appResources.mail_sndfile, O_RDONLY); 822 if (filefd < 0) 823 { 824 fprintf(stderr, "%s: Couldn't play file \"%s\"\n", 825 - "Mailbox widget", mail_sndfile); 826 + "Mailbox widget", appResources.mail_sndfile); 827 close(audiofd); 828 return; 829 } 830 831 +#ifdef SUN_AUDIO 832 /* Read in the audio header */ 833 rn = read(filefd, buf, sizeof(Audio_filehdr)); 834 835 @@ -1841,12 +1898,28 @@ 836 usleep(1000); 837 } 838 } 839 - close(audiofd); 840 +#elif defined(BSD_AUDIO) 841 + ioctl(audiofd, SNDCTL_DSP_RESET, 0); 842 + fstat(filefd, &sbuf); 843 + bsize = sbuf.st_size; 844 + buf = malloc((u_int)bsize); 845 + if ( (rn = read(filefd, buf, bsize)) > 0) 846 + write(audiofd, buf, rn); 847 + ioctl(audiofd, SNDCTL_DSP_SYNC, 0); 848 + free(buf); 849 + if (mixerfd > 0) 850 + { 851 + /* restoring volume level */ 852 + ioctl(mixerfd,MIXER_WRITE(mixerid),&level_tmp); 853 + close(mixerfd); 854 + } 855 +#endif 856 + close(audiofd); 857 close(filefd); 858 } 859 else 860 - XBell (display, volume); 861 -#else /* !SUN_AUDIO */ 862 + XBell (display, 0); 863 +#else /* !SUN_AUDIO && !BSD_AUDIO */ 864 XBell (display, 0); 865 #endif /* SUN_AUDIO */ 866 return; 867 @@ -1888,7 +1961,7 @@ 868 869 if (mail_size > saved_mail_size) { 870 /* NEW mail */ 871 - if (popup == True || *cp == ' ') { 872 + if (appResources.popup == True || *cp == ' ') { 873 date = strtol(cp, &cp2, 10); 874 if (*cp2 == '\0' || isspace(*cp2)) { 875 get_mail_header((*cp2 == '\0') ? NULL : (cp2 + 1)); 876 @@ -1898,31 +1971,31 @@ 877 current_status = ARRIVE; 878 XtResizeWidget(toplevel, Arrive_pixmap_width, Arrive_pixmap_height, 1); 879 XtResizeWidget(biff, Arrive_pixmap_width, Arrive_pixmap_height, 0); 880 - if (popup == True) { 881 + if (appResources.popup == True) { 882 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 883 } 884 - if (raise == True) { 885 + if (appResources.raise == True) { 886 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 887 } 888 - if (animate == True && mail_header != NULL) { 889 + if (appResources.animate == True && mail_header != NULL) { 890 AnimateBiff(); 891 } 892 redraw_window(); 893 #ifdef SHAPE 894 shape_window(); 895 #endif 896 - if (popup == True) { 897 + if (appResources.popup == True) { 898 if (mail_header != NULL) { 899 PopupMailHeader(mail_header); 900 901 - if (popup_time) 902 + if (appResources.popup_time) 903 XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel), 904 - (unsigned long) popup_time, BreakPopup, NULL); 905 + (unsigned long) appResources.popup_time, (XtTimerCallbackProc) BreakPopup, NULL); 906 } 907 } 908 XSync(XtDisplay(toplevel), 0); 909 - if (bell == True) { 910 - beep(XtDisplay(toplevel), 0); 911 + if (appResources.bell == True) { 912 + beep(XtDisplay(toplevel)); 913 } 914 } else if (mail_size < saved_mail_size){ 915 /* No mail */ 916 @@ -1934,10 +2007,10 @@ 917 #ifdef SHAPE 918 shape_window(); 919 #endif 920 - if (popup == True) { 921 + if (appResources.popup == True) { 922 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 923 } 924 - if (raise == True && stay_raised == False) { 925 + if (appResources.raise == True && appResources.stay_raised == False) { 926 XLowerWindow(XtDisplay(toplevel), XtWindow(toplevel)); 927 } 928 free(mail_header); 929 @@ -1974,7 +2047,7 @@ 930 if (header_count > 1 || *cp == '\0') break; 931 cp = strtok(NULL, "\n"); 932 } 933 - if (preserve == False) { 934 + if (appResources.preserve == False) { 935 free(mail_header); 936 mail_header = NULL; 937 } 938 @@ -2024,16 +2097,16 @@ 939 if (current_status == ARRIVE) { 940 redraw_window(); 941 942 - if (popup == True) { 943 + if (appResources.popup == True) { 944 BreakPopup(toplevel, (XtPointer) NULL, (XtPointer) NULL); 945 if (mail_header != NULL) { 946 PopupMailHeader(mail_header); 947 } 948 - if (popup_time) 949 + if (appResources.popup_time) 950 XtAppAddTimeOut(XtWidgetToApplicationContext(toplevel), 951 - (unsigned long) popup_time, BreakPopup, NULL); 952 + (unsigned long) appResources.popup_time, (XtTimerCallbackProc) BreakPopup, NULL); 953 } 954 - if (raise == True) { 955 + if (appResources.raise == True) { 956 XRaiseWindow(XtDisplay(toplevel), XtWindow(toplevel)); 957 } 958 #ifdef SHAPE 959