1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
|
/* -*- Mode: C++-C -*-
*
* Copyright 1994 Christopher B. Liebman
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name Christopher B. Liebman not
* be used in advertising or publicity pertaining to distribution of this
* software without specific, written prior permission.
*
* THIS SOFTWARE IS PROVIDED `AS-IS'. CHRISTOPHER B. LIEBMAN, DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING WITHOUT
* LIMITATION ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NONINFRINGEMENT. IN NO EVENT SHALL CHRISTOPHER
* B. LIEBMAN, BE LIABLE FOR ANY DAMAGES WHATSOEVER, INCLUDING SPECIAL,
* INCIDENTAL OR CONSEQUENTIAL DAMAGES, INCLUDING LOSS OF USE, DATA, OR
* PROFITS, EVEN IF ADVISED OF THE POSSIBILITY THEREOF, AND REGARDLESS OF
* WHETHER IN AN ACTION IN CONTRACT, TORT OR NEGLIGENCE, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author : Chris Liebman
* Created On : Tue Jan 11 14:11:30 1994
* Last Modified By: Chris Liebman
* Last Modified On: Mon Mar 7 16:55:46 1994
* Update Count : 164
* Status : Released
*
* HISTORY
* 13-Feb-1994 Chris Liebman
* Last Modified: Sun Feb 13 00:38:34 1994 #150 (Chris Liebman)
* Added mail annotations. Also added new command stuff.
*
* 2-Feb-1994 Chris Liebman
* Last Modified: Tue Feb 1 14:38:13 1994 #120 (Chris Liebman)
* Added annotation support.
*
* 31-Jan-1994 Chris Liebman
* Last Modified: Mon Jan 31 22:35:28 1994 #116 (Chris Liebman)
* New search support and resources.
*
* 24-Jan-1994 Chris Liebman
* Last Modified: Sun Jan 23 18:54:23 1994 #47 (Chris Liebman)
* Added lots of new resources!
*
* 18-Jan-1994 Chris Liebman
* Last Modified: Tue Jan 18 16:57:29 1994 #31 (Chris Liebman)
* Handle the cases where index, rindex, bcopy, bzero are
* already defined as macros on SYSV. Added new resource:
* closeness. Added new header structs.
*
* 14-Jan-1994 Chris Liebman
* Last Modified: Fri Jan 14 10:22:29 1994 #5 (Chris Liebman)
* Added defines for index(), rindex(), bcopy() and bzero() for SYSV.
* Removed include of xpm.h, its now in face_image_xpm.c.
* Added new ignore message binding resource element to TheXFacesResources.
* Added the status header to the Face structure.
*
* PURPOSE
* Definitions structures and extern declarations for xfaces.
*
* $Id: faces.h,v 1.29 1994/03/12 20:05:52 liebman Exp $
*/
#ifndef FACES_H_
#define FACES_H_
#include <stdio.h>
#include <ctype.h>
#include <pwd.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Xaw/Label.h>
#include "Tiled.h"
#ifndef SYSV
#include <strings.h>
#else
/*
* Handle these functions if macros are not already defined.
*/
#ifndef index
#define index(a, b) strchr(a, b)
#endif
#ifndef rindex
#define rindex(a, b) strrchr(a, b)
#endif
#ifndef bcopy
#define bcopy(a, b, c) memcpy(b, a, c)
#endif
#ifndef bzero
#define bzero(a, b) memset(a, 0, b)
#endif
#endif /* SYSV */
#include "regexp.h"
#include "patchlevel.h"
/*
* Compare a string.
*/
#define StringEqVal(s1, val) (strncmp((s1), (val), strlen(val)) == 0)
/*
* Application class.
*/
#ifndef XFACES_CLASS
#define XFACES_CLASS "XFaces"
#endif
/*
* Max size for mail seperator string.
*/
#define MAX_MAILSEP_SIZE 31
#define MAIL_SEP1 "From "
#define MAIL_SEP1_SKIP False
#define MAIL_SEP2 "\001\001\001\001\n"
#define MAIL_SEP2_SKIP True
/*
* The face type.
*/
typedef struct face Face;
typedef struct face_item FaceItem;
/*
*Image and sound types.
*/
typedef struct face_image FaceImage;
typedef struct face_image_type FaceImageType;
typedef struct face_sound FaceSound;
typedef struct face_sound_type FaceSoundType;
typedef struct face_command FaceCommand;
typedef struct face_search_type FaceSearchType;
typedef struct face_search_data FaceSearchData;
/*
* Here is a mail item structures.
*/
typedef struct mail_header MailHeader;
typedef struct mail_item MailItem;
/*
* Here is the binding structure.
*/
typedef struct face_binding
{
String name; /* Field to search. */
String patsrc;
regexp *pattern; /* Pattern to search for. */
String file; /* file for image/sound. */
String label; /* Label for face. */
int anno; /* Annotation number for label. */
int casesensitive; /* Zero means case insensitive. */
struct face_binding *next;
} FaceBinding;
/*
* The resource structure.
*/
typedef struct _faces_resources
{
String spool_dir; /* The directory for default spool */
/* files. */
String spool_file; /* This is the file to monitor */
/* (full path!). */
String list_command;
String pop_host; /* pop mailbox host. */
int pop_port;
String pop_auth_file; /* login/passwd for pop server */
/* (full path!) */
String image_path; /* Where to find the images. */
char* image_path_str;
char** image_paths;
String sound_path; /* Where to find the sounds. */
char* sound_path_str;
char** sound_paths;
String facedb_path; /* Where to find the facedb's.*/
char* facedb_path_str;
char** facedb_paths;
char* machine; /* name for machine file. */
char* people; /* name for people file. */
int update; /* How often to check the mail. */
int volume; /* How loud to play sounds. */
String from_field; /* String to use as the field name
* for getting the from name. */
String no_mail_image; /* No mail picture. */
String no_mail_sound; /* No mail sound. */
Boolean keep_order;
Boolean compress_images; /* Show faces compressed. */
Boolean use_sound; /* Play sounds. */
Boolean use_shape; /* Shape windows. */
Boolean use_commands; /* Shape windows. */
Boolean use_content_length; /* Use Content-Length header (if
* available) to skip mail body. */
Boolean shape_borders;
Boolean shape_internal;
int closeness; /* Allow similar colors. */
String image_types_str;
FaceImageType** image_types;
String image_search_str;
FaceSearchData* image_search;
String sound_search_str;
FaceSearchData* sound_search;
String command_search_str;
FaceSearchData* command_search;
String ignore_message_bindings_str;
FaceBinding* ignore_message_bindings;
String before_image_bindings_str;
FaceBinding* before_image_bindings;
String after_image_bindings_str;
FaceBinding* after_image_bindings;
String before_sound_bindings_str;
FaceBinding* before_sound_bindings;
String after_sound_bindings_str;
FaceBinding* after_sound_bindings;
String before_command_bindings_str;
FaceBinding* before_command_bindings;
String after_command_bindings_str;
FaceBinding* after_command_bindings;
int annotation_count;
int unknown_annotation_count;
Boolean annotation_above;
Pixel background;
Boolean shape_extra;
Boolean path_by_chdir;
Boolean lookup_hostname;
} FacesResourcesRec, *FacesResources;
/*
* Headers are on a double linked list.
*/
struct mail_header
{
char* name; /* Header name. */
char* value; /* Header value. */
char* line; /* If we could not parse out name/value. */
MailHeader* next; /* Next header. */
MailHeader* prev; /* Previous header. */
};
struct mail_item
{
String user; /* User from From line. */
String host; /* Host from From line. */
String realhost; /* Unaliased hostname. */
String label; /* Item label. */
int use_label; /* Use label for annotation. */
int unknown; /* if non zero use unknown annos. */
int in_use; /* Message in use. */
MailHeader *headers; /* List of mail headers. */
char* body; /* Mail body. */
FaceImage* image; /* Image for user. */
FaceSound* sound; /* Sound to play. */
FaceCommand* command; /* Command to run. */
Face* face;
char** annotations; /* Annotation data. */
MailItem* next; /* Pointer to next item. */
MailItem* prev; /* Pointer to prev item. */
};
struct face_item
{
MailItem* item;
FaceItem* next;
};
/*
* Here is a face structure.
*/
struct face
{
FaceImage *image; /* Image */
char* label; /* Face label. */
int count; /* Count of items using this face. */
int last_count; /* Previous count. */
FaceItem* items; /* List of mail items using face. */
Widget widget; /* Widget used to display user. */
Pixmap pixmap; /* Annotated pixmap. */
Pixmap shape; /* Annotated shape pixmap. */
char** annotations; /* Annotation data. */
struct face *next; /* Pointer to next face. */
struct face *prev; /* Pointer to prev face. */
};
typedef enum face_format
{
FormatImage = 1,
FormatAudio,
FormatCommand
} FaceFormat;
#ifdef __STDC__
#define P_(xxx) xxx
#else
#define P_(xxx) ()
#endif
/*
* Global variable definitions.
*/
/* face_display.c */
extern Face *TheFaceList;
extern Widget NoMailWidget;
/* mail_box.c */
extern char* MailSeperator;
extern int MailSeperatorLength;
extern Boolean MailSeperatorSkip;
/* mail_items.c */
extern MailItem* TheMailItems;
/* main.c */
extern FacesResourcesRec TheFacesResources;
extern Widget TheTopLevel;
extern Widget TheFrame;
extern FaceImage *NoMailImage;
extern FaceSound *NoMailSound;
extern char *getlogin();
/*
* External functions.
*/
/* cmd_check.c */
extern void CmdCheck P_((void));
/* face_actions.c */
extern void FaceActionsInit P_((void));
/* face_annotate.c */
extern int FaceAnnotate P_((Face* face));
extern void FaceAnnotateFree P_((Face* face));
extern void FaceAnnotateInit P_((void));
/* face_binding.c */
extern FaceBinding* FaceBindingParse P_((String str,
int has_value,
int has_label));
extern FaceBinding* FaceBindingCheck P_((MailHeader* headers,
FaceBinding*bindings));
/* face_command.c */
extern void FaceCommandFree P_((FaceCommand* fc));
extern int FaceCommandLoad P_((char* name, MailItem* item, FaceSearchData* data));
extern void FaceCommandRun P_((FaceCommand* fc));
extern void FaceCommandFind P_((MailItem* item));
/* face_display.c */
extern Face* FaceDisplay P_((MailItem* item));
extern void FaceClear P_((void));
extern void FaceClean P_((void));
extern int FaceCount P_((void));
extern void FaceDisplayInit P_((void));
/* face_image.c */
extern FaceImageType* FaceImageTypeByName P_((char* name));
extern void FaceImageTypeRegister P_((FaceImageType* type));
extern FaceImageType** FaceImageTypeListParse P_((char* str));
extern int FaceImageLoad P_((char* file, MailItem* item, FaceSearchData* data));
extern FaceImage* FaceImageCreate P_((char* file,
FaceImageType* type,
void* data));
extern void FaceImageLabelCreate P_((MailItem* item));
extern void FaceImageFree P_((FaceImage* fi));
extern Pixmap FaceImagePixmap P_((FaceImage* fi));
extern Pixmap FaceImageShape P_((FaceImage* fi));
extern String StringConcat P_((String s1,
String s2));
extern void FaceImageRef P_((FaceImage* fi));
extern void FaceImageCount P_((FaceImage* fi));
extern void FaceImageDecount P_((FaceImage* fi));
extern String FaceImageLabelGet P_((FaceImage* fi));
extern void FaceImageFind P_((MailItem* item));
/* face_image_xbm.c */
extern void FaceImageColorize P_((Pixmap* pixmap, int width, int height));
extern void* FaceImageXbmRead P_((String file, void* type_data));
#ifdef SHAPE
extern void* FaceImageShapedXbmRead P_((String file, void* type_data));
#endif
extern void FaceImageXbmFree P_((void* data, void* type_data));
extern Pixmap FaceImageXbmPixmap P_((void *data, void* type_data));
extern Pixmap FaceImageXbmShape P_((void *data, void* type_data));
extern void FaceImageXbmInit P_((void));
/* face_image_xface.c */
#ifdef XFACE
extern FaceImage* FaceImageXFaceCreate P_((String str));
extern void FaceImageXFaceFree P_((void* data, void* type_data));
extern Pixmap FaceImageXFacePixmap P_((void *data, void* type_data));
extern Pixmap FaceImageXFaceShape P_((void *data, void* type_data));
#endif
/* face_image_xpm.c */
extern void* FaceImageXpmRead P_((String file, void* type_data));
#ifdef SHAPE
extern void* FaceImageShapedXpmRead P_((String file, void* type_data));
#endif
extern void FaceImageXpmFree P_((void* data, void* type_data));
extern Pixmap FaceImageXpmPixmap P_((void *data, void* type_data));
extern Pixmap FaceImageXpmShape P_((void *data, void* type_data));
extern void FaceImageXpmInit P_((void));
/* face_search.c */
extern FaceSearchType* FaceSearchTypeByName P_((char *name));
extern void FaceSearchTypeRegister P_((FaceSearchType* type));
extern int FaceSearch P_((MailItem* item, FaceSearchData* search_list));
extern int FaceSearchLoad P_((char *name, MailItem* item, FaceSearchData* data));
extern FaceSearchData* FaceSearchParse P_((char* str, FaceFormat format));
/* face_search_binding.c */
extern void FaceSearchBindingInit P_((void));
/* face_search_facedb.c */
extern void FaceSearchFacedbInit P_((void));
/* face_search_resource.c */
extern void FaceSearchResourceInit P_((void));
/* face_search_uh.c */
extern void FaceSearchUserHostInit P_((void));
/* face_search_xface.c */
#ifdef XFACE
extern void FaceSearchXFaceInit P_((void));
#endif
/* face_shape.c */
extern void FaceShapeCreate P_((void));
/* face_sound.c */
#ifdef SOUND
extern FaceSound* FaceSoundCreate P_((char* file));
extern void FaceSoundFree P_((FaceSound* fs));
extern int FaceSoundLoad P_((char* name, MailItem* item, FaceSearchData* data));
extern void FaceSoundPlay P_((FaceSound* fs));
extern void FaceSoundInit P_((void));
extern void FaceSoundFind P_((MailItem* item));
#endif
/* mail_body.c */
extern char* MailBodyRead P_((int content_length));
extern void MailBodySkip P_((int content_length));
/* mail_box.c */
extern void MailBoxParse P_((void));
/* mail_check.c */
extern void MailCheck P_((void));
/* mail_file.c */
extern int MailFileOpen P_((char* name));
extern void MailFileClose P_((void));
extern int MailFileReadChar P_((void));
extern void MailFileUnReadChar P_((int ch));
extern void MailFileUnReadString P_((char* str));
extern void MailFileClearUnRead P_((void));
extern void MailFilePeekString P_((char* buf, int len));
extern int MailFileReadString P_((char* buf, int len));
extern int MailFileSkipString P_((int len));
extern int MailFilePeekChar P_(());
/* mail_header.c */
extern char* MailHeaderLineRead P_((void));
extern MailHeader* MailHeaderRead P_((void));
extern MailHeader* MailHeaderListRead P_((void));
extern void MailHeaderFree P_((MailHeader* header));
extern void MailHeaderListFree P_((MailHeader* list));
extern MailHeader* MailHeaderFind P_((char* name, MailHeader* list));
extern int MailHeaderListCompare P_((MailHeader* list1, MailHeader* list2));
/* mail_items.c */
extern void MailBoxClear P_((void));
extern void MailBoxUnClear P_((void));
extern void MailBoxClean P_((void));
extern void MailItemCreate P_((MailHeader* headers));
extern void MailItemCreateNoHeaders P_((char* user,
char* host,
char** annotations));
extern void MailBoxEmpty P_((void));
extern void MailItemInit P_((void));
/* mail_parse.c */
extern void MailParseAddress P_((String from,
String* user,
String* host));
/* main.c */
extern void CheckMailNow P_((void));
extern int main P_((int argc, char** argv));
extern void regerror P_((String s));
/* path.c */
extern char** PathParse P_((char* path));
extern int PathEnumerate P_((char* file,
char** paths,
int (*func)(char* file, char* path, void* data),
void* data));
/* pop_check.c */
extern void PopCheck P_((void));
/* regexp.c */
extern regexp* regcomp P_((char* exp));
extern int regexec P_((regexp *prog, char *string));
/* regsub.c */
extern void regsub P_((regexp *prog, char *source, char *dest));
/* string.c */
extern char* SkipChars P_((char* str, char* delim));
extern char* ParseToken P_((char** str, char* delim));
extern char** StringParse P_((char* str, char* delims));
#endif /* FACES_H_ */
|