home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM Aktief 1995 #3 / CDA3.iso / genealog / pafctool.zip / ALIVE.C next >
C/C++ Source or Header  |  1992-04-09  |  4KB  |  132 lines

  1. /*
  2.  * Copyright (C) 1992, Stephen A. Wood.  All rights reserved.
  3.  * 
  4.  * This file is part of PAF C-Tools.
  5.  * 
  6.  * These programs are free software; you can redistribute them and/or modify
  7.  * them under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  * 
  11.  * These programs are distributed in the hope that they 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, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  * The GNU General Public License can be found in the file LICENSE.
  20.  * 
  21.  * The author of PAF C-Tools is Stephen A. Wood.  He may be reached on internet
  22.  * at the address saw@cegaf.gov, or via mail at 328 Dominion Drive,
  23.  * Newport News, VA 23602.
  24.  * 
  25.  * ------------
  26.  * 
  27.  * This program finds all individuals that have no death date and were born
  28.  * after 1890.  If the birthday is given, then a line is printed with the
  29.  * persons birthday followed by their name.  After the name, the year of birth
  30.  * is put in parenthesis.  If the person is female, the marriage record is
  31.  * looked up.  If there is a husband found, his last name is used instead of
  32.  * the womans last name.  Her last name is placed in brackets after the
  33.  * husbands last name.  If the woman has several marriages in the database, the
  34.  * marriage pointed to by her individual record is the one used.  This may or
  35.  * may not be the latest marriage.
  36.  */
  37.  
  38. #include <stdio.h>
  39. #include <time.h>
  40.  
  41. #include "pafsubs.h"
  42.  
  43. void printrec(RECORD_PTR rin);
  44.  
  45. int sortflag = 0;
  46.  
  47. main(argc,argv)
  48. int argc;
  49. char *argv[];
  50. {
  51.   RECORD_PTR rin, rin_max;
  52.   PAF_FILE *indiv_file;
  53.  
  54.   if(argc > 1) sortflag = 1;
  55.   paf_open_name('r');
  56.   paf_open_indiv('r');
  57.   paf_open_marr('r');
  58.  
  59.   indiv_file = get_paf_filed(INDIV);
  60.   rin_max = indiv_file->nrec;
  61.  
  62.   for(rin=1;rin<=rin_max;rin++){
  63.     printrec(rin);
  64.   }
  65.   return(0);
  66. }
  67.  
  68. void printrec(RECORD_PTR rin)
  69. {
  70.   INDIV_REC indiv, husband;
  71.   NAME_REC namrec;
  72.   MARR_REC marriage;
  73.   int i;
  74.   RECORD_PTR j;
  75.   int year,month,day;
  76.   int used_married_name;
  77.  
  78.   get_indiv_rec(rin,&indiv);
  79.  
  80. /* Check out what the other fields mean here */
  81. /* Why do some live people have non-zero deathdate fields */
  82.   if((indiv.deathdate&0xFCFFFF) == 0 && indiv.birthdate != 0
  83.      && indiv.sex != 'D') {
  84.     year = (indiv.birthdate & 0xFF) << 4;
  85.     year += (indiv.birthdate >> 12) & 0xF;
  86.     month = ((indiv.birthdate & 0xF00) >> 7);
  87.     month += ((indiv.birthdate & 0x800000) >>23);
  88.     day = ((indiv.birthdate & 0x7C0000) >> 18);
  89.     if(year >= 1890 && month != 0 && day != 0){
  90.       if(indiv.sex == 'D') printf("Deleted: ");
  91.       if(sortflag != 0){
  92.     NAME_REC first,last;
  93.     get_name_rec(indiv.names[0],&last);
  94.     get_name_rec(indiv.names[1],&first);
  95.     printf("%-10s%-10s|",last.name,first.name);
  96.       }
  97.       printf("%i/%i",month,day);
  98.       for(i=1;i<4;i++){
  99.     if(indiv.names[i] != 0){
  100.       get_name_rec(indiv.names[i],&namrec);
  101.       printf(" %s",namrec.name);
  102.     }
  103.       }
  104.       used_married_name = 0;
  105.       if(indiv.sex == 'F' && indiv.ownmarriage != 0) {
  106.     get_marr_rec(indiv.ownmarriage,&marriage);
  107.     if(marriage.husband != 0) {
  108.       get_indiv_rec(marriage.husband,&husband);
  109.       if(husband.names[0] != 0){
  110.         get_name_rec(husband.names[0],&namrec);
  111.         printf(" %s",namrec.name);
  112.         used_married_name = 1;
  113.       }
  114.     }
  115.       }
  116.       if(indiv.names[0] != 0){
  117.     if(used_married_name) printf(" [");
  118.     else printf(" ");
  119.     get_name_rec(indiv.names[0],&namrec);
  120.     printf("%s",namrec.name);
  121.     if(used_married_name) printf("]");
  122.       }
  123.       if(indiv.names[4] != 0){
  124.     get_name_rec(indiv.names[4],&namrec);
  125.     printf(", %s",namrec.name);
  126.       }
  127.       printf(" (%i)\n",year);
  128.     }
  129.   }
  130.   return;
  131. }
  132.