예제 #1
0
int main()
{
    uint8_t buffer[Person_size];
    pb_istream_t stream;
    size_t count;
    
    /* Read the data into buffer */
    SET_BINARY_MODE(stdin);
    count = fread(buffer, 1, sizeof(buffer), stdin);
    
    if (!feof(stdin))
    {
    	printf("Message does not fit in buffer\n");
    	return 1;
    }
    
    /* Construct a pb_istream_t for reading from the buffer */
    stream = pb_istream_from_buffer(buffer, count);
    
    /* Decode and print out the stuff */
    if (!print_person(&stream))
    {
        printf("Parsing failed: %s\n", PB_GET_ERROR(&stream));
        return 1;
    } else {
        return 0;
    }
}
예제 #2
0
void  print_people( int ref )
{
	int reference ;					/* person selected for printing		*/
	char *alert_ptr, alert_str[200] ;
	short i, count = 0 ;
	Str_prt_params params ;
	
	while( !count )
	{
		if( !ref )
		{
			reference =  get_person_reference( NULL, TRUE ) ;
			if( !reference )  return ;		/* exit if nobody selected	*/

			count = entries ;	/* entries is number of people selected	*/
			if( count > 1 )
			{
				rsrc_gaddr( R_STRING, PRINT_MANY, &alert_ptr ) ;
				sprintf( alert_str, alert_ptr, count ) ;
				if( form_alert( 0, alert_str ) == 2 )  count = 0 ;
			}
		}
		else
		{
			matches[0] = ref ;	/* force selector list					*/
			count = 1 ;
		}	

		if( count )
		{
			if( open_printer( &params ) )
			{
				params.ref2 = 0 ;		/* Do not print second reference.	*/
				
				if( params.use_gdos )
					setup_font( &params, fontinfo ) ;

				if( params.chs_across < 40 )
				{
					rsrc_gaddr( R_STRING, GROSS_FONT, &alert_ptr ) ;
					rsrc_form_alert( 1, GROSS_FONT ) ;
				}
				else
				{
					busy( BUSY_MORE ) ;
			
					start_print_checking( &params ) ;

					i = 0 ;
					while(  printing_ok( &params ) && ( reference = matches[i++] ) )
						print_person( reference, &params ) ;

					close_printer( &params ) ;
					busy( BUSY_LESS ) ;
				}
			}
		}
	}
}
예제 #3
0
void print_address_book(const struct Address_book *address_book){
  int i;
  for(i = 0; i<address_book->size;i++){

    print_person(*(address_book->persons)+i);
 
  }
}
예제 #4
0
void
print_pilot(pilot *ptr)
{
   if (!EINA_MAGIC_CHECK(ptr, SUBTYPE_MAGIC)) {
      EINA_MAGIC_FAIL(ptr, SUBTYPE_MAGIC);
      return;
   }
   print_person(&ptr->base);
   printf("callsign: %s\n", ptr->callsign);
}
예제 #5
0
// Allocate and de-allocate a single struct.
void struct_example(void) {
  struct person* p;

  p = malloc(sizeof(*p));
  p->name = "Alice";
  p->age = 21;
  print_person(*p);

  free(p);
}
예제 #6
0
int main(void)
{
	struct person persona = {"Juan", "Tanamera", 23, 956123123};

	print_person(&persona);

	print_attr(&persona, PHONE);

	printf("\n");

	return 0;
}
예제 #7
0
int
main(int argc, char **argv)
{
   person *base;
   pilot *sub;

   eina_init();
   eina_magic_string_set(BASETYPE_MAGIC, "person");
   eina_magic_string_static_set(SUBTYPE_MAGIC, "pilot");

   base = person_new("Tyrol");
   sub = pilot_new("thrace", "starbuck");

   print_person(base);
   print_person((person *)sub);

   print_pilot(base); //BAD
   print_pilot(sub);

   eina_shutdown();
}
예제 #8
0
파일: good3.c 프로젝트: kaer0339/ioopm15
int main(int argc, char *argv[])
{
  if (argc < 7)
    {
      printf("Usage: ./%s first1 last1 age1 first2 last2 age2", argv[0]);
    }
  else
    {
      // Construct p1 from the command line arguments 
      struct person p1 = {
	.first_name = argv[1], // note, no strdup (cf. bad3.c)
	.last_name  = argv[2],
	.age        = atoi(argv[3])
      };

      struct person p2 = {
	.first_name = argv[4],
	.last_name  = argv[5],
	.age        = atoi(argv[6])
      };

      // Print the two singles
      print_person(&p1);
      print_person(&p2);

      // Next line just initialises the random function used in marry
      srand(p2.age);

      // Marry p1 and p2 
      marry(&p1, &p2);

      // Print the two spouses
      print_person(&p1);
      print_person(&p2);
    }

  return 0;
}
예제 #9
0
int main()
{
    pb_istream_t stream = {&callback, NULL, SIZE_MAX};
    stream.state = stdin;
    SET_BINARY_MODE(stdin);

    if (!print_person(&stream))
    {
        printf("Parsing failed: %s\n", PB_GET_ERROR(&stream));
        return 1;
    } else {
        return 0;
    }
}
예제 #10
0
파일: q10.c 프로젝트: chadhao/Programming1
int main(int argc, char* argv[])
{
	struct person p;
	p.first_name = malloc(sizeof(char) * (strlen("Kim")+1));
	p.first_name = "Kim";
	p.last_name = malloc(sizeof(char) * (strlen("Kardashian")+1));
	p.last_name = "Kardashian";
	p.spouse->first_name = malloc(sizeof(char) * (strlen("Kanye")+1));
	p.spouse->first_name = "Kanye";
	p.spouse->last_name = malloc(sizeof(char) * (strlen("West")+1));
	p.spouse->last_name = "West";
	print_person(p);
	return 0;
}
예제 #11
0
int find_chain(person **people,int n)
{
	int i,count;
	person **start,**subseq;
	subseq=calloc(n,sizeof(person *));

	qsort(people,n,sizeof(struct person),cmpht);
	print_person(people,n);

	count=1;
	start=people;
	for(i=0; i<n; i++){
		if(people[i]->height != people[i+1]->height){
			qsort(start,count,sizeof(struct person),cmpwt);
			count=1;
			start=&people[i+1];
		}
		else{
			count++;
		}
	}
	print_person(people,n);

	/*find the max increasing sub sequence*/
	count=0;
	subseq[0]=people[0];
	for(i=0; i<n; i++){
		if(people[i]->weight > subseq[count]->weight)
			subseq[++count]=people[i];
		else if(people[i]->weight > subseq[count-1]->weight)
			subseq[count]=people[i];
	}
	print_person(subseq,count);

	return count;
}
예제 #12
0
void get_data_from_keyboard()
{
	int i;
	printf("enter the n:\n");
	scanf("%d",&n);
	
	people=calloc(n,sizeof(person *));
	printf("enter the data set:\n");
	
	for(i=0; i<n; i++){
		people[i]=malloc(sizeof(struct person));
		scanf("%d %d",&(people[i]->height),&(people[i]->weight));
	}
	print_person(people,n);
}
예제 #13
0
/* This main function does a little testing
   Like all good CS Majors you should test
   your code here. There is no substitute for testing
   and you should be sure to test for all edge cases
   e.g., calling remove_front on an empty list.
*/
int main(void)
{
	/* Now to make use of all of this stuff */
	list* llist = create_list();

  /* What does an empty list contain?  Lets use our handy traversal function */
  printf("TEST CASE 1\nAn Empty list should print nothing here:\n");
  traverse(llist, print_person);
	printf("\n");

 	/* Lets add a person from front and then print */
 	push_front(llist, create_person("Andrew", 24));
 	printf("TEST CASE 2\nA List with one person should print that person:\n");
 	traverse(llist, print_person);
 	printf("\n");

  
  /* Lets remove two persons from front and then print */
  remove_front(llist, free_person); // remove a list with more than 1 elements
 	remove_front(llist, free_person); // remove a list with only 1 element
 	printf("TEST CASE 3\nAnother Empty list should print nothing here:\n");
 	traverse(llist, print_person);
 	printf("\n");

 	/* Lets add two people and then print */
 	push_front(llist, create_person("Nick", 22));
 	push_front(llist, create_person("Randal", 21));
 	printf("TEST CASE 4\nA List with two people should print those two people:\n");
 	traverse(llist, print_person);
 	printf("\n");

	/* Lets copy this list */
	list* llist2 = copy_list(llist, copy_person);
	printf("TEST CASE 5\nA copied list should print out the same two people:\n");
 	traverse(llist2, print_person);
 	printf("\n");

  /* Lets kill the list */
  empty_list(llist, free_person);
 	printf("TEST CASE 6\nAfter freeing all nodes the list should be empty:\n");
 	traverse(llist, print_person);
	printf("\n");

	/* Let's make a list of people, and remove certain ones! */
	/* Should remove anyone whose name is 8+ characters long */
	push_front(llist, create_person("Josephine", 27));
	push_front(llist, create_person("Dave", 34));
	push_front(llist, create_person("Benjamin", 23));
	push_front(llist, create_person("Lisa", 41));
	push_front(llist, create_person("Maximilian", 24));
	remove_if(llist, long_name, free_person);
	printf("TEST CASE 7\nShould only print 2 people with short names:\n");
	traverse(llist, print_person);
  printf("\n");
  
  /* Testing over clean up*/
  empty_list(llist, free_person);
  free(llist);
  empty_list(llist2, free_person);
  free(llist2);


  // MY TESTS!!!

  // Test case 8 -- create_list(); is_empty() and size() when the list is empty
  list* myList = create_list();
  printf("TEST CASE 8\nShould print 1 and then 0:\n");
  printf("%d\t", is_empty(myList));
  printf("%d\n", size(myList));
  printf("\n");

  // Test case 9 -- front() and back() when the list is empty
  printf("TEST CASE 9\nShould print nothing:\n");
  print_person(front(myList));
  print_person(back(myList));
  printf("\n");

  // Test case 10 -- push_front() and push_back() and traverse()
  push_front(myList, create_person("Dan", 24));
  push_back(myList, create_person("Sun", 24));
  push_front(myList, create_person("Someone", 100));
  push_back(myList, create_person("Somebody", 1));
  printf("TEST CASE 10\nShould print 4 people in the order of Someone-Dan-Sun-Somebody:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 11 -- size() and is_empty() when the list is not empty
  printf("TEST CASE 11\nShould return 0 and then 4:\n");
  printf("%d\t", is_empty(myList));
  printf("%d\n", size(myList));
  printf("\n");

  // Test case 12 -- front() and back() when the list is not empty
  printf("TEST CASE 12\nShould print Someone then Somebody:\n");
  print_person(front(myList));
  print_person(back(myList));
  printf("\n");

  // Test case 13 -- copy_list()
  list* myListCopy = copy_list(myList, copy_person);
  printf("TEST CASE 13\nA copied list should print 4 people in the order of Someone-Dan-Sun-Somebody:\n");
  traverse(myListCopy, print_person);
  printf("\n");

  // Test case 14 -- remove_front() and remove_back() when the list is not empty
  remove_front(myList, free_person);
  remove_back(myList, free_person);
  printf("TEST CASE 13\nShould print 2 people in the order of Dan-Sun:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 15 -- remove_if()
  push_front(myList, create_person("LLLLLLLLLLLLL", 1));
  push_front(myList, create_person("MMMMMMMMM", 1));
  push_front(myList, create_person("AAA", 3));
  push_back(myList, create_person("DDD", 5));
  push_back(myList, create_person("T", 10));
  push_back(myList, create_person("VVVVVVVVVV", 1));
  remove_if(myList, long_name, free_person);
  printf("TEST CASE 13\nShould print 5 people:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 16 -- empty_list()
  empty_list(myList, free_person);
  printf("TEST CASE 16\nShould print nothing:\n");
  traverse(myList, print_person);
  printf("\n");

  // Test case 17 -- remove_front() and remove_back() when the list is empty
  remove_front(myList, free_person);
  remove_back(myList, free_person);
  printf("TEST CASE 17\nNo error should occur: \n");
  printf("\n");

  // Test case 18 -- push big data into the copied list to test push_front() and copy_list()
  for (int i = 0; i < 1000000; i++) {
    push_front(myListCopy, create_person("BIG", 1));
  }
  printf("TEST CASE 18\nShould print 1000004 (add a large number of data): \n");
  printf("%d\n", size(myListCopy));
  printf("\n");

  empty_list(myList, free_person);
  free(myList);

  empty_list(myListCopy, free_person);
  free(myListCopy);

  return 0;
}
예제 #14
0
void print_car(const struct car *c)
{
	printf("COCHE %s: %s (%s), color %s, propiedad de:\n    ",
		c->plate, c->model, c->manufacturer, c->color);
	print_person(c->owner);
}
예제 #15
0
/*
** COMMAND: export
**
** Usage: %fossil export --git ?OPTIONS? ?REPOSITORY?
**
** Write an export of all check-ins to standard output.  The export is
** written in the git-fast-export file format assuming the --git option is
** provided.  The git-fast-export format is currently the only VCS 
** interchange format supported, though other formats may be added in
** the future.
**
** Run this command within a checkout.  Or use the -R or --repository
** option to specify a Fossil repository to be exported.
**
** Only check-ins are exported using --git.  Git does not support tickets 
** or wiki or events or attachments, so none of those are exported.
**
** If the "--import-marks FILE" option is used, it contains a list of
** rids to skip.
**
** If the "--export-marks FILE" option is used, the rid of all commits and
** blobs written on exit for use with "--import-marks" on the next run.
**
** Options:
**   --export-marks FILE          export rids of exported data to FILE
**   --import-marks FILE          read rids of data to ignore from FILE
**   --repository|-R REPOSITORY   export the given REPOSITORY
**   
** See also: import
*/
void export_cmd(void){
  Stmt q, q2, q3;
  int i;
  Bag blobs, vers;
  const char *markfile_in;
  const char *markfile_out;

  bag_init(&blobs);
  bag_init(&vers);

  find_option("git", 0, 0);   /* Ignore the --git option for now */
  markfile_in = find_option("import-marks", 0, 1);
  markfile_out = find_option("export-marks", 0, 1);

  db_find_and_open_repository(0, 2);
  verify_all_options();
  if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }

  db_multi_exec("CREATE TEMPORARY TABLE oldblob(rid INTEGER PRIMARY KEY)");
  db_multi_exec("CREATE TEMPORARY TABLE oldcommit(rid INTEGER PRIMARY KEY)");
  if( markfile_in!=0 ){
    Stmt qb,qc;
    char line[100];
    FILE *f;

    f = fossil_fopen(markfile_in, "r");
    if( f==0 ){
      fossil_fatal("cannot open %s for reading", markfile_in);
    }
    db_prepare(&qb, "INSERT OR IGNORE INTO oldblob VALUES (:rid)");
    db_prepare(&qc, "INSERT OR IGNORE INTO oldcommit VALUES (:rid)");
    while( fgets(line, sizeof(line), f)!=0 ){
      if( *line == 'b' ){
        db_bind_text(&qb, ":rid", line + 1);
        db_step(&qb);
        db_reset(&qb);
        bag_insert(&blobs, atoi(line + 1));
      }else if( *line == 'c' ){
        db_bind_text(&qc, ":rid", line + 1);
        db_step(&qc);
        db_reset(&qc);
        bag_insert(&vers, atoi(line + 1));
      }else{
        fossil_fatal("bad input from %s: %s", markfile_in, line);
      }
    }
    db_finalize(&qb);
    db_finalize(&qc);
    fclose(f);
  }

  /* Step 1:  Generate "blob" records for every artifact that is part
  ** of a check-in 
  */
  fossil_binary_mode(stdout);
  db_multi_exec("CREATE TEMP TABLE newblob(rid INTEGER KEY, srcid INTEGER)");
  db_multi_exec("CREATE INDEX newblob_src ON newblob(srcid)");
  db_multi_exec(
    "INSERT INTO newblob"
    " SELECT DISTINCT fid,"
    "  CASE WHEN EXISTS(SELECT 1 FROM delta"
                       " WHERE rid=fid"
                       "   AND NOT EXISTS(SELECT 1 FROM oldblob"
                                         " WHERE srcid=fid))"
    "   THEN (SELECT srcid FROM delta WHERE rid=fid)"
    "   ELSE 0"
    "  END"
    " FROM mlink"
    " WHERE fid>0 AND NOT EXISTS(SELECT 1 FROM oldblob WHERE rid=fid)");
  db_prepare(&q,
    "SELECT DISTINCT fid FROM mlink"
    " WHERE fid>0 AND NOT EXISTS(SELECT 1 FROM oldblob WHERE rid=fid)");
  db_prepare(&q2, "INSERT INTO oldblob VALUES (:rid)");
  db_prepare(&q3, "SELECT rid FROM newblob WHERE srcid= (:srcid)");
  while( db_step(&q)==SQLITE_ROW ){
    int rid = db_column_int(&q, 0);
    Blob content;

    while( !bag_find(&blobs, rid) ){
      content_get(rid, &content);
      db_bind_int(&q2, ":rid", rid);
      db_step(&q2);
      db_reset(&q2);
      printf("blob\nmark :%d\ndata %d\n", BLOBMARK(rid), blob_size(&content));
      bag_insert(&blobs, rid);
      fwrite(blob_buffer(&content), 1, blob_size(&content), stdout);
      printf("\n");
      blob_reset(&content);

      db_bind_int(&q3, ":srcid", rid);
      if( db_step(&q3) != SQLITE_ROW ){
        db_reset(&q3);
        break;
      }
      rid = db_column_int(&q3, 0);
      db_reset(&q3);
    }
  }
  db_finalize(&q);
  db_finalize(&q2);
  db_finalize(&q3);

  /* Output the commit records.
  */
  db_prepare(&q,
    "SELECT strftime('%%s',mtime), objid, coalesce(comment,ecomment),"
    "       coalesce(user,euser),"
    "       (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
    "  FROM event"
    " WHERE type='ci' AND NOT EXISTS (SELECT 1 FROM oldcommit WHERE objid=rid)"
    " ORDER BY mtime ASC",
    TAG_BRANCH
  );
  db_prepare(&q2, "INSERT INTO oldcommit VALUES (:rid)");
  while( db_step(&q)==SQLITE_ROW ){
    Stmt q4;
    const char *zSecondsSince1970 = db_column_text(&q, 0);
    int ckinId = db_column_int(&q, 1);
    const char *zComment = db_column_text(&q, 2);
    const char *zUser = db_column_text(&q, 3);
    const char *zBranch = db_column_text(&q, 4);
    char *zBr;

    bag_insert(&vers, ckinId);
    db_bind_int(&q2, ":rid", ckinId);
    db_step(&q2);
    db_reset(&q2);
    if( zBranch==0 ) zBranch = "trunk";
    zBr = mprintf("%s", zBranch);
    for(i=0; zBr[i]; i++){
      if( !fossil_isalnum(zBr[i]) ) zBr[i] = '_';
    }
    printf("commit refs/heads/%s\nmark :%d\n", zBr, COMMITMARK(ckinId));
    free(zBr);
    printf("committer");
    print_person(zUser);
    printf(" %s +0000\n", zSecondsSince1970);
    if( zComment==0 ) zComment = "null comment";
    printf("data %d\n%s\n", (int)strlen(zComment), zComment);
    db_prepare(&q3,
      "SELECT pid FROM plink"
      " WHERE cid=%d AND isprim"
      "   AND pid IN (SELECT objid FROM event)",
      ckinId
    );
    if( db_step(&q3) == SQLITE_ROW ){
      printf("from :%d\n", COMMITMARK(db_column_int(&q3, 0)));
      db_prepare(&q4,
        "SELECT pid FROM plink"
        " WHERE cid=%d AND NOT isprim"
        "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)"
        " ORDER BY pid",
        ckinId);
      while( db_step(&q4)==SQLITE_ROW ){
        printf("merge :%d\n", COMMITMARK(db_column_int(&q4,0)));
      }
      db_finalize(&q4);
    }else{
      printf("deleteall\n");
    }

    db_prepare(&q4,
      "SELECT filename.name, mlink.fid, mlink.mperm FROM mlink"
      " JOIN filename ON filename.fnid=mlink.fnid"
      " WHERE mlink.mid=%d",
      ckinId
    );
    while( db_step(&q4)==SQLITE_ROW ){
      const char *zName = db_column_text(&q4,0);
      int zNew = db_column_int(&q4,1);
      int mPerm = db_column_int(&q4,2);
      if( zNew==0)
        printf("D %s\n", zName);
      else if( bag_find(&blobs, zNew) ) {
        const char *zPerm;
        switch( mPerm ){
          case PERM_LNK:  zPerm = "120000";   break;
          case PERM_EXE:  zPerm = "100755";   break;
          default:        zPerm = "100644";   break;
        }
        printf("M %s :%d %s\n", zPerm, BLOBMARK(zNew), zName);
      }
    }
    db_finalize(&q4);
    db_finalize(&q3);
    printf("\n");
  }
  db_finalize(&q2);
  db_finalize(&q);
  bag_clear(&blobs);
  manifest_cache_clear();


  /* Output tags */
  db_prepare(&q,
     "SELECT tagname, rid, strftime('%%s',mtime)"
     "  FROM tagxref JOIN tag USING(tagid)"
     " WHERE tagtype=1 AND tagname GLOB 'sym-*'"
  );
  while( db_step(&q)==SQLITE_ROW ){
    const char *zTagname = db_column_text(&q, 0);
    char *zEncoded = 0;
    int rid = db_column_int(&q, 1);
    const char *zSecSince1970 = db_column_text(&q, 2);
    int i;
    if( rid==0 || !bag_find(&vers, rid) ) continue;
    zTagname += 4;
    zEncoded = mprintf("%s", zTagname);
    for(i=0; zEncoded[i]; i++){
      if( !fossil_isalnum(zEncoded[i]) ) zEncoded[i] = '_';
    }
    printf("tag %s\n", zEncoded);
    printf("from :%d\n", COMMITMARK(rid));
    printf("tagger <tagger> %s +0000\n", zSecSince1970);
    printf("data 0\n");
    fossil_free(zEncoded);
  }
  db_finalize(&q);
  bag_clear(&vers);

  if( markfile_out!=0 ){
    FILE *f;
    f = fossil_fopen(markfile_out, "w");
    if( f == 0 ){
      fossil_fatal("cannot open %s for writing", markfile_out);
    }
    db_prepare(&q, "SELECT rid FROM oldblob");
    while( db_step(&q)==SQLITE_ROW ){
      fprintf(f, "b%d\n", db_column_int(&q, 0));
    }
    db_finalize(&q);
    db_prepare(&q, "SELECT rid FROM oldcommit");
    while( db_step(&q)==SQLITE_ROW ){
      fprintf(f, "c%d\n", db_column_int(&q, 0));
    }
    db_finalize(&q);
    if( ferror(f)!=0 || fclose(f)!=0 ) {
      fossil_fatal("error while writing %s", markfile_out);
    }
  }
}
예제 #16
0
파일: person.c 프로젝트: enghqii/OS-5-mmap
int main (int    argc, char **argv)
{
    const char *file_name;
    const char *set_value;
    const char *attr_name;
    int         watch_mode;

    struct sigaction sigact;

    sigemptyset(&sigact.sa_mask);
    sigact.sa_flags     = SA_SIGINFO;
    sigact.sa_restorer  = NULL;
    sigact.sa_sigaction = sig_handler;

    sigaction(SIGUSR1, &sigact, 0);
    sigaction(SIGINT, &sigact, 0);
    sigaction(SIGTERM, &sigact, 0);

    /* Parse command line arguments. */
    file_name  = "./person.dat";
    set_value  = NULL;
    watch_mode = 0;

    while (1)
    {
        int opt;

        opt = getopt (argc, argv, "ws:f:");
        if (opt < 0)
            break;

        switch (opt)
        {
            case 'w':
                watch_mode = 1;
                break;
            case 's':
                set_value = optarg;
                break;
            case 'f':
                file_name = optarg;
                break;
            default:
                print_usage (argv[0]);
                return -1;
        }
    }
    if (!watch_mode && optind >= argc)
    {
        print_usage (argv[0]);
        return -1;
    }
    attr_name = argv[optind];

    /* ###################################################### */

    setup(file_name);

    if(watch_mode) // watch mode 
    {
        int i = 0;

        printf("waiting...\n");
        printf("my pid is %x\n", getpid());

        // add self on watchers list
        for(i = 0; i < NOTIFY_MAX * sizeof(pid_t); i += sizeof(pid_t))
        {
            pid_t* p_pid = (pid_t *)((char *)p_mmap + i);

            if( *p_pid == 0 )
            {
                *p_pid = getpid();
                break;
            }
        }

        if(i/sizeof(pid_t) == NOTIFY_MAX)
        {
            *((pid_t *)p_mmap) = getpid();
        }

        while(1){
            sleep(2);
        }
    }

    else // not watch_mode
    {
        int         off;
        char *      data;

        if( 0 > (off = person_get_offset_of_attr(attr_name)) )
        {
            fprintf(stderr, "invalid attr name \'%s\'\n", attr_name);
            return -1;
        }

        if(set_value != NULL) // set mode
        {
            printf("attr name is %s(%d)\n", attr_name, off);

            if( person_attr_is_integer(attr_name) )
            {
                int * addr = (int *)(((char *)p_mmap) + off);

                *addr = atoi(set_value);
                msync(addr, sizeof(int), MS_SYNC);
            }
            else
            {
                char* addr = ((char *)p_mmap) + off;
                int len = strlen(set_value) * sizeof(char) + 1;

                memcpy(addr, set_value, len);
                msync(addr, sizeof(Person), MS_SYNC);
            }
            send_signal(off);
        }

        else // print mode
        {
            if( person_attr_is_integer(attr_name) )
            {
                int * addr = (int *)(((char *)p_mmap) + off);
                printf("%d\n", *addr);
            }
            else
            {
                char* addr = ((char *)p_mmap) + off;
                printf("%s\n", addr);
            }
        }
        print_person(p_mmap);
    }

    cleanup();
    return 0;
}