Example #1
0
void
OPENLDAP::Source::common_add (Book &book)
{
  book.trigger_saving.connect (sigc::mem_fun (this,
					      &OPENLDAP::Source::save));
  add_book (book);
}
Example #2
0
int admin()
{
	int choice;
	printf("What function do you want?\n(1)add book\n(2)remove book\n(3)add member\n(4)remove member\n(5)member list\n(6)book list\n(7)exit\n");
	scanf("%d",&choice);
	switch(choice)
	{
		case 1:
			add_book();
			break;
		case 2:
			remove_book();
			break;
		case 3:
			add_member();
			break;
		case 4:
			remove_member();
			break;
		case 5:
			member_list();
			break;
		case 6:
			book_list();
			break;
		case 7:
			exit(0);	
	}
	return 1;
}
Example #3
0
book *create_book (const char* title, int type, int id)
{
	book *b=(book*)calloc(1,sizeof(book));
	
	switch(type){
		case 2: 
			b->max_width=20;
			b->max_lines=15;
			type=2;
			break;
		case 1:	
		default:
			b->max_width=29;
			b->max_lines=20;
			type=1;
			break;
	}
	b->type=type;
	b->id=id;
	safe_snprintf(b->title, sizeof(b->title), "%s", title);
	
	add_book(b);
	
	return b;
}
Example #4
0
void Manage(int what)
{
	cout << "Would you like to:" << endl;
	cout << "1. Search existing objects" << endl;
	cout << "2. Add a new one" << endl;
	cout << "3. Go back" << endl;

	char ch;

	cin.clear();
	cin.ignore(numeric_limits<streamsize>::max(), '\n');

	ch = getchar();

	switch (ch)
	{
	case'1':
		switch (what)
		{
		case 1:
			bookSearch();
			break;
		case 2:
			clientSearch();
			break;
		case 3:
			catSearch();
			break;
		}
		break;
	case '2':
		switch (what)
		{
		case 1:
			add_book();
			break;
		case 2:
			add_client();
			break;
		case 3:
			add_cat();
			break;
		}
		break;
	case '3':
		break;
	default:
		cout << "Please provide a valid response." << endl;
		cin.clear();
		cin.ignore(numeric_limits<streamsize>::max(), '\n');
		Manage(what);
		break;
	}
system("pause");
}
Example #5
0
/* resize the db and add a book struct with user input
 * this lives here since it uses static db functions */
void user_add_book(void)
{
	Book* B;
	long id;
	int year;
	char title[257];
	char name[112];
	char pub[41];

	/* get user input */
	fprintf(stdout, "Title of the Book? ");
	clear_stream();

	if (! fgets(title, sizeof(title) - 1, stdin))
		/* checking for error */
		goto error;
	chomp(title);

	printf("Author? ");
	if (! fgets(name, sizeof(name) - 1, stdin))
		goto error;
	chomp(name);

	printf("ID (10 numbers)? ");
	if (scanf("%ld", &id) == 0)
		goto error;

	/* clearing stream in another way due to scanf */
	while(getchar() != '\n');

	printf("When was it published? ");
	if (scanf("%d", &year) == 0)
		goto error;
	while(getchar() != '\n');

	printf("Publisher company? ");
	if (! fgets(pub, sizeof(pub) - 1, stdin))
		goto error;
	chomp(pub);

	/* create and call function to add it */
	B = create_book(id, title, year, pub);
	split_create_authors(B, name);

	if (!add_book(B)) {
		printf("Book node added to database\n");
		return;
	}

error:
	printf("Book creation aborted\n");
	return;
}
Example #6
0
void addDocument::on_buttonBox_accepted()
{
    std::string title, autor, editor, resume, style, actor;
    int editorYear, pisteNumber;

    if(ui->le_title->text() == "")
    {
       QMessageBox::information(this, tr("Add cancel"), tr("You must write an title to addind a document !"), QMessageBox::Ok);
    }
    else
    {
        title = ui->le_title->text().toStdString();
        autor = ui->le_autor->text().toStdString();
        editor = ui->le_editor->text().toStdString();
        resume = ui->le_resume->toPlainText().toStdString();
        style = ui->le_style->text().toStdString();
        actor = ui->le_actor->text().toStdString();
        editorYear = ui->le_editorYear->text().toInt();
        pisteNumber = ui->le_pisteNumber->text().toInt();

        if(ui->cb_type->currentIndex() == 0) //add a book
        {
            Book* doc = new Book(title,autor,resume,editorYear, editor);
            add_book(doc);
            myLib->push_back(doc);
            QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok);
        }
        else if(ui->cb_type->currentIndex() == 1) //add a  CD
        {
            CD* doc = new CD(title,autor,style,pisteNumber);
            add_cd(doc);
            myLib->push_back(doc);
            QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok);
        }
        else if(ui->cb_type->currentIndex() == 2)//add a Movie
        {
            Movie* doc = new Movie(title,autor,resume,style,autor);
            add_movie(doc);
            myLib->push_back(doc);
            QMessageBox::information(this, tr("Add"), tr("Your document is add !"), QMessageBox::Ok);
        }
    }
}
Example #7
0
History::Source::Source (Ekiga::ServiceCore &_core): core(_core)
{
  book = gmref_ptr<Book>(new Book (core));

  add_book (book);
}
Example #8
0
History::Source::Source (Ekiga::ServiceCore &_core): core(_core)
{
  book = boost::shared_ptr<Book>(new Book (core));

  add_book (book);
}
Example #9
0
KAB::Source::Source (Ekiga::ContactCore &_core): core(_core)
{
  add_book (BookPtr(new KAB::Book (core)));
}
Example #10
0
//int* adduser(int booknum);
//int userexist ();
int main()
{
	struct library *library = alloc_library();
	if (!library){
		printf("Failed to allocate library");
		return -1;
	}
	char input[80];
	char input2[80];
	int exit = 0;
	int ret;
	int menu;
	//i=0,booknum=0;
	while (!exit){
		printf("CHOOSE AN OPTION\n");
		scanf("%d",&menu);
		switch (menu)
		{
			case 1:
			scanf("%s", input);
			ret = add_user(library, input);
			if (ret < 0){
				printf("Failed to allocate memory\n");
				exit = 1;
				break;
			}
			if (ret == 1){
				printf("ERROR\n");
				break;
			}
			printf("User added\n");
			break;
		case 2:
			scanf("%s", input);
			ret = add_book(library, input);
			if (ret < 0){
				printf("Failed to allocate memory\n");
				exit = 1;
				break;
			}
			if (ret == 1){
				printf("ERROR\n");
				break;
			}
			printf("Book added\n");
			break;
		case 3:
			scanf("%s", input);
			ret = remove_book(library, input);
			if (ret == 1){
				printf("error\n");
				break;
			}
			printf("removed\n");
			break;
		case 4:
			scanf("%s", input);
			scanf("%s", input2);
			ret = take_book(library, input, input2);
			switch (ret){
				case -1:
					printf("Failed to allocate memory\n");
					exit = 1;
					break;
				case 1:
				case 2:
					printf("ERROR\n");
					break;
				case 3:
					printf("IN USE\n");
					break;
				default:
					printf("SUCESS\n");
					break;

			}
			break;
		case 5:
			scanf("%s", input);
			scanf("%s", input2);
			ret = return_book(library, input, input2);
			switch (ret){
				case 1:
				case 2:
					printf("ERROR\n");
					break;
				case 3:
					printf("NOT IN YOUR USE\n");
					break;
				default:
					printf("SUCESS\n");
			}
			break;
		case 6:
			scanf("%s", input);
			ret = print_user_info(library, input);
			if (ret == 1){
				printf("ERROR\n");
			}
			break;
		case 7:
			exit = 1;
			printf("BYE\n");
			break;
		}
	}
	free_library(library);
	return 0;
}