void bookmarks_remove_from (Bookmarks *bookmarks, GList *here) { GList *link; g_return_if_fail (bookmarks != NULL); if (here == NULL) return; for (link = bookmarks->list; link && (link != here); link = bookmarks->list) { char *path = link->data; bookmarks->list = g_list_remove_link (bookmarks->list, link); if (get_link_from_path (bookmarks->list, path) == NULL) { my_remove (bookmarks->names, path); my_remove (bookmarks->tips, path); } g_free (link->data); g_list_free (link); } }
void test_multiple_creat() { int success0, success1, success2, success3, success4; success0 = my_creat("/test0.txt"); success1 = my_creat("/test1.txt"); success2 = my_creat("/test2.txt"); success3 = my_creat("/test3.txt"); success4 = my_creat("/test4.txt"); if (success0 = success1 * success2 * success3 * success4 < 0) { printf("\ntest_multiple_creat: FAILED\n"); } printf("\ntest_multiple_creat test0.txt at block %i\n", open_files[success0]); printf("test_multiple_creat test1.txt at block %i\n", open_files[success1]); printf("test_multiple_creat test2.txt at block %i\n", open_files[success2]); printf("test_multiple_creat test3.txt at block %i\n", open_files[success3]); printf("test_multiple_creat test4.txt at block %i\n", open_files[success4]); if ((my_remove("/test0.txt") > 0) || (my_remove("/test1.txt") > 0) || (my_remove("/test2.txt") > 0) || (my_remove("/test3.txt") > 0) || (my_remove("/test4.txt") > 0)) { printf("Failed at removing after multiple creates\n"); exit(1); } printf("test_multiple_creat removed all txt files\n"); printf("test_multiple_creat: PASSED\n"); }
void bookmarks_remove_all_instances (Bookmarks *bookmarks, const char *path) { GList *link; g_return_if_fail (bookmarks != NULL); g_return_if_fail (path != NULL); link = get_link_from_path (bookmarks->list, path); while (link != NULL) { bookmarks->list = g_list_remove_link (bookmarks->list, link); g_free (link->data); g_list_free (link); link = get_link_from_path (bookmarks->list, path); } my_remove (bookmarks->names, path); my_remove (bookmarks->tips, path); }
void bookmarks_remove (Bookmarks *bookmarks, const char *path) { GList *link; g_return_if_fail (bookmarks != NULL); g_return_if_fail (path != NULL); link = get_link_from_path (bookmarks->list, path); if (link == NULL) return; bookmarks->list = g_list_remove_link (bookmarks->list, link); g_free (link->data); g_list_free (link); if (get_link_from_path (bookmarks->list, path) == NULL) { my_remove (bookmarks->names, path); my_remove (bookmarks->tips, path); } }
int my_history(char *cmd, char **env, int action) { char *path; if (action == 0) return (my_put_hist(cmd, env)); path = get_history_path(NULL); if (path == NULL + 1) return (-1); if (!path) return (0); return (my_remove(env, path)); }
char *eval_paren(char *str, char *ops, char *base) { t_limits limite; int nb_paren; char *temp; limite.left = max_level_paren(str, ops); limite.right = limite.left + 1; while (str[limite.right] != ops[1] && str[limite.right]) limite.right = limite.right + 1; while (str_contain_operator(str, ops) == 0) { limite.left = max_level_paren(str, ops); limite.right = limite.left + 2; while (str[limite.right] != ops[1] && str[limite.right]) limite.right = limite.right +1; temp = my_remove(str, limite.left, limite.right, ops); str = my_replace(str, my_eval_expr(my_remove(str, limite.left, limite.right, ops), base, ops), limite, ops); } return (str); }
void my_abs(char **str, int sens, char *ops) { char *result; t_limits limite; int signe; result = *str; signe = 1; limite.left = limite.right = 0; while (result[limite.right] && (find_pos(ops, result[limite.right]) == 2 || find_pos(ops, result[limite.right]) == 3)) { if (find_pos(ops, result[limite.right]) == 3) signe *= -1; limite.right = limite.right + 1; } result = my_remove(result, limite.right, my_strlen(result), ops); if ((signe == -1 && sens == 0) || sens < 0) add_sign(&result, ops[3]); *str = result; }
static void test_hash_basic(void *p) { struct HashTab *htab; int i; htab = hashtab_create(cf_size, mycmp, USUAL_ALLOC); for (i = 0; i < cf_cnt; i++) { int n = i + cf_ofs; str_check(my_lookup(htab, n), "NEXIST"); str_check(my_insert(htab, n), "OK"); str_check(my_lookup(htab, n), "OK"); } for (i = 0; i < cf_cnt; i++) { int n = i + cf_ofs; str_check(my_lookup(htab, n), "OK"); str_check(my_remove(htab, n), "OK"); str_check(my_lookup(htab, n), "NEXIST"); } end: hashtab_destroy(htab); }
int main( int, char *[] ) { boost::system::error_code ec; // Library 1 tests: ec = my_mkdir( "/no-such-file-or-directory/will-not-succeed" ); std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); BOOST_TEST( ec.category() == boost::system::system_category() ); // Library 2 tests: ec = my_remove( "/no-such-file-or-directory" ); std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); BOOST_TEST( ec == boost::system::errc::no_such_file_or_directory ); BOOST_TEST( ec.category() == boost::system::generic_category() ); // Library 3 tests: ec = boost::lib3::boo_boo; std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); BOOST_TEST( ec == boost::lib3::boo_boo ); BOOST_TEST( ec.value() == boost::lib3::boo_boo ); BOOST_TEST( ec.category() == boost::lib3::lib3_error_category ); BOOST_TEST( ec == boost::system::errc::io_error ); boost::system::error_code ec3( boost::lib3::boo_boo+100, boost::lib3::lib3_error_category ); BOOST_TEST( ec3.category() == boost::lib3::lib3_error_category ); BOOST_TEST( ec3.default_error_condition().category() == boost::lib3::lib3_error_category ); // Library 4 tests: ec = lib4::boo_boo; std::cout << "ec.value() is " << ec.value() << '\n'; BOOST_TEST( ec ); BOOST_TEST( ec == lib4::boo_boo ); BOOST_TEST( ec.value() == lib4::boo_boo.value() ); BOOST_TEST( ec.category() == lib4::lib4_error_category ); BOOST_TEST( ec == boost::system::errc::io_error ); boost::system::error_code ec4( lib4::boo_boo.value()+100, lib4::lib4_error_category ); BOOST_TEST( ec4.default_error_condition().category() == lib4::lib4_error_category ); // Test 3 //test3::run(); return ::boost::report_errors(); }
// !!UNC void init_posix_emu(void) { if(!validate_stat_struct) { ErrorAlert( "Invalid struct my_stat -- edit posix_emu.h" ); QuitEmulator(); } #if DEBUG_EXTFS debug_extfs = PrefsFindInt16("debugextfs"); debug_extfs = DB_EXTFS_LOUD; if(debug_extfs != DB_EXTFS_NONE) { extfs_log_open( EXTFS_LOG_FILE_NAME ); } #endif // We cannot use ExtFS "RootPath" because of the virtual desktop. if(PrefsFindBool("enableextfs")) { PrefsReplaceString("extfs", ""); } else { PrefsRemoveItem("extfs"); D(bug("extfs disabled by user\n")); #if DEBUG_EXTFS extfs_log_close(); #endif return; } const char *extdrives = PrefsFindString("extdrives"); // Set up drive list. size_t outinx = 0; for( TCHAR letter = TEXT('A'); letter <= TEXT('Z'); letter++ ) { if(extdrives && !strchr(extdrives,letter)) continue; TCHAR rootdir[20]; _sntprintf( rootdir, lengthof(rootdir), TEXT("%c:\\"), letter ); use_streams[ letter - 'A' ] = false; switch(GetDriveType(rootdir)) { case DRIVE_FIXED: case DRIVE_REMOTE: case DRIVE_RAMDISK: // TODO: NTFS AFP? // fall case DRIVE_REMOVABLE: case DRIVE_CDROM: if(outinx < lengthof(host_drive_list)) { host_drive_list[outinx] = letter; outinx += 2; } } } // Set up virtual desktop root. // TODO: this should be customizable. GetModuleFileName( NULL, virtual_root, lengthof(virtual_root) ); TCHAR *p = _tcsrchr( virtual_root, TEXT('\\') ); if(p) { _tcscpy( ++p, desktop_name ); } else { // should never happen _sntprintf( virtual_root, lengthof(virtual_root), TEXT("C:\\%s"), desktop_name ); } CreateDirectory( virtual_root, 0 ); // Set up an icon looking like "My Computer" // Can be overwritten just like any other folder custom icon. if(my_access(custom_icon_name,0) != 0) { int fd = my_creat( custom_icon_name, 0 ); if(fd >= 0) { my_close(fd); fd = open_rfork( custom_icon_name, O_RDWR|O_CREAT ); if(fd >= 0) { my_write( fd, my_comp_icon, sizeof(my_comp_icon) ); my_close(fd); static uint8 host_finfo[SIZEOF_FInfo]; uint32 finfo = Host2MacAddr(host_finfo); get_finfo(custom_icon_name, finfo, 0, false); WriteMacInt16(finfo + fdFlags, kIsInvisible); set_finfo(custom_icon_name, finfo, 0, false); get_finfo(my_computer, finfo, 0, true); WriteMacInt16(finfo + fdFlags, ReadMacInt16(finfo + fdFlags) | kHasCustomIcon); set_finfo(my_computer, finfo, 0, true); } else { my_remove(custom_icon_name); } } } }
void test_my_remove() { printf("\ntest_my_remove:\n"); int fd, fd2, fd3, fd4, fd5, fd6, fd7; if ((fd = my_creat("/test.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd2 = my_creat("/test2.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd3 = my_creat("/test3.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd4 = my_creat("/test4.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd5 = my_creat("/test5.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd6 = my_creat("/test6.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } if ((fd7 = my_creat("/test7.txt")) < 0) { printf("Failed at creating file /test.txt\n"); exit(1); } int block_num, block_num_2, block_num_3, block_num_4, block_num_5, block_num_6, block_num_7; block_num = get_associated_block_num(fd); block_num_2 = get_associated_block_num(fd2); block_num_3 = get_associated_block_num(fd3); block_num_4 = get_associated_block_num(fd4); block_num_5 = get_associated_block_num(fd5); block_num_6 = get_associated_block_num(fd6); block_num_7 = get_associated_block_num(fd7); printf("Created file /test.txt at block %d\n", block_num); printf("Created file /test2.txt at block %d\n", block_num_2); printf("Created file /test3.txt at block %d\n", block_num_3); printf("Created file /test4.txt at block %d\n", block_num_4); printf("Created file /test5.txt at block %d\n", block_num_5); printf("Created file /test6.txt at block %d\n", block_num_6); printf("Created file /test7.txt at block %d\n", block_num_7); if (my_remove("/test.txt") < 0) { printf("Failed to remove file /test.txt\n"); exit(1); } if (my_remove("/test2.txt") < 0) { printf("Failed to remove file /test2.txt\n"); exit(1); } if (my_remove("/test3.txt") < 0) { printf("Failed to remove file /test3.txt\n"); exit(1); } if (my_remove("/test4.txt") < 0) { printf("Failed to remove file /test4.txt\n"); exit(1); } if (my_remove("/test5.txt") < 0) { printf("Failed to remove file /test5.txt\n"); exit(1); } if (my_remove("/test6.txt") < 0) { printf("Failed to remove file /test6.txt\n"); exit(1); } if (my_remove("/test7.txt") < 0) { printf("Failed to remove file /test7.txt\n"); exit(1); } block_num = get_associated_block_num(fd); block_num_2 = get_associated_block_num(fd2); block_num_3 = get_associated_block_num(fd3); block_num_4 = get_associated_block_num(fd4); block_num_5 = get_associated_block_num(fd5); block_num_6 = get_associated_block_num(fd6); block_num_7 = get_associated_block_num(fd7); if (block_num != 0 || block_num_2 != 0 || block_num_3 != 0 || block_num_4 != 0 || block_num_5 != 0 || block_num_6 != 0 || block_num_7 != 0) { printf("BLOCK 1: %d\nBLOCK 2: %d\nBLOCK 3: %d\nBLOCK 4: %d\nBLOCK 5: %d\nBLOCK 6: %d\nBLOCK 7: %d\n", block_num, block_num_2, block_num_3, block_num_4, block_num_5, block_num_6, block_num_7); exit(1); } printf("Successfully removed all files\n"); printf("test_my_remove: PASSED\n"); }
//just for a test int main() { GameNode g1; g1.Gamename=2; g1.GameIntroduction=13; g1.CompanyIntroduction=12; g1.PlayingHours=20; GameNode g2; g2.Gamename=3; g1.GameIntroduction=4; g1.CompanyIntroduction=2; g1.PlayingHours=20; GameNode g3; g3.Gamename=1; g3.GameIntroduction=23; g3.CompanyIntroduction=2; g3.PlayingHours=20; GameNode g4; GameNode g5; GameListNode *head = malloc(sizeof(GameListNode)); head->prev=NULL; head->gamenode=g1; GameListNode *node2 = malloc(sizeof(GameListNode)); head->next=node2; node2->prev=head; node2->gamenode=g2; node2->next=NULL; printf("%d\n",my_insert(&head,g3)); GameListNode *current=head; while(current!=NULL) { printf("%d\n",(current->gamenode).Gamename); current=current->next; } printf("%d\n",my_remove(&head,3)); current=head; while(current!=NULL) { printf("%d\n",(current->gamenode).Gamename); current=current->next; } GameListNode * gn = my_query(head,1); if (gn!=NULL) printf("query%d\n",(gn->gamenode).GameIntroduction); int *test; int i; test= sortByKeyWord(head,1); for (i=0;i<2;i++) printf("%d\n",test[i]); return 0; }