int
  SU_Number_Of_Str(
    char *The_String,
    char *In_The_String,
    BOOL Case_Sensitive )
{
  int count;
/*   int i; */
  char *s;
  char *ss;

  ASSERT( In_The_String != NULL );

  count = 0;

  if ( (int)strlen( The_String ) > (int)strlen( In_The_String ) )
    return count;

/*   s = (char *)malloc( (int)strlen( In_The_String ) + 1 ); */
  if ( fNewMemory( (void **)&s, (int)strlen( In_The_String ) + 1 ) )
  {
    if ( Case_Sensitive == TRUE ) {
      s = strcpy( s, In_The_String );
      while ( ( s = strstr( s, The_String ) ) != NULL ) {
        s = s + (int)strlen( The_String );
        count ++;
      } 
      FreeMemory( s );

      return count;
    }
    else {
/*       ss = (char *)malloc( (int)strlen( The_String ) + 1 ); */
      if ( fNewMemory( (void **)&ss, (int)strlen( The_String ) + 1 ) )
      {

        s = strcpy( s, In_The_String );
        ss = strcpy( ss, The_String );
        SU_Make_Lowercase( s );
        SU_Make_Lowercase( ss );
        while ( ( s = strstr( s, ss ) ) != NULL ) {
          s = s + (int)strlen( ss );
          count++;
        }
        FreeMemory( ss );
      }
      FreeMemory( s );

      return count;
    }
  }
  else
    return count;

} /* SU_Number_Of_Str */
Beispiel #2
0
/* This function returns the text of the specified signature, or NULL
 * if the signature could not be found or loaded.
 */
LPSTR FASTCALL GetEditSignature( char * pSig )
{
   char sz[ _MAX_FNAME ];
   LPSTR lpszSignature;
   HNDFILE fh;

   lpszSignature = NULL;
   if( 0 != strcmp( pSig, GS(IDS_STR946) ) )
      {
      wsprintf( sz, "%s.sig", (LPSTR)pSig );
      if( ( fh = Ameol2_OpenFile( sz, DSD_SIG, AOF_READ ) ) != HNDFILE_ERROR )
         {
         WORD cbSignature;
   
         cbSignature = (WORD)Amfile_GetFileSize( fh );
         if( fNewMemory( &lpszSignature, cbSignature + 8 ) )
            {
            lpszSignature[ 0 ] = CR;
            lpszSignature[ 1 ] = LF;
            lpszSignature[ 2 ] = CR;
            lpszSignature[ 3 ] = LF;
            if( Amfile_Read( fh, lpszSignature + 4, cbSignature ) != cbSignature )
               {
               DiskReadError( hwndFrame, sz, FALSE, FALSE );
               FreeMemory( &lpszSignature );
               }
            else
            {
               if( fEditAtTop )
               {
               lpszSignature[ cbSignature + 3 ] = CR;
               lpszSignature[ cbSignature + 4 ] = LF;
               lpszSignature[ cbSignature + 5 ] = CR;
               lpszSignature[ cbSignature + 6 ] = LF;
               lpszSignature[ cbSignature + 7 ] = '\0';
               }
               else
                  lpszSignature[ cbSignature + 4 ] = CR;
            }
            }
         Amfile_Close( fh );
         return( lpszSignature );
         }
      }
   if( fNewMemory( &lpszSignature, 1 ) )
      lpszSignature[ 0 ] = '\0';
   return( lpszSignature );
}
Beispiel #3
0
/*--------------------------------------------------------------
 Routine : scale_symbol
 Purpose : Scales the symbol.
           Creates and returns the "scaled" symbol.
           Space is allocated to hold the scaled symbol.
---------------------------------------------------------------*/
SYMBOL *
scale_symbol(SYMBOL *symbol, float scale)
{
    SYMBOL        *new_symbol;
    SEGMENT        *new_seg, *seg_list;

    if ( !fNewMemory( (void *)&new_symbol, sizeof( SYMBOL ) ) )
    {
      printf("\n*** scale_symbol : malloc failed ***\n");
      exit(1);
    }
    new_symbol->type = symbol->type;
    new_symbol->depth = symbol->depth * (float)scale;
    new_symbol->width = symbol->width * (float)scale;
    new_symbol->textdepth = symbol->textdepth * (float)scale;
    new_symbol->textwidth = symbol->textwidth * (float)scale;
	new_symbol->text_lines_allowed = symbol->text_lines_allowed;
    seg_list = symbol->segment_list;
    new_symbol->segment_list = scale_segment(seg_list, scale);
    new_seg = new_symbol->segment_list;
    seg_list = seg_list->next;
    while (seg_list != NULL) {
        new_seg->next = scale_segment(seg_list, scale);
        new_seg = new_seg->next;
        seg_list = seg_list->next;
    }
    return new_symbol;
}
Beispiel #4
0
void FASTCALL CmdSignatureDlg_DisplaySig( HWND hwnd, int index )
{
   char sz[ _MAX_FNAME ];
   HWND hwndList;
   HWND hwndEdit;
   HNDFILE fh;

   hwndList = GetDlgItem( hwnd, IDD_LIST );
   hwndEdit = GetDlgItem( hwnd, IDD_EDIT );
   ComboBox_GetLBText( hwndList, index, sz );
   lstrcat( sz, ".sig" );
   if( ( fh = Ameol2_OpenFile( sz, DSD_SIG, AOF_READ ) ) != HNDFILE_ERROR )
      {
      WORD wSize;
      LPSTR lpText;

      INITIALISE_PTR(lpText);
      wSize = LOWORD( Amfile_GetFileSize( fh ) );
      if( fNewMemory( &lpText, wSize + 1 ) )
         {
         if( Amfile_Read( fh, lpText, wSize ) != wSize )
            DiskReadError( hwnd, sz, FALSE, FALSE );
         else
            {
            lpText[ wSize ] = '\0';
            Edit_SetText( hwndEdit, lpText );
            }
         FreeMemory( &lpText );
         }
      Amfile_Close( fh );
      }
   else
      Edit_SetText( hwndEdit, "" );
   SetWindowLong( hwnd, DWL_USER, (LPARAM)index );
}
char *
  SU_Left_Justified(
    char *The_String,
    int  In_The_Width,
    char With_The_Filler )
{
  int i;
/*   char *Justified_String = (char *)malloc( In_The_Width + 1 ); */
  char *Justified_String;

  ASSERT( In_The_Width >= (int)strlen( The_String ) );

  if( fNewMemory( (void **)&Justified_String, In_The_Width + 1 ) )
  {
    for ( i = 0; i < (int)strlen( The_String ); i++ )
      Justified_String[ i ] = The_String[ i ];

    for ( i = i; i < In_The_Width; i++ ) 
      Justified_String[ i ] = With_The_Filler;

    Justified_String[ i ] = '\0';

    return Justified_String;

  }
  else
    return NULL;

} /* SU_Left_Justified */
char *
  SU_Right_Justified(
    char *The_String,
    int  In_The_Width,
    char With_The_Filler )
{
  int i;
  int j;
  int Right_Margin;
/*   char *Justified_String = (char *)malloc( In_The_Width + 1 ); */
  char *Justified_String;

  ASSERT( In_The_Width >= (int)strlen( The_String ) );

  if ( fNewMemory( (void **)&Justified_String, In_The_Width + 1 ) )
  {
    Right_Margin = In_The_Width - (int)strlen( The_String );
 
    for ( i = 0; i < Right_Margin; i++ )
      Justified_String[ i ] = With_The_Filler;

    j = 0;
    for ( i = i; i < In_The_Width; i++ )
      Justified_String[ i ] = The_String[ j ];
 
    Justified_String[ i ] = '\0';

    return Justified_String;

  }
  else
    return NULL;

} /* SU_Right_Justified */
Beispiel #7
0
void FASTCALL CmdPrintOutbasket( HWND hwnd )
{
   HPRINT hPr;
   BOOL fOk = TRUE;
   LPSTR lpOBPrintBuf;

   /* Show and get the print terminal dialog box.
    */
   if( !Adm_Dialog( hRscLib, hwnd, MAKEINTRESOURCE(IDDLG_PRINTOUTBASKET), PrintOutbasketDlg, 0L ) )
      return;

   fNewMemory( &lpOBPrintBuf, LEN_TEMPBUF );
   GetWindowText( hwnd, lpOBPrintBuf, LEN_TEMPBUF );
   if(   NULL != ( hPr = BeginPrint( hwnd, lpOBPrintBuf, &lfFixedFont ) ) )
      {
      register int cCount;

      for( cCount = 0; fOk && cCount < cCopies; ++cCount )
         {

      int nCount;
      int c;
      HWND hwndList;

      ResetPageNumber( hPr );
      fOk = BeginPrintPage( hPr );

      hwndList = GetDlgItem( hwnd, IDD_LIST );

      nCount = ListBox_GetCount( hwndList );
      for( c = 0; c != nCount; c++ )
         {
         OBINFO obinfo;
         LPOB lpob;

         lpob = (LPOB)ListBox_GetItemData( hwndList, c );
         Amob_GetObInfo( lpob, &obinfo );
         Amob_Describe( lpob, lpOBPrintBuf );
         if( TestF(obinfo.obHdr.wFlags, OBF_HOLD) )
            wsprintf( lpOBPrintBuf, "%s (H)", lpOBPrintBuf );
         if( TestF(obinfo.obHdr.wFlags, OBF_KEEP) )
            wsprintf( lpOBPrintBuf, "%s (K)", lpOBPrintBuf );
         if( fOk )
            fOk = PrintLine( hPr, lpOBPrintBuf );
         }
      if( fOk )
         EndPrintPage( hPr );
      }
      }
   EndPrint( hPr );
   if( NULL != lpOBPrintBuf )
      FreeMemory( &lpOBPrintBuf );
}
Beispiel #8
0
/*--------------------------------------------------------------
 Routine : scale_polyline
 Purpose : Scales the polyline segment.
           Creates and returns the "scaled" polyline segment.
           Space is allocated to hold the scaled polyline segment.
---------------------------------------------------------------*/
static POLYLINE *
scale_polyline(POLYLINE *poly, float scale)
{
    POLYLINE        *new_poly;
    int                i;
    FTA_POINT           *points;

/*     if ((new_poly = (POLYLINE *)malloc(sizeof(POLYLINE))) == NULL) { */
/*         printf("\n*** scale_polyline : malloc failed ***\n"); */
/*         exit(1); */
/*     } */
    if ( !fNewMemory( (void *)&new_poly, sizeof( POLYLINE ) ) )
    {
      printf("\n*** scale_polyline : malloc failed ***\n");
      exit(1);
    }
/*     if ((new_poly->points =    */
/*                 (POINT *)malloc(poly->num_points*sizeof(POINT))) == NULL) {    */
/*         printf("\n*** scale_polyline : malloc failed ***\n");    */
/*         exit(1);    */
/*     }    */
    if (  
      !fNewMemory(  
        (void *)&points,  
        ( poly->num_points * sizeof( FTA_POINT ) ) ) ) 
    {  
      printf("\n*** scale_polyline : malloc failed ***\n");  
      exit(1);  
    }  
    new_poly->points = points;
    new_poly->num_points = poly->num_points;
    for (i = 0; i < poly->num_points; i++) {
        new_poly->points[i].x = poly->points[i].x * scale;
        new_poly->points[i].y = poly->points[i].y * scale;
    }

    return new_poly;
}
char *
  SU_Join(
    char *string1,
    char *string2 )
{
    char *result;

    /* are both strings empty? */
    if(!string1 && !string2) {
        result = NULL;

    } else if(string1 && !string2) {
		fNewMemory( (void **)&result, strlen(string1) + 1 );
        /* result = (char*)malloc((strlen(string1) + 1) * sizeof(char)); */
        if(result) {
            strcpy(result, string1);
        }
    } else if(!string1 && string2) {
		fNewMemory( (void **)&result, strlen(string2) + 1 );
        /* result = (char*)malloc((strlen(string2) + 1) * sizeof(char));*/
        if(result) {
            strcpy(result, string2);
        }

    } else if(string1 && string2) {
		fNewMemory( (void **)&result, strlen(string1) + strlen(string2) + 1 );
        /* result = (char*)malloc((strlen(string1) + strlen(string2) + 1) * sizeof(char)); */
        if(result) {
            strcpy(result, string1);
            strcat(result, string2);
        }
    }

    return result;

} /* SU_Join */
Beispiel #10
0
BOOL FASTCALL CmdSignatureDlg_SaveSig( HWND hwnd, int index )
{
   char sz[ _MAX_FNAME ];
   HWND hwndList;
   register int c;
   HNDFILE fh;

   hwndList = GetDlgItem( hwnd, IDD_LIST );
   ComboBox_GetLBText( hwndList, index, sz );
   for( c = 0; sz[ c ]; ++c )
      if( !ValidFileNameChr( sz[ c ] ) )
         {
         wsprintf( lpTmpBuf, GS( IDS_STR136 ), sz[ c ] );
         fMessageBox( hwnd, 0, lpTmpBuf, MB_OK|MB_ICONEXCLAMATION );
         return( FALSE );
         }
   lstrcat( sz, ".sig" );
   if( ( fh = Ameol2_CreateFile( sz, DSD_SIG, 0 ) ) == HNDFILE_ERROR )
      fMessageBox( hwnd, 0, GS( IDS_STR137 ), MB_OK|MB_ICONEXCLAMATION );
   else
      {
      WORD wSize;
      LPSTR lpText;
      HWND hwndEdit;

      INITIALISE_PTR(lpText);
      hwndEdit = GetDlgItem( hwnd, IDD_EDIT );
      wSize = Edit_GetTextLength( hwndEdit ) + 1;
      if( !fNewMemory( &lpText, wSize ) )
         OutOfMemoryError( hwnd, FALSE, FALSE );
      else
         {
         Edit_GetText( hwndEdit, lpText, wSize );
         if( Amfile_Write( fh, lpText, wSize ) == wSize )
            {
            FreeMemory( &lpText );
            Amfile_Close( fh );
            return( TRUE );
            }
         FreeMemory( &lpText );
         DiskWriteError( hwnd, sz, FALSE, FALSE );
         }
      Amfile_Close( fh );
      Amfile_Delete( sz );
      }
   return( FALSE );
}
Beispiel #11
0
char *
  SU_Stripped_Trailing(
    char The_Character,
    char *From_The_String,
    BOOL Case_Sensitive )
{
  int i;
  int j;
/*   char *Stripped_String = (char *)malloc( (int)strlen( From_The_String ) + 1 ); */
  char *Stripped_String;

  if ( fNewMemory( (void **)&Stripped_String, (int)strlen( From_The_String ) + 1 ) )
  {

    j = 0;
    i = (int)strlen( From_The_String ) - 1;
    if ( Case_Sensitive == TRUE ) {
      while ( ( i >= 0 ) &&
              ( From_The_String[ i ] == The_Character ) ) {
        i--;
      }
      j = i + 1;
      for ( i = 0; i < j; i++ ) {
        Stripped_String[ i ] = From_The_String[ i ];
      }
    }
    else {
      while ( ( i >= 0 ) &&
              ( tolower( From_The_String[ i ] ) == 
                  tolower( The_Character ) ) ) {
        i--;
      }
      j = i + 1;
      for ( i = 0; i < j; i++ ) {
        Stripped_String[ i ] = From_The_String[ i ];
      }
    }

    Stripped_String[ i ] = '\0';

    return Stripped_String;

  }
  else
    return NULL;

} /* SU_Stripped_Trailing */
Beispiel #12
0
/*---------------------------------------------------------------
 Routine : load_from_file
 Purpose : Routine called to load data from a file.
 This routine enforces the functionality required for file
 selection through dialogs.
---------------------------------------------------------------*/
void load_from_file(
    char   *filename, 
    char   *appln_title,
    char   *title,
    char   *filter,
    char   *existing_data,
    void   *data_type,
    int    (*read_data_procedure)(void *, char *),
	int     called_from)
{
	fstruct *client_data;

	if ( !fNewMemory( (void *)&client_data, sizeof( fstruct ) ) )
	{
		exit( 1 );
	}

	/* Set up the client data for use in callback */
	client_data->action_procedure = read_data_procedure;
	client_data->title = title;
	client_data->filter = filter;
	client_data->data_type = data_type;  
	client_data->file_error_string = strsave(FILE_OPEN_ERROR);
	client_data->file_dialog_title  = strsave(appln_title);
	client_data->mode = R_OK;

	client_data->filename = filename;

	if ( existing_data != NULL ) {  

		if(called_from == FD_FTA) {
			/* routine called from FTA code */
			if(FTAFrameAskQuestion(existing_data, FTA_QUESTION_TITLE)) {
				load_file_cb(client_data, called_from);
			}
		} else if(called_from == FD_PED){
			/* routine called from PED code */
			if(PEDFrameAskQuestion(existing_data, FTA_QUESTION_TITLE)) {
				load_file_cb(client_data, called_from);
			}
		}
	} else {

		load_file_cb(client_data, called_from);
	}

} /* load_from_file */
Beispiel #13
0
/* Create a new image list.
 */
WINCOMMCTRLAPI HIMAGELIST WINAPI EXPORT Amctl_ImageList_Create( int cx, int cy, UINT flags, int cInitial, int cGrow )
{
   static HIMAGELIST himl;

   INITIALISE_PTR(himl);
   if( fNewMemory( &himl, sizeof( IMAGELIST ) ) )
      {
      himl->cGrow = cGrow;
      himl->cSlots = 0;
      himl->cx = cx;
      himl->cy = cy;
      himl->flags = flags;
      himl->clrBk = CLR_DEFAULT;
      CreateEmptyBitmaps( himl, cInitial, cGrow ? ( ( cInitial / cGrow ) + 1 ) * cGrow : cInitial );
      }
   return( himl );
}
Beispiel #14
0
/* This function adds the specified blink entry to the linked list
 * of blink entries.
 */
LPBLINKENTRY FASTCALL AddBlinkToList( LPSTR lpszName, DWORD dwBlinkFlags, LPSTR lpszConnCard, UINT iCommand, BOOL fNew )
{
   LPBLINKENTRY lpbeNew;

   INITIALISE_PTR(lpbeNew);

   /* First create an entry for this blink in the list.
    */
   if( fNewMemory( &lpbeNew, sizeof(BLINKENTRY ) ) )
      {
      /* Link this entry into the list.
       */
      lpbeNew->lpbeNext = lpbeFirst;
      lpbeNew->lpbePrev = NULL;
      if( lpbeFirst )
         lpbeFirst->lpbePrev = lpbeNew;
      lpbeFirst = lpbeNew;

      /* Fill out the structure.
       */
      strcpy( lpbeNew->szName, lpszName );
      strcpy( lpbeNew->szConnCard, lpszConnCard );
      lpbeNew->iCommandID = iCommand;
      lpbeNew->dwBlinkFlags = dwBlinkFlags;

      /* For Internet type blinks, set the SMTP authentication
       * information.
       */
      if (fNew && ( dwBlinkFlags & BF_IPFLAGS) )
      {
         strcpy( lpbeNew->szAuthInfoUser, szSMTPMailLogin );
         memcpy( lpbeNew->szAuthInfoPass, szSMTPMailPassword, LEN_PASSWORD );
         SaveBlinkSMTPAuth( lpbeNew );
      }

      /* Fill out the RAS elements (Win32 only)
       * If this is a CIX only conn card and we connect to
       * CIX via dial-up, disable RAS.
       */
      lpbeNew->rd = rdDef;
      if( ( !fCIXViaInternet && 0 == ( dwBlinkFlags & ~BF_CIXFLAGS ) ) || ( strcmp( lpszName, "CIX Forums Via Dial-Up" ) == 0 ) )
         lpbeNew->rd.fUseRAS = FALSE;
      }
   return( lpbeNew );
}
Beispiel #15
0
char *
  SU_Centered(
    char *The_String,
    int  In_The_Width,
    char With_The_Filler )
{
  int Left_Margin;
  int Right_Margin; 
  int i;
  int j;

/*   char *Centered_String = (char *)malloc( In_The_Width + 1 ); */
  char *Centered_String;

  ASSERT( In_The_Width >= (int)strlen( The_String ) );

  if ( fNewMemory( (void **)&Centered_String, In_The_Width + 1 ) )
  { 

    Left_Margin = ( In_The_Width - (int)strlen( The_String ) ) / 2;
    Right_Margin = (int)strlen( The_String ) + Left_Margin; 

    for ( i = 0; i < Left_Margin; i++ ) {
      Centered_String[ i ] = With_The_Filler;
    }

    j = 0;
    for ( i = i; i < Right_Margin; i++ ) {
      Centered_String[ i ] = The_String[ j++ ];
    }

    for ( i = i; i < In_The_Width; i++ ) {
      Centered_String[ i ] = With_The_Filler;
    }

    Centered_String[ i ] = '\0';
  
    return Centered_String;

  }
  else
    return NULL;

} /* SU_Centered */
Beispiel #16
0
/*--------------------------------------------------------------
 Routine : scale_segment
 Purpose : Scales the segment.
           Creates and returns the "scaled" segment.
           Space is allocated to hold the scaled segment.
---------------------------------------------------------------*/
static SEGMENT *
scale_segment(SEGMENT *seg_list, float scale)
{
    SEGMENT        *new_seg;

/*     ASSERTMSG(      */
/*       fValidPointer( seg_list, sizeof( SEGMENT ) ),     */
/*       "Segment list ptr not valid" );     */

/*     if ((new_seg = (SEGMENT *)malloc(sizeof(SEGMENT))) == NULL) { */
/*         printf("\n*** scale_segment : malloc failed ***\n"); */
/*         exit(1); */
/*     } */
    if ( !fNewMemory( (void *)&new_seg, sizeof( SEGMENT ) ) )
    {
      printf("\n*** scale_segment : malloc failed ***\n");
      exit(1);
    }
    new_seg->next = NULL;
    new_seg->type = seg_list->type;
/*     new_seg->seg = seg_list->seg;  */
    switch (seg_list->type) {
    case CLEAR_ARC_SEG :
    case FILL_ARC_SEG :
    case ARC_SEG :
        new_seg->seg = (void *)scale_arc(seg_list->seg, scale);
        break;
    case RECTANGLE_SEG :
	case FILL_RECTANGLE_SEG:
        new_seg->seg = (void *)scale_rectangle(seg_list->seg, scale);
        break;
    case FILL_POLYLINE_SEG :
    case POLYLINE_SEG :
        new_seg->seg = (void *)scale_polyline(seg_list->seg, scale);
        break;
    case LINE_SEG :
        new_seg->seg = (void *)scale_line(seg_list->seg, scale);
        break;
    default:
        printf("\n*** scale_segment : Invalid symbol type ***\n\n");
        exit(1);
    }
    return new_seg;
}
Beispiel #17
0
/*--------------------------------------------------------------
 Routine : scale_line
 Purpose : Scales the line segment.
           Creates and returns the "scaled" line segment.
           Space is allocated to hold the scaled line segment.
---------------------------------------------------------------*/
static LINE *
scale_line(LINE *line, float scale)
{
    LINE        *new_line;

/*     if ((new_line = (LINE *)malloc(sizeof(LINE))) == NULL) { */
/*         printf("\n*** scale_line : malloc failed ***\n"); */
/*         exit(1); */
/*     } */
    if ( !fNewMemory( (void *)&new_line, sizeof( LINE ) ) )
    {
      printf("\n*** scale_line : malloc failed ***\n");
      exit(1);
    }
    new_line->start.x = line->start.x * scale;
    new_line->start.y = line->start.y * scale;
    new_line->end.x = line->end.x * scale;
    new_line->end.y = line->end.y * scale;
    return new_line;
}
Beispiel #18
0
/*--------------------------------------------------------------
 Routine : scale_rectangle
 Purpose : Scales the rectangle segment.
           Creates and returns the "scaled" rectangle segment.
           Space is allocated to hold the scaled rectangle segment.
---------------------------------------------------------------*/
static RECTANGLE *
scale_rectangle(RECTANGLE *rect, float scale)
{
    RECTANGLE        *new_rect;

/*     if ((new_rect = (RECTANGLE *)malloc(sizeof(RECTANGLE))) == NULL) { */
/*         printf("\n*** scale_rectangle : malloc failed ***\n"); */
/*         exit(1); */
/*     } */
    if ( !fNewMemory( (void *)&new_rect, sizeof( RECTANGLE ) ) )
    {
      printf("\n*** scale_rectangle : malloc failed ***\n");
      exit(1);
    }
    new_rect->point.x = rect->point.x * scale;
    new_rect->point.y = rect->point.y * scale;
    new_rect->width = rect->width * scale;
    new_rect->height = rect->height * scale;
    return new_rect;
}
Beispiel #19
0
char *
  SU_Copy(
    char *string )
{
    char *result;

    /* are both strings empty? */
    if(!string) {
        result = NULL;

    } else {
		fNewMemory( (void **)&result, strlen(string) + 1 );
        /* result = (char*)malloc((strlen(string) + 1) * sizeof(char)); */
        if(result) {
            strcpy(result, string);
        }
    }

    return result;

} /* SU_Copy */
Beispiel #20
0
/*--------------------------------------------------------------
 Routine : scale_arc
 Purpose : Scales the arc segment.
           Creates and returns the "scaled" arc segment.
           Space is allocated to hold the scaled arc segment.
---------------------------------------------------------------*/
static ARC *
scale_arc(ARC *arc, float scale)
{
    ARC                *new_arc;

/*     if ((new_arc = (ARC *)malloc(sizeof(ARC))) == NULL) { */
/*         printf("\n*** scale_arc : malloc failed ***\n"); */
/*         exit(1); */
/*     } */
    if ( !fNewMemory( (void *)&new_arc, sizeof( ARC ) ) )
    {
      printf("\n*** scale_arc : malloc failed ***\n");
      exit(1);
    }
    new_arc->point.x = arc->point.x * scale;
    new_arc->point.y = arc->point.y * scale;
    new_arc->width = arc->width * scale;
    new_arc->height = arc->height * scale;
    new_arc->start_angle = arc->start_angle;
    new_arc->end_angle = arc->end_angle;
    return new_arc;
}
Beispiel #21
0
/*---------------------------------------------------------------
 Routine : make_level
 Purpose : Create and initialise a LEVEL structure
---------------------------------------------------------------*/
LEVEL *
  make_level(
    ITEM *ip, 
    int lvl)
{
  LEVEL *lp;
/*  LEVEL *tlp; */

  if (ip == NULL) return NULL;
/*   if ((lp = (LEVEL *)malloc(sizeof(LEVEL))) == NULL) */
  if ( !fNewMemory( (void *)&lp, sizeof(LEVEL) ) )
  {
    printf("\n*** make_level : malloc failed ***\n");
    exit(1);
  }
  lp->level = lvl;
  lp->size = 0;
  lp->iptr = NULL;
  lp->next = NULL;
  return lp;

} /* make_level */
Beispiel #22
0
char *
  SU_Stripped(
    char The_Character,
    char *From_The_String,
    BOOL Case_Sensitive )
{
  int i;
  int j;
/*   char *Stripped_String = (char *)malloc( (int)strlen( From_The_String ) + 1 ); */
  char *Stripped_String;

  if ( fNewMemory( (void **)&Stripped_String, (int)strlen( From_The_String ) + 1 ) )
  {

    j = 0;
    if ( Case_Sensitive == TRUE ) {
      for ( i = 0; i < (int)strlen( From_The_String ); i++ ) {
        if ( From_The_String[ i ] != The_Character )
          Stripped_String[ j++ ] = From_The_String[ i ];
      }
    }
    else {
      for ( i = 0; i < (int)strlen( From_The_String ); i++ ) {
        if ( tolower( From_The_String[ i ] ) != tolower( The_Character ) )
          Stripped_String[ j++ ] = From_The_String[ i ];
      }
    }

    Stripped_String[ j ] = '\0';

    return Stripped_String;

  }
  else
    return NULL;

} /* SU_Stripped */
Beispiel #23
0
/* This function locates the old signature in the specified edit
 * control and replaces it with the new one.
 */
void FASTCALL ReplaceEditSignature( HWND hwndEdit, char * pszOldSig, char * pszNewSig, BOOL fTop )
{
   LPSTR lpszOldSigText;
   LPSTR lpszNewSigText;
   UINT cbEdit;

   /* Get some lengths. Skip the replacement if
    * the signature is smaller than the edit text.
    */
   cbEdit = Edit_GetTextLength( hwndEdit );
   if( NULL != ( lpszOldSigText = GetEditSignature( pszOldSig ) ) )
      {
      if( NULL != ( lpszNewSigText = GetEditSignature( pszNewSig ) ) )
         {
         if( strlen(lpszOldSigText) <= cbEdit )
            {
            LPSTR lpText;
         
            INITIALISE_PTR(lpText);
            if( fNewMemory( &lpText, cbEdit + 1 ) )
               {
               DWORD sel;
               int nOldSig;
               int selEnd;
               int selStart;
         
               /* Get the edit control contents.
                */
               sel = Edit_GetSel( hwndEdit );
               selStart = LOWORD(sel);
               selEnd = HIWORD(sel);
               Edit_GetText( hwndEdit, lpText, cbEdit+1 );
               nOldSig = FStrMatch( lpText, lpszOldSigText, TRUE, FALSE );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, FALSE );
#endif USEBIGEDIT
               if( -1 != nOldSig )
                  {
                  Edit_SetSel( hwndEdit, nOldSig, nOldSig + strlen(lpszOldSigText) );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               else
                  {
                  /* Not found, so go to end of edit text and append new
                   * signature there.
                   */
                  if( fTop )
                     Edit_SetSel( hwndEdit, 0, 0 );
                  else
                     Edit_SetSel( hwndEdit, 32767, 32767 );
                  Edit_ReplaceSel( hwndEdit, lpszNewSigText );
                  }
               Edit_SetSel( hwndEdit, selStart, selEnd );
#ifdef USEBIGEDIT
               SetWindowRedraw( hwndEdit, TRUE );
#endif USEBIGEDIT
               UpdateWindow( hwndEdit );
               FreeMemory( &lpText );
               }
            }
         FreeMemory( &lpszNewSigText );
         }
      FreeMemory( &lpszOldSigText );
      }
}
Beispiel #24
0
/* This function reads all blink manager entries into a locally
 * linked list.
 */
void FASTCALL LoadBlinkList( void )
{
   LPSTR lpsz;

   INITIALISE_PTR(lpsz);

   /* First create the Blink menu.
    */
   hBlinkMenu = GetSubMenu( GetSubMenu( hMainMenu, 0 ), 12 );

   /* Get the list of blink manager entries and
    * install them into the command table.
    */
   if( fNewMemory( &lpsz, 8000 ) )
      {
      UINT c;

      Amuser_GetPPString( szBlinkman, NULL, "", lpsz, 8000 );
      for( c = 0; lpsz[ c ]; ++c )
         {
         char szBtnBmpFilename[ 64 ];
         LPCSTR pszBtnBmpFilename;
         char szConnCard[ 40 ];
         DWORD dwBlinkFlags;
         LPBLINKENTRY lpbe;
         RASDATA rd2;
         int index;
         LPSTR lp;

         /* Read the configuration setting
          */
         Amuser_GetPPString( szBlinkman, &lpsz[ c ], "", lpTmpBuf, LEN_TEMPBUF );
         lp = lpTmpBuf;

         /* Set the default RAS settings
          */
         rd2 = rdDef;

         /* Parse blink flags value.
          */
         lp = IniReadLong( lp, &dwBlinkFlags );
         lp = IniReadText( lp, szConnCard, sizeof(szConnCard)-1 );
         if( *lp )
            {
            lp = IniReadInt( lp, &rd2.fUseRAS );
            if( rd2.fUseRAS )
               {
               char szRASPassword[ 80 ];

               lp = IniReadText( lp, rd2.szRASEntryName, RAS_MaxEntryName );
               lp = IniReadText( lp, rd2.szRASUserName, UNLEN );
               lp = IniReadText( lp, szRASPassword, PWLEN );
               DecodeLine64( szRASPassword, rd2.szRASPassword, PWLEN );
               }
            }

         /* Get button bitmap details.
          */
         lp = IniReadText( lp, szBtnBmpFilename, sizeof(szBtnBmpFilename) );
         lp = IniReadInt( lp, &index );

         /* Convert to proper filename or index.
          */
         pszBtnBmpFilename = szBtnBmpFilename;
         if( '\0' == *pszBtnBmpFilename )
            pszBtnBmpFilename = BTNBMP_GRID;

         /* Store the settings.
          */
         if( *szConnCard == '\0' )
            strcpy( szConnCard, szCIXConnCard );
         if( strcmp( &lpsz[ c ], "Custom" ) == 0 )
            lpbe = AddBlinkToList( &lpsz[ c ], dwBlinkFlags, szConnCard, IDM_CUSTOMBLINK, FALSE );
         else {
            WORD wDefKey;

            wDefKey = 0;
            if( strcmp( &lpsz[ c ], "Full" ) == 0 )
               wDefKey = MAKEKEY(HOTKEYF_CONTROL,'T');
            lpbe = AddBlinkToCommandTable( &lpsz[ c ], dwBlinkFlags, szConnCard, wDefKey, FALSE );
            }

         /* Store RAS settings.
          */
         if( NULL != lpbe )
            lpbe->rd = rd2;
         c += strlen( &lpsz[ c ] );
         }
      FreeMemory( &lpsz );
      }

   /* If no blink entries, install some defaults.
    */
   if( NULL == lpbeFirst )
      {
      AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, 0, TRUE );
      AddBlinkToList( "Custom", BF_POSTCIX|BF_GETCIX, szCIXConnCard, IDM_CUSTOMBLINK, TRUE );
      if( fUseInternet )
         AddBlinkToCommandTable( "Mail Only", BF_GETIPMAIL|BF_POSTIPMAIL, szCIXConnCard, 0, TRUE );
      AddBlinkToCommandTable( "Upload Only", BF_POSTIPMAIL|BF_POSTIPNEWS|BF_POSTCIX, szCIXConnCard, 0, TRUE );
      AddBlinkToCommandTable( "CIX Forums Only", BF_POSTCIX|BF_GETCIX, szCIXConnCard, 0, TRUE );
      if( fUseInternet )
         AddBlinkToCommandTable( "Internet Only", BF_IPFLAGS, szCIXConnCard, 0, TRUE );
      fBlinkListLoaded = FALSE;
      }
   else
      {
      /* Always make sure we have a Default blink
       * command.
       */
      if( 0 == GetBlinkCommandID( "Full" ) )
         AddBlinkToCommandTable( "Full", BF_FULLCONNECT, szCIXConnCard, MAKEKEY(HOTKEYF_CONTROL,'T'), TRUE );
      fBlinkListLoaded = TRUE;
      }
}
Beispiel #25
0
/*---------------------------------------------------------------
 Routine : save_to_file
 Purpose : Routine called to save data to a file.
 This routine enforces the functionality required for file
 selection through dialogs.

 Sets up client data to be passed between routines in the
 save file thread.
 if filename given
 then
   if file exists
   then
     query if file is to be overwritten
       (overwrite if so)
   end if
 else
   if given but doesn't exist
   then
     save the data to the file
   end if
 end if
---------------------------------------------------------------*/
void
  save_to_file(
    char     *filename,
    char     *appln_title,
    char     *title,
    char     *filter,
    void     *data_type,  
    int      (*save_data_procedure)(void *, char *),
    BOOL     force_overwrite,
	int     called_from
    )
{

	fstruct *client_data;
	char *s;

	if ( !fNewMemory( (void *)&client_data, sizeof( fstruct ) ) )
	{
		exit( 1 );
	}

	/* Set up the client data for use in callback */
	client_data->action_procedure = save_data_procedure;
	client_data->title = title;
	client_data->filter = filter;
	client_data->data_type = data_type;  
	client_data->file_error_string = strsave(SAVE_ERROR);
	client_data->file_dialog_title  = strsave(appln_title);
	client_data->mode = W_OK;

	if ( !(filename == NULL) ) {

		/* Set up the filename in client data for use in callback */
		client_data->filename = filename; 

		/* if file exists and not forced overwrite then */
		if ( file_exists( filename ) && !( force_overwrite ) ) {

			/* File exists, query overwrite */
			s = filename_from_pathname( filename );
			client_data->file_dialog_title =
			(char *)strgrow(
				client_data->file_dialog_title,
				s );

			if(called_from == FD_FTA) {
				/* routine called from FTA code */
				if(FTAFrameAskQuestion(FILE_EXISTS_QUESTION, client_data->file_dialog_title)) {
					overwrite_file_cb((fstruct *)client_data, FD_FTA);
				}
			} else if(called_from == FD_PED) {
				/* routine called from FTA code */
				if(PEDFrameAskQuestion(FILE_EXISTS_QUESTION, client_data->file_dialog_title)) {
					overwrite_file_cb((fstruct *)client_data, FD_PED);
				}
			}


			/* Don't free client_data as the callback still needs it */
			strfree( s ); 

		} else { /* file given, does not exist, or is forced overwrite */

			if ( (*save_data_procedure)(data_type, filename) == FILE_ERROR ) {

				s = filename_from_pathname( client_data->filename );
				client_data->file_error_string =
				(char *)strgrow(
					client_data->file_error_string,
					s );

 				if(called_from == FD_FTA) {
					/* routine called from FTA code */
					FTAFramePostError(client_data->file_error_string, client_data->file_dialog_title);
				} else if(called_from == FD_PED) {
					/* routine called from FTA code */
					PEDFramePostError(client_data->file_error_string, client_data->file_dialog_title);
				}
				

				strfree( s ); 
 
				end_thread_cb(client_data);
			}

		} /* end if file exists */

	} else { /* NULL filename */

		/* Get selection of filename and save using that name */
		select_filename_and_act_cb(client_data);

	}

} /* save_to_file */
float                              /* RET - time (seconds)                   */
  probs_estimate(
    TREE *tree,         /* IN  - tree                             */
    int max_order,      /* IN  - number of cut sets               */
    int min_term,       /* IN  - min number of terms to evaluate  */
    int max_term)       /* IN  - max number of terms to evaluate  */
{
    int num_mcs;   /* number of cut sets used */
    float t = 0;
    int i,j;
    Group **index; /* index to the groups   */
	int *z;
    Group  *p;     /* pointer               */
    clock_t time1, time2;
    BitArray *stop = BitCreate(1);  /* 1-bit zero */
	float *probs;
	
	/*     TimeEstimate Base; */

    /* find out how many cut sets are actually used */
    num_mcs = ExprCountOrder(tree->mcs_expr, max_order);

	/* make sure that max_term does not exceed number of mcs */
	/* if number of mcs is zero then return 0 */
	if(num_mcs == 0) {
		return 0.0f;
	} else if (max_term > num_mcs) {
		max_term = num_mcs;
	}

	/* allocate memory required for testing */
    if ( !fNewMemory( (void *)&probs, ( tree->num_bas * sizeof(float) ) ) ) 
    {
        exit(1);
    }
    if ( !fNewMemory( (void *)&index, ( num_mcs * sizeof(Group *) ) ) )
    {
      exit( 1 );
    }
    if ( !fNewMemory( (void *)&z, ( num_mcs * sizeof(int) ) ) )
    {
      exit( 1 );
    }

	/* populate the arrays with default data */
	for(i=0, p=tree->mcs_expr; i<num_mcs; i++, p=p->next) {
		index[i] = p;
		z[i] = i;
	}	

	/* fill the probs array */
    get_probs( probs );


	/* set the static variables to sensible values */
	set_basic_n(tree->num_bas);
	set_prob_term(0.0);	
	set_basic_prob(probs);

	/* The function that takes most of the time is calc_sub_term().
	   Run this function for each number of terms required. Run it
	   enough times for the CPU clock to change. */
    for (i = min_term; i <= max_term; i++) {
		time1 = clock();
		j = 0;
		do {
			calc_sub_term(z, i, index);
			j++;
			time2 = clock();
		} while(time1 == time2);

        t += nCr(num_mcs, i) * (time2 - time1) / j;
    }

    FreeMemory(index);
	FreeMemory(z);
	FreeMemory(probs);

    return t/CLOCKS_PER_SEC;

} /* probs_estimate */
/*---------------------------------------------------------------
 Routine : calculate_probs
 Purpose : Calculate the probabilities for the tree, based upon
 the minimal cut sets.
---------------------------------------------------------------*/
BOOL
  calculate_probs(
    char *filename,       /* IN - filename to write report to */
    TREE *tree,           /* IN - tree                         */
    int   max_order,      /* IN - max order of cut sets to use */
    int   prob_n_terms,   /* IN - number of terms in expansion */
    float unit_time )     /* IN - unit time factor to be applied */
{
    BitArray *stop = BitCreate(1);  /* 1-bit zero */
    FILE  *file;
    Expr   e;
    Group *g;
    float *probs, *cp, *imp;
    float  p;
    int    num_bas, num_mcs, i, j;
/*     char  *mcs_file; */
/*     int    order; */
    clock_t time1, time2;
    time_t tp;
    BOOL success = TRUE;
	float one_increment /* value for one increment of the progress bar */;

 /* start clock */
    time1 = clock();

    if ( (file = fopen(filename, "w")) == NULL) {
        printf("*** calculate_probs : error opening file\n");
        return FALSE;
    }

/*     printf("calculate_probs()\n"); */

 /* include transfered-in trees and build the primary event list
  *
  * We need to do something different to deal with Common Cause Analysis
  * We don't need the tree, but we do need the primary event list.
  * Need to add the common cause events into the primary event list.
  */
 /* if necessary, expand tree */
    expand_tree(tree);

 /* set probs in BASLIST from the events database */
    set_bas_prob( unit_time );

 /* get number of primary events */
    if ((num_bas = tree->num_bas) == 0) {
fclose( file );
        return FALSE;
    }

  if (GenerateNumericalProbabilityCheckForInterrupt()) {
    success = FALSE;
fclose( file );
    return success;
  }

 /* create array of probabilities of primary events */
    if ( !fNewMemory( (void *)&probs, ( num_bas * sizeof(float) ) ) ) 
    {
        printf("\n*** calculate_probs 1 : malloc failed ***\n");
        exit(1);
    }

    if ( !fNewMemory( (void *)&imp, ( num_bas * sizeof(float) ) ) ) 
    {
        printf("\n*** calculate_probs : malloc failed ***\n");
        exit(1);
    }

 /* fill array */
    get_probs( probs );

 /* get mcs list */
    e = tree->mcs_expr;

    /* num_mcs =  ExprCount(e); */

    /* how many mcs are actually used? */
	num_mcs = ExprCountOrder(tree->mcs_expr, max_order);

	/* make sure that max_term does not exceed number of mcs */
	/* if number of mcs is zero then return FALSE */
	if(num_mcs == 0) {
		return FALSE;
	} else if (prob_n_terms > num_mcs) {
		prob_n_terms = num_mcs;
	}

	/* initialise Working dialog */
	/* most of the cpu time is taken up in the ExprProb() function */
	/* the working dialog is incremented in the combs() function */
	one_increment = 0.0;
	for(i = 1; i <= prob_n_terms; i++) {
		one_increment += nCr(num_mcs, i);
	}

	/* set up progress bar */
	one_increment /= 100.0;
    set_one_increment(one_increment);
	GenerateNumericalProbabilitySetProgressBarMax(100);


/*  ExprPrint(e);   */

 /* print header */
    fprintf(file,
        "Probabilities Analysis\n"
        "======================\n\n");
    fprintf(file, "Tree   : %s\n", tree->name);
    time(&tp);
    fprintf(file, "Time   : %s\n", ctime(&tp));

    fprintf(file, "Number of primary events   = %d\n",   num_bas);
    fprintf(file, "Number of minimal cut sets = %d\n",   num_mcs);
    fprintf(file, "Order of minimal cut sets  = %d\n",   tree->max_order);
    if (max_order < tree->max_order) {
        fprintf(file, "               (order <= %d used)\n\n", max_order);
    } else {
        fprintf(file, "\n");
    }

    fprintf(file, "Unit time span         = %f\n\n",   unit_time);

 /* calculate cut set probabilities - use ALL the cut sets */
    cp = ExprCutsetProbs(e, probs);

    fprintf(file, "Minimal cut set probabilities :\n\n");

    i = 0;
    for(g=e; !BitEquals(g->b, stop); g=g->next) {
        char **fp = BitPara( g->b, 30 );

/*         printf("(%3d) %s %-20s - %E\n", */
/*                i+1, */
/*                BitString(g->b), */
/*                fp[0], */
/*                cp[i]); */
/*  */
/*         for (j = 1; fp[j] != NULL; j++) { */
/*             printf("       %-20s\n", fp[j]); */
/*         } */

        if (GenerateNumericalProbabilityCheckForInterrupt()) {
            success = FALSE;
            CleanUpOperations(
                file,
                probs,
                cp,
                imp,
				stop);
			ParaDestroy(fp);
            return success;
		}

        fprintf(file,
               "%3d   %-30s   %E\n",
               i+1,
               fp[0],
               cp[i]);

        for (j = 1; fp[j] != NULL; j++) {
            fprintf(file,
                   "      %-20s\n", fp[j]);
        }

        ParaDestroy(fp);
        i++;
    }

 /* calculate top level probability  - use only up to max_order cut sets */
    fprintf(file, "\n\n"
                  "Probability of top level event "
                  "(minimal cut sets up to order %d used):\n\n", max_order);

    p = 0;

	

    for (i = 1; i <= prob_n_terms && i <= num_mcs && !GenerateNumericalProbabilityCheckForInterrupt(); i++) {
        float term;
        char *sign, *s, *bound;

        p += (term = ExprProb(e, probs, max_order, i));
        sign       = ((i % 2) ? "+" :  "-" );
        s          = ((i > 1) ? "s" :  " " );
        bound      = ((i % 2) ? "upper" :  "lower" );

        fprintf(file, "%2d term%s   %s%E   = %E (%s bound)\n",
                i, s, sign, fabs(term), p, bound);
    }

    if (prob_n_terms >= num_mcs) {
        fprintf(file, "\nExact value : %E\n", p);
    }

    if (GenerateNumericalProbabilityCheckForInterrupt()) {
        success = FALSE;
        CleanUpOperations(
            file,
            probs,
            cp,
            imp,
			stop);
        return success;
	}

 /* calculate importances of individual events */

    for (j = 0; j < num_bas; j++) {
        imp[j] = 0;
    }

    i = 0;
    for(g=e; !BitEquals(g->b, stop); g=g->next) {
        for (j = 0; j < g->b->n; j++) {
            if ( BitGet(g->b, (g->b->n-1) - j) ) {
               imp[j] += cp[i];
            }
        }
        i++;
    }

    if (GenerateNumericalProbabilityCheckForInterrupt()) {
        success = FALSE;
        CleanUpOperations(
            file,
            probs,
            cp,
            imp,
			stop);
        return success;
	}

    fprintf(file, "\n\nPrimary Event Analysis:\n\n");

    fprintf(file, " Event          "
                  "Failure contrib.    "
                  "Importance\n\n");

    for (i = 0; i < num_bas; i++) {
        char *fs = BasicString(num_bas, i);
        fprintf(file, "%-15s %E            %5.2f%%\n",
                fs, imp[i], 100 * imp[i] / p);
        strfree(fs);
    }

    time2 = clock();

/*     printf("calculate_probs : num_terms = %d : time = %f\n",   */
/*            prob_n_terms, (time2-time1)/(float)CLOCKS_PER_SEC);   */

    CleanUpOperations(
        file,
        probs,
        cp,
        imp,
		stop);
/*     fclose(file); */
/*     FreeMemory(probs); */
/*     free(cp); */
/*     FreeMemory(imp); */

    return ( TRUE );

} /* calculate_probs */
Beispiel #28
0
/* This function creates a new mailbox and a rule to accompany
 * that mailbox.
 */
void FASTCALL CreateSortMailFrom( HWND hwnd )
{
   LPWINDINFO lpWindInfo;

   lpWindInfo = GetBlock( hwndTopic );
   if( Amdb_GetTopicType( lpWindInfo->lpTopic ) != FTYPE_MAIL )
      return;

   if( Adm_Dialog( hInst, hwnd, MAKEINTRESOURCE(IDDLG_SORTMAILFROM), SortMailFrom, 0L ) )
      {
      MSGINFO msginfo;
      RULE rule;
      PTH pth;

      /* Get the current folder handle.
       */
      Amdb_GetMsgInfo( lpWindInfo->lpMessage, &msginfo );

      /* First create a new rule.
       */
      memset( &rule, 0, sizeof(RULE) );
      rule.wFlags = FILF_MOVE;
      rule.pData = lpWindInfo->lpTopic;
      rule.pMoveData = ptlDest;
      lstrcpy( rule.szFromText, szRuleAuthor );
      if( CreateRule( &rule ) == NULL )
         {
         fMessageBox( hwnd, 0, GS(IDS_STR1043), MB_OK|MB_ICONINFORMATION );
         return;
         }

      /* If we move existing messages, then loop and move 'em.
       */
      if( fMoveExisting )
         {
         PTH FAR * lppth;
         int count;
         HCURSOR hOldCursor;

         INITIALISE_PTR(lppth);

         /* Busy, busy, bee
          */
         hOldCursor = SetCursor( hWaitCursor );

         /* First pass - count the number of messages.
          */
         count = 0;
         for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) )
            {
            MSGINFO msginfo2;

            Amdb_GetMsgInfo( pth, &msginfo2 );
//          if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) )
            if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 )
               ++count;
            }

         /* Second pass, allocate a PTH array of count messages and collect
          * the pth handles to the array.
          */
         if( count > 0 )
         {
         if( fNewMemory( (PTH FAR *)&lppth, ( count + 1 ) * sizeof(PTH) ) )
            {
            int index;

            index = 0;
            for( pth = Amdb_GetFirstMsg( lpWindInfo->lpTopic, VM_VIEWCHRON ); pth; pth = Amdb_GetNextMsg( pth, VM_VIEWCHRON ) )
               {
               MSGINFO msginfo2;

               Amdb_GetMsgInfo( pth, &msginfo2 );
//          if( strcmp( msginfo2.szAuthor, szRuleAuthor ) == 0 || ( szRuleAuthor[ 0 ] == '@' && strstr( msginfo2.szAuthor, szRuleAuthor ) != NULL ) )
            if( AddressRuleMatch( szRuleAuthor, msginfo2.szAuthor ) != -1 )
                  {
                  ASSERT( index < count );
                  lppth[ index++ ] = pth;
                  }
               }
            ASSERT( index == count );
            lppth[ index++ ] = NULL;
            DoCopyLocalRange( hwndTopic, lppth, count, ptlDest, TRUE, FALSE );
            FreeMemory( (PTH FAR *)&lppth );
            }
         }
         SetCursor( hOldCursor );
         }
      }
}