** dav_get_resource_state: Returns the state of the resource ** r->filename: DAV_RESOURCE_NULL, DAV_RESOURCE_LOCK_NULL, ** or DAV_RESOURCE_EXIST. ** ** Returns DAV_RESOURCE_ERROR if an error occurs. */
| 684 | ** Returns DAV_RESOURCE_ERROR if an error occurs. |
| 685 | */ |
| 686 | DAV_DECLARE(int) dav_get_resource_state(request_rec *r, |
| 687 | const dav_resource *resource) |
| 688 | { |
| 689 | const dav_hooks_locks *hooks = DAV_GET_HOOKS_LOCKS(r); |
| 690 | |
| 691 | if (resource->exists) |
| 692 | return DAV_RESOURCE_EXISTS; |
| 693 | |
| 694 | if (hooks != NULL) { |
| 695 | dav_error *err; |
| 696 | dav_lockdb *lockdb; |
| 697 | int locks_present; |
| 698 | |
| 699 | /* |
| 700 | ** A locknull resource has the form: |
| 701 | ** |
| 702 | ** known-dir "/" locknull-file |
| 703 | ** |
| 704 | ** It would be nice to look into <resource> to verify this form, |
| 705 | ** but it does not have enough information for us. Instead, we |
| 706 | ** can look at the path_info. If the form does not match, then |
| 707 | ** there is no way we could have a locknull resource -- it must |
| 708 | ** be a plain, null resource. |
| 709 | ** |
| 710 | ** Apache sets r->filename to known-dir/unknown-file and r->path_info |
| 711 | ** to "" for the "proper" case. If anything is in path_info, then |
| 712 | ** it can't be a locknull resource. |
| 713 | ** |
| 714 | ** ### I bet this path_info hack doesn't work for repositories. |
| 715 | ** ### Need input from repository implementors! What kind of |
| 716 | ** ### restructure do we need? New provider APIs? |
| 717 | */ |
| 718 | if (r->path_info != NULL && *r->path_info != '\0') { |
| 719 | return DAV_RESOURCE_NULL; |
| 720 | } |
| 721 | |
| 722 | if ((err = (*hooks->open_lockdb)(r, 1, 1, &lockdb)) == NULL) { |
| 723 | /* note that we might see some expired locks... *shrug* */ |
| 724 | err = (*hooks->has_locks)(lockdb, resource, &locks_present); |
| 725 | (*hooks->close_lockdb)(lockdb); |
| 726 | } |
| 727 | |
| 728 | if (err != NULL) { |
| 729 | /* ### don't log an error. return err. add higher-level desc. */ |
| 730 | |
| 731 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00623) |
| 732 | "Failed to query lock-null status for %s", |
| 733 | r->filename); |
| 734 | |
| 735 | return DAV_RESOURCE_ERROR; |
| 736 | } |
| 737 | |
| 738 | if (locks_present) |
| 739 | return DAV_RESOURCE_LOCK_NULL; |
| 740 | } |
| 741 | |
| 742 | return DAV_RESOURCE_NULL; |
| 743 | } |
no outgoing calls
no test coverage detected