Пример #1
0
/**
 * \fn void deleteBdd(std::string bddName)
 * \brief Deletes a BDD
 *
 * \param[in] bddName The name of the bdd.
 */
void deleteBdd(std::string bddName){
  string path2bdd("bdd/" + bddName);
  
  // On récupère les données des activités préexistantes
  activitiesMap *am;
  int nbActivities = mapActivities(path2bdd,&am);
  int i = 0;
  while(i < nbActivities){
    deleteActivity(am[i].activity, bddName);
    i++;
  }
  delete []am;
  emptyFolder(path2bdd);
  rmdir(path2bdd.c_str());
}
Пример #2
0
int main(int argc, char**argv)
{
    int opt;
    int expectedPomodoros = 0;
    int action = 0;
    
    std::string activityTitle;
    /* 
    // no arguments given
    */
    if(argc == 1) 
    {
	fprintf(stderr, "This program needs arguments....\n\n");
	print_help();
	return 1;
    }

    while((opt = getopt(argc, argv, "hVp:a:lbBs:d:c:u:")) != -1) 
    {
	switch(opt) 
	{
	  case 'h':
	    print_help();
	    return 0;
	    break;
	  case 'V':
	    printf("%s %s\n\n", PACKAGE, VERSION); 
	    return 0;
	    break;
          case 'l':
            list_all_activities();
            return 0;
            break;
          case 'p':
            if(!optarg || strlen(optarg) < 1)
            {
                fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
                return 1;
            }
            else
            {
                expectedPomodoros = atoi(optarg);
            }
            break;
	  case 'a':
	    printf("Output: %s\n", optarg);
	    if(!optarg || strlen(optarg) < 1)
	    {
		fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
		return 1;
	    }
	    else
	    {
		action = ACTION_ADD;
                activityTitle = std::string(optarg);
	    }
	    break;
          case 's':
            if(!optarg || strlen(optarg) < 1)
            {
                fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
                return 1;
            }
            else
            {
                runActivity(std::string(optarg));
            }
            break;  
          case 'd':
            if(!optarg || strlen(optarg) < 1)
            {
                fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
                return 1;
            }
            else
            {
                deleteActivity(std::string(optarg));
                return 0;
            }
            break;    
          case 'c':
            if(!optarg || strlen(optarg) < 1)
            {
                fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
                return 1;
            }
            else
            {
                completeActivity(std::string(optarg), true);
                return 0;
            }
            break;
          case 'u':
            if(!optarg || strlen(optarg) < 1)
            {
                fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
                return 1;
            }
            else
            {
                completeActivity(std::string(optarg), false);
                return 0;
            }
            break; 
          case 'b':
            run_timer(BREAK);
            return 0;
            break;
          case 'B':
            run_timer(LONG_BREAK);
            return 0;
            break;
	  case ':':
	    //fprintf(stderr, "%s: Error - Option '%c' needs a value\n\n", PACKAGE, opt);
	    print_help();
	    return 1;
	    break;
	  case '?':
	    //fprintf(stderr, "%s: Error - No such option: '%c'\n\n", PACKAGE, optopt);
	    print_help();
	    return 1;
	}
    }
    
    switch(action)
    {
        case ACTION_ADD:
            add_activity(activityTitle, expectedPomodoros);
            break;
    }
    
    return 0;
}