BSTreeNode* BSTree_Get(BSTree* tree, BSKey* key, BSTree_Compare* compare) { TBSTree* btree = (TBSTree*)tree; BSTreeNode* ret = NULL; if( (btree != NULL) && (key != NULL) && (compare != NULL) ) { ret = recursive_get(btree->root, key, compare); } return ret; }
static BSTreeNode* recursive_get(BSTreeNode* root, BSKey* key, BSTree_Compare* compare) { BSTreeNode* ret = NULL; if( root != NULL ) { int r = compare(key, root->key); if( r == 0 ) { ret = root; } else if( r < 0 ) { ret = recursive_get(root->left, key, compare); } else if( r > 0 ) { ret = recursive_get(root->right, key, compare); } } return ret; }
int com_get (char *arg) { unsigned long long amount_written; char newpath[255]; if ((server==NULL) || (vol==NULL)) { printf("You're not connected yet to a volume\n"); goto error; } if ((arg[0]=='-') && (arg[1]=='r') && (arg[2]==' ')) { arg+=3; while ((arg) && (isspace(arg[0]))) arg++; snprintf(newpath,255,"%s/%s",curdir,arg); return recursive_get(newpath); } else return com_get_file(arg,0, &amount_written); error: return -1; }