~fuzzgun/emailgraph/trunk-1

« back to all changes in this revision

Viewing changes to emailgraph.c

  • Committer: Bob Mottram
  • Date: 2012-03-18 19:43:31 UTC
  • Revision ID: fuzzgun@gmail.com-20120318194331-1d7ewy8yv0if61q9
Email density plot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Email graphing
3
 
    Copyright (C) 2011 Bob Mottram
4
 
    fuzzgun@gmail.com
5
 
 
6
 
    This program is free software: you can redistribute it and/or modify
7
 
    it under the terms of the GNU General Public License as published by
8
 
    the Free Software Foundation, either version 3 of the License, or
9
 
    (at your option) any later version.
10
 
 
11
 
    This program is distributed in the hope that it will be useful,
12
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
    GNU General Public License for more details.
15
 
 
16
 
    You should have received a copy of the GNU General Public License
17
 
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
2
  Email graphing
 
3
  Copyright (C) 2012 Bob Mottram
 
4
  fuzzgun@gmail.com
 
5
 
 
6
  This program is free software: you can redistribute it and/or modify
 
7
  it under the terms of the GNU General Public License as published by
 
8
  the Free Software Foundation, either version 3 of the License, or
 
9
  (at your option) any later version.
 
10
 
 
11
  This program is distributed in the hope that it will be useful,
 
12
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
  GNU General Public License for more details.
 
15
 
 
16
  You should have received a copy of the GNU General Public License
 
17
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
20
#include "emailgraph.h"
59
59
  filename_list * corpus=NULL;
60
60
  merge_rule * rules=NULL;
61
61
  merge_rule * exclusions=NULL;
 
62
  char plot_dates[256];
62
63
  char plot_daily[256];
63
64
  char plot_weekly[256];
64
65
  char plot_monthly[256];
83
84
  int mnth;
84
85
  time_t current_time;
85
86
  int stdin_data_exists=0;
 
87
  FILE * fp_dates = 0;
 
88
  char * plot_dates_data = "temp_dates.txt";
86
89
 
87
 
  /* is tehre data to be read from stdin? */
 
90
  /* is there data to be read from stdin? */
88
91
  stdin_data_exists = stdin_has_data(1);
89
92
 
90
93
  /*  
91
 
  read_sentiment_file("sentiment.txt",1);
92
 
  read_sentiment_file("sentiment.txt",0);
93
 
  return 1;
 
94
      read_sentiment_file("sentiment.txt",1);
 
95
      read_sentiment_file("sentiment.txt",0);
 
96
      return 1;
94
97
  */
95
98
 
96
99
  if (contact_list==NULL) {
111
114
  mailbox_filename[0]='\0';
112
115
  mailbox_directory[0]='\0';
113
116
 
 
117
  plot_dates[0]='\0';
114
118
  plot_daily[0]='\0';
115
119
  plot_weekly[0]='\0';
116
120
  plot_monthly[0]='\0';
378
382
      i++;
379
383
      continue;
380
384
    }
 
385
    if (strcmp(argv[i],"--plotdensity")==0) {
 
386
      sprintf((char*)plot_dates,"%s",argv[i+1]);
 
387
      fp_dates = fopen(plot_dates_data,"w");
 
388
      i++;
 
389
      continue;
 
390
    }
381
391
    if (strcmp(argv[i],"--end")==0) {
382
392
      end_date = parse_date(argv[i+1]);
383
393
      i++;
479
489
      return 0;
480
490
    }
481
491
    process_emails(
482
 
                 (char*)mailbox_filename, contact_list, start_date, 
483
 
                 end_date, start_hour, end_hour,
484
 
                 (int*)month_histogram, (int*)year_histogram, 
485
 
                 (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment);
 
492
                   (char*)mailbox_filename, contact_list, start_date, 
 
493
                   end_date, start_hour, end_hour,
 
494
                   (int*)month_histogram, (int*)year_histogram, 
 
495
                   (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment,
 
496
                   fp_dates);
486
497
  }
487
498
  else {
488
499
    if (filenames!=NULL) {
489
500
      next_filename = (filename_list*)(filenames->next);
490
501
      while (next_filename!=NULL) {
491
502
        process_emails(
492
 
                     (char*)(next_filename->filename), contact_list, 
493
 
                     start_date, end_date, start_hour, end_hour,
494
 
                     (int*)month_histogram, (int*)year_histogram, 
495
 
                     (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment);
 
503
                       (char*)(next_filename->filename), contact_list, 
 
504
                       start_date, end_date, start_hour, end_hour,
 
505
                       (int*)month_histogram, (int*)year_histogram, 
 
506
                       (int*)day_histogram, (int*)week_histogram, keywords, gender,corpus,sentence_dump,sentiment,
 
507
                       fp_dates);
496
508
        next_filename = (filename_list*)(next_filename->next);
497
509
      }
498
510
    }
499
511
  }
500
512
 
 
513
  if (fp_dates!=NULL) fclose(fp_dates);
501
514
 
502
515
  free_filename_list(filenames);
503
516
 
575
588
      }
576
589
    }
577
590
 
 
591
    if (plot_dates[0]!='\0') {
 
592
      if (title_str[0]=='\0') {
 
593
        sprintf((char*)plot_title,"%s","Email Density Plot");
 
594
      }
 
595
      else {
 
596
        sprintf((char*)plot_title,"%s",title_str);
 
597
      }
 
598
      plot_email_dates(
 
599
                       (char*)plot_dates,
 
600
                       (char*)plot_title,NULL,
 
601
                       IMAGE_WIDTH,IMAGE_HEIGHT,
 
602
                       plot_dates_data);
 
603
    }
 
604
 
578
605
    if (plot_daily[0]!='\0') {
579
606
      if (title_str[0]=='\0') {
580
607
        if (sentiment==0) {