3 * ====================================================================
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
20 * ====================================================================
23 * @file svn_ra_svn_private.h
24 * @brief Functions used by the server - Internal routines
27 #ifndef SVN_RA_SVN_PRIVATE_H
28 #define SVN_RA_SVN_PRIVATE_H
30 #include "svn_ra_svn.h"
31 #include "svn_editor.h"
35 #endif /* __cplusplus */
39 * Set the shim callbacks to be used by @a conn to @a shim_callbacks.
42 svn_ra_svn__set_shim_callbacks(svn_ra_svn_conn_t *conn,
43 svn_delta_shim_callbacks_t *shim_callbacks);
46 * @defgroup ra_svn_deprecated ra_svn low-level functions
50 /** Write a number over the net.
52 * Writes will be buffered until the next read or flush.
55 svn_ra_svn__write_number(svn_ra_svn_conn_t *conn,
59 /** Write a string over the net.
61 * Writes will be buffered until the next read or flush.
64 svn_ra_svn__write_string(svn_ra_svn_conn_t *conn,
66 const svn_string_t *str);
68 /** Write a cstring over the net.
70 * Writes will be buffered until the next read or flush.
73 svn_ra_svn__write_cstring(svn_ra_svn_conn_t *conn,
77 /** Write a word over the net.
79 * Writes will be buffered until the next read or flush.
82 svn_ra_svn__write_word(svn_ra_svn_conn_t *conn,
86 /** Write a list of properties over the net. @a props is allowed to be NULL,
87 * in which case an empty list will be written out.
92 svn_ra_svn__write_proplist(svn_ra_svn_conn_t *conn,
96 /** Begin a list. Writes will be buffered until the next read or flush. */
98 svn_ra_svn__start_list(svn_ra_svn_conn_t *conn,
101 /** End a list. Writes will be buffered until the next read or flush. */
103 svn_ra_svn__end_list(svn_ra_svn_conn_t *conn,
106 /** Flush the write buffer.
108 * Normally this shouldn't be necessary, since the write buffer is flushed
109 * when a read is attempted.
112 svn_ra_svn__flush(svn_ra_svn_conn_t *conn,
115 /** Write a tuple, using a printf-like interface.
117 * The format string @a fmt may contain:
120 Spec Argument type Item type
121 ---- -------------------- ---------
122 n apr_uint64_t Number
123 r svn_revnum_t Number
124 s const svn_string_t * String
125 c const char * String
127 b svn_boolean_t Word ("true" or "false")
130 ? Remaining elements optional
131 ! (at beginning or end) Suppress opening or closing of tuple
134 * Inside the optional part of a tuple, 'r' values may be @c
135 * SVN_INVALID_REVNUM, 'n' values may be
136 * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', and 'w' values may be
137 * @c NULL; in these cases no data will be written. 'b' and '(' may
138 * not appear in the optional part of a tuple. Either all or none of
139 * the optional values should be valid.
141 * (If we ever have a need for an optional boolean value, we should
142 * invent a 'B' specifier which stores a boolean into an int, using -1
143 * for unspecified. Right now there is no need for such a thing.)
145 * Use the '!' format specifier to write partial tuples when you have
146 * to transmit an array or other unusual data. For example, to write
147 * a tuple containing a revision, an array of words, and a boolean:
149 SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "r(!", rev));
150 for (i = 0; i < n; i++)
151 SVN_ERR(svn_ra_svn_write_word(conn, pool, words[i]));
152 SVN_ERR(svn_ra_svn_write_tuple(conn, pool, "!)b", flag)); @endcode
155 svn_ra_svn__write_tuple(svn_ra_svn_conn_t *conn,
157 const char *fmt, ...);
159 /** Read an item from the network into @a *item. */
161 svn_ra_svn__read_item(svn_ra_svn_conn_t *conn,
163 svn_ra_svn_item_t **item);
165 /** Scan data on @a conn until we find something which looks like the
166 * beginning of an svn server greeting (an open paren followed by a
167 * whitespace character). This function is appropriate for beginning
168 * a client connection opened in tunnel mode, since people's dotfiles
169 * sometimes write output to stdout. It may only be called at the
170 * beginning of a client connection.
173 svn_ra_svn__skip_leading_garbage(svn_ra_svn_conn_t *conn,
176 /** Parse an array of @c svn_sort__item_t structures as a tuple, using a
177 * printf-like interface. The format string @a fmt may contain:
180 Spec Argument type Item type
181 ---- -------------------- ---------
182 n apr_uint64_t * Number
183 r svn_revnum_t * Number
184 s svn_string_t ** String
185 c const char ** String
187 b svn_boolean_t * Word ("true" or "false")
188 B apr_uint64_t * Word ("true" or "false")
189 l apr_array_header_t ** List
192 ? Tuple is allowed to end here
195 * Note that a tuple is only allowed to end precisely at a '?', or at
196 * the end of the specification. So if @a fmt is "c?cc" and @a list
197 * contains two elements, an error will result.
199 * 'B' is similar to 'b', but may be used in the optional tuple specification.
200 * It returns TRUE, FALSE, or SVN_RA_SVN_UNSPECIFIED_NUMBER.
202 * If an optional part of a tuple contains no data, 'r' values will be
203 * set to @c SVN_INVALID_REVNUM, 'n' and 'B' values will be set to
204 * SVN_RA_SVN_UNSPECIFIED_NUMBER, and 's', 'c', 'w', and 'l' values
205 * will be set to @c NULL. 'b' may not appear inside an optional
206 * tuple specification; use 'B' instead.
209 svn_ra_svn__parse_tuple(const apr_array_header_t *list,
211 const char *fmt, ...);
213 /** Read a tuple from the network and parse it as a tuple, using the
214 * format string notation from svn_ra_svn_parse_tuple().
217 svn_ra_svn__read_tuple(svn_ra_svn_conn_t *conn,
219 const char *fmt, ...);
221 /** Parse an array of @c svn_ra_svn_item_t structures as a list of
222 * properties, storing the properties in a hash table.
227 svn_ra_svn__parse_proplist(const apr_array_header_t *list,
231 /** Read a command response from the network and parse it as a tuple, using
232 * the format string notation from svn_ra_svn_parse_tuple().
235 svn_ra_svn__read_cmd_response(svn_ra_svn_conn_t *conn,
237 const char *fmt, ...);
239 /** Accept commands over the network and handle them according to @a
240 * commands. Command handlers will be passed @a conn, a subpool of @a
241 * pool (cleared after each command is handled), the parameters of the
242 * command, and @a baton. Commands will be accepted until a
243 * terminating command is received (a command with "terminate" set in
244 * the command table). If a command handler returns an error wrapped
245 * in SVN_RA_SVN_CMD_ERR (see the @c SVN_CMD_ERR macro), the error
246 * will be reported to the other side of the connection and the
247 * command loop will continue; any other kind of error (typically a
248 * network or protocol error) is passed through to the caller.
254 svn_ra_svn__handle_commands2(svn_ra_svn_conn_t *conn,
256 const svn_ra_svn_cmd_entry_t *commands,
258 svn_boolean_t error_on_disconnect);
260 /** Write a successful command response over the network, using the
261 * same format string notation as svn_ra_svn_write_tuple(). Do not use
262 * partial tuples with this function; if you need to use partial
263 * tuples, just write out the "success" and argument tuple by hand.
266 svn_ra_svn__write_cmd_response(svn_ra_svn_conn_t *conn,
268 const char *fmt, ...);
270 /** Write an unsuccessful command response over the network. */
272 svn_ra_svn__write_cmd_failure(svn_ra_svn_conn_t *conn,
281 * @defgroup svn_commands sending ra_svn commands
285 /** Sets the target revision of connection @a conn to @a rev. Use @a pool
289 svn_ra_svn__write_cmd_target_rev(svn_ra_svn_conn_t *conn,
293 /** Send a "open-root" command over connection @a conn. Open the
294 * repository root at revision @a rev and associate it with @a token.
295 * Use @a pool for allocations.
298 svn_ra_svn__write_cmd_open_root(svn_ra_svn_conn_t *conn,
303 /** Send a "delete-entry" command over connection @a conn. Delete the
304 * @a path at optional revision @a rev below @a parent_token.
305 * Use @a pool for allocations.
308 svn_ra_svn__write_cmd_delete_entry(svn_ra_svn_conn_t *conn,
312 const char *parent_token);
314 /** Send a "add-dir" command over connection @a conn. Add a new directory
315 * node named @a path under the directory identified by @a parent_token.
316 * Associate the new directory with the given @a token. * @a copy_path
317 * and @a copy_rev are optional and describe the copy source.
318 * Use @a pool for allocations.
321 svn_ra_svn__write_cmd_add_dir(svn_ra_svn_conn_t *conn,
324 const char *parent_token,
326 const char *copy_path,
327 svn_revnum_t copy_rev);
329 /** Send a "open-dir" command over connection @a conn. Associate to
330 * @a token the directory node named @a path under the directory
331 * identified by @a parent_token in revision @a rev.
332 * Use @a pool for allocations.
335 svn_ra_svn__write_cmd_open_dir(svn_ra_svn_conn_t *conn,
338 const char *parent_token,
342 /** Send a "change-dir-prop" command over connection @a conn. Set the
343 * property @a name to the optional @a value on the directory identified
344 * to @a token. Use @a pool for allocations.
347 svn_ra_svn__write_cmd_change_dir_prop(svn_ra_svn_conn_t *conn,
351 const svn_string_t *value);
353 /** Send a "close-dir" command over connection @a conn. Identify the node
354 * to close with @a token. The latter will then no longer be associated
355 * with that node. Use @a pool for allocations.
358 svn_ra_svn__write_cmd_close_dir(svn_ra_svn_conn_t *conn,
362 /** Send a "absent-dir" command over connection @a conn. Directory node
363 * named @a path under the directory identified by @a parent_token is
364 * absent. Use @a pool for allocations.
367 svn_ra_svn__write_cmd_absent_dir(svn_ra_svn_conn_t *conn,
370 const char *parent_token);
372 /** Send a "add-file" command over connection @a conn. Add a new file
373 * node named @a path under the directory identified by @a parent_token.
374 * Associate the new file with the given @a token. * @a copy_path and
375 * @a copy_rev are optional and describe the copy source.
376 * Use @a pool for allocations.
379 svn_ra_svn__write_cmd_add_file(svn_ra_svn_conn_t *conn,
382 const char *parent_token,
384 const char *copy_path,
385 svn_revnum_t copy_rev);
387 /** Send a "open-file" command over connection @a conn. Associate to
388 * @a token the file node named @a path under the directory identified by
389 * @a parent_token in revision @a rev.
390 * Use @a pool for allocations.
393 svn_ra_svn__write_cmd_open_file(svn_ra_svn_conn_t *conn,
396 const char *parent_token,
400 /** Send a "change-file-prop" command over connection @a conn. Set the
401 * property @a name to the optional @a value on the file identified to
402 * @a token. Use @a pool for allocations.
405 svn_ra_svn__write_cmd_change_file_prop(svn_ra_svn_conn_t *conn,
409 const svn_string_t *value);
411 /** Send a "close-dir" command over connection @a conn. Identify the node
412 * to close with @a token and provide an optional @a check_sum. The token
413 * will then no longer be associated with that node.
414 * Use @a pool for allocations.
417 svn_ra_svn__write_cmd_close_file(svn_ra_svn_conn_t *conn,
420 const char *text_checksum);
422 /** Send a "absent-file" command over connection @a conn. File node
423 * named @a path in the directory identified by @a parent_token is
424 * absent. Use @a pool for allocations.
427 svn_ra_svn__write_cmd_absent_file(svn_ra_svn_conn_t *conn,
430 const char *parent_token);
432 /** Send a "apply-textdelta" command over connection @a conn. Starts a
433 * series of text deltas to be applied to the file identified by @a token.
434 * Optionally, specify the file's current checksum in @a base_checksum.
435 * Use @a pool for allocations.
438 svn_ra_svn__write_cmd_apply_textdelta(svn_ra_svn_conn_t *conn,
441 const char *base_checksum);
443 /** Send a "textdelta-chunk" command over connection @a conn. Apply
444 * textdelta @a chunk to the file identified by @a token.
445 * Use @a pool for allocations.
448 svn_ra_svn__write_cmd_textdelta_chunk(svn_ra_svn_conn_t *conn,
451 const svn_string_t *chunk);
453 /** Send a "textdelta-end" command over connection @a conn. Ends the
454 * series of text deltas to be applied to the file identified by @a token.
455 * Use @a pool for allocations.
458 svn_ra_svn__write_cmd_textdelta_end(svn_ra_svn_conn_t *conn,
462 /** Send a "close-edit" command over connection @a conn. Ends the editor
463 * drive (successfully). Use @a pool for allocations.
466 svn_ra_svn__write_cmd_close_edit(svn_ra_svn_conn_t *conn,
469 /** Send a "abort-edit" command over connection @a conn. Prematurely ends
470 * the editor drive, e.g. due to some problem on the other side.
471 * Use @a pool for allocations.
474 svn_ra_svn__write_cmd_abort_edit(svn_ra_svn_conn_t *conn,
477 /** Send a "set-path" command over connection @a conn.
478 * Use @a pool for allocations.
480 * @see set_path() in #svn_ra_reporter3_t for a description.
483 svn_ra_svn__write_cmd_set_path(svn_ra_svn_conn_t *conn,
487 svn_boolean_t start_empty,
488 const char *lock_token,
491 /** Send a "delete-path" command over connection @a conn.
492 * Use @a pool for allocations.
494 * @see delete_path() in #svn_ra_reporter3_t for a description.
497 svn_ra_svn__write_cmd_delete_path(svn_ra_svn_conn_t *conn,
501 /** Send a "link-path" command over connection @a conn.
502 * Use @a pool for allocations.
504 * @see link_path() in #svn_ra_reporter3_t for a description.
507 svn_ra_svn__write_cmd_link_path(svn_ra_svn_conn_t *conn,
512 svn_boolean_t start_empty,
513 const char *lock_token,
516 /** Send a "finish-report" command over connection @a conn.
517 * Use @a pool for allocations.
519 * @see finish_report() in #svn_ra_reporter3_t for a description.
522 svn_ra_svn__write_cmd_finish_report(svn_ra_svn_conn_t *conn,
525 /** Send a "abort-report" command over connection @a conn.
526 * Use @a pool for allocations.
528 * @see abort_report() in #svn_ra_reporter3_t for a description.
531 svn_ra_svn__write_cmd_abort_report(svn_ra_svn_conn_t *conn,
534 /** Send a "reparent" command over connection @a conn.
535 * Use @a pool for allocations.
537 * @see #svn_ra_reparent for a description.
540 svn_ra_svn__write_cmd_reparent(svn_ra_svn_conn_t *conn,
544 /** Send a "get-latest-rev" command over connection @a conn.
545 * Use @a pool for allocations.
547 * @see #svn_ra_get_latest_revnum for a description.
550 svn_ra_svn__write_cmd_get_latest_rev(svn_ra_svn_conn_t *conn,
553 /** Send a "get-dated-rev" command over connection @a conn.
554 * Use @a pool for allocations.
556 * @see #svn_ra_get_dated_revision for a description.
559 svn_ra_svn__write_cmd_get_dated_rev(svn_ra_svn_conn_t *conn,
563 /** Send a "change-rev-prop2" command over connection @a conn.
564 * Use @a pool for allocations.
566 * @see #svn_ra_change_rev_prop2 for a description.
569 svn_ra_svn__write_cmd_change_rev_prop2(svn_ra_svn_conn_t *conn,
573 const svn_string_t *value,
574 svn_boolean_t dont_care,
575 const svn_string_t *old_value);
577 /** Send a "change-rev-prop" command over connection @a conn.
578 * Use @a pool for allocations.
580 * @see #svn_ra_change_rev_prop for a description.
583 svn_ra_svn__write_cmd_change_rev_prop(svn_ra_svn_conn_t *conn,
587 const svn_string_t *value);
589 /** Send a "rev-proplist" command over connection @a conn.
590 * Use @a pool for allocations.
592 * @see #svn_ra_rev_proplist for a description.
595 svn_ra_svn__write_cmd_rev_proplist(svn_ra_svn_conn_t *conn,
599 /** Send a "rev-prop" command over connection @a conn.
600 * Use @a pool for allocations.
602 * @see #svn_ra_rev_prop for a description.
605 svn_ra_svn__write_cmd_rev_prop(svn_ra_svn_conn_t *conn,
610 /** Send a "get-file" command over connection @a conn.
611 * Use @a pool for allocations.
613 * @see #svn_ra_get_file for a description.
616 svn_ra_svn__write_cmd_get_file(svn_ra_svn_conn_t *conn,
621 svn_boolean_t stream);
623 /** Send a "update" command over connection @a conn.
624 * Use @a pool for allocations.
626 * @see #svn_ra_do_update3 for a description.
629 svn_ra_svn__write_cmd_update(svn_ra_svn_conn_t *conn,
633 svn_boolean_t recurse,
635 svn_boolean_t send_copyfrom_args,
636 svn_boolean_t ignore_ancestry);
638 /** Send a "switch" command over connection @a conn.
639 * Use @a pool for allocations.
641 * @see #svn_ra_do_switch3 for a description.
644 svn_ra_svn__write_cmd_switch(svn_ra_svn_conn_t *conn,
648 svn_boolean_t recurse,
649 const char *switch_url,
651 svn_boolean_t send_copyfrom_args,
652 svn_boolean_t ignore_ancestry);
654 /** Send a "status" command over connection @a conn.
655 * Use @a pool for allocations.
657 * @see #svn_ra_do_status2 for a description.
660 svn_ra_svn__write_cmd_status(svn_ra_svn_conn_t *conn,
663 svn_boolean_t recurse,
667 /** Send a "diff" command over connection @a conn.
668 * Use @a pool for allocations.
670 * @see #svn_ra_do_diff3 for a description.
673 svn_ra_svn__write_cmd_diff(svn_ra_svn_conn_t *conn,
677 svn_boolean_t recurse,
678 svn_boolean_t ignore_ancestry,
679 const char *versus_url,
680 svn_boolean_t text_deltas,
683 /** Send a "check-path" command over connection @a conn.
684 * Use @a pool for allocations.
686 * @see #svn_ra_check_path for a description.
689 svn_ra_svn__write_cmd_check_path(svn_ra_svn_conn_t *conn,
694 /** Send a "stat" command over connection @a conn.
695 * Use @a pool for allocations.
697 * @see #svn_ra_stat for a description.
700 svn_ra_svn__write_cmd_stat(svn_ra_svn_conn_t *conn,
705 /** Send a "get-file-revs" command over connection @a conn.
706 * Use @a pool for allocations.
708 * @see #svn_ra_get_file_revs2 for a description.
711 svn_ra_svn__write_cmd_get_file_revs(svn_ra_svn_conn_t *conn,
716 svn_boolean_t include_merged_revisions);
718 /** Send a "lock" command over connection @a conn.
719 * Use @a pool for allocations.
721 * @see #svn_ra_lock for a description.
724 svn_ra_svn__write_cmd_lock(svn_ra_svn_conn_t *conn,
728 svn_boolean_t steal_lock,
729 svn_revnum_t revnum);
731 /** Send a "unlock" command over connection @a conn.
732 * Use @a pool for allocations.
734 * @see #svn_ra_unlock for a description.
737 svn_ra_svn__write_cmd_unlock(svn_ra_svn_conn_t *conn,
741 svn_boolean_t break_lock);
743 /** Send a "get-lock" command over connection @a conn.
744 * Use @a pool for allocations.
746 * @see #svn_ra_get_lock for a description.
749 svn_ra_svn__write_cmd_get_lock(svn_ra_svn_conn_t *conn,
753 /** Send a "get-locks" command over connection @a conn.
754 * Use @a pool for allocations.
756 * @see #svn_ra_get_locks2 for a description.
759 svn_ra_svn__write_cmd_get_locks(svn_ra_svn_conn_t *conn,
764 /** Send a "replay" command over connection @a conn.
765 * Use @a pool for allocations.
767 * @see #svn_ra_replay for a description.
770 svn_ra_svn__write_cmd_replay(svn_ra_svn_conn_t *conn,
773 svn_revnum_t low_water_mark,
774 svn_boolean_t send_deltas);
776 /** Send a "replay-range" command over connection @a conn.
777 * Use @a pool for allocations.
779 * @see #svn_ra_replay_range for a description.
782 svn_ra_svn__write_cmd_replay_range(svn_ra_svn_conn_t *conn,
784 svn_revnum_t start_revision,
785 svn_revnum_t end_revision,
786 svn_revnum_t low_water_mark,
787 svn_boolean_t send_deltas);
789 /** Send a "get-deleted-rev" command over connection @a conn.
790 * Use @a pool for allocations.
792 * @see #svn_ra_get_deleted_rev for a description.
795 svn_ra_svn__write_cmd_get_deleted_rev(svn_ra_svn_conn_t *conn,
798 svn_revnum_t peg_revision,
799 svn_revnum_t end_revision);
801 /** Send a "get-iprops" command over connection @a conn.
802 * Use @a pool for allocations.
804 * @see #svn_ra_get_inherited_props for a description.
807 svn_ra_svn__write_cmd_get_iprops(svn_ra_svn_conn_t *conn,
810 svn_revnum_t revision);
812 /** Send a "finish-replay" command over connection @a conn.
813 * Use @a pool for allocations.
816 svn_ra_svn__write_cmd_finish_replay(svn_ra_svn_conn_t *conn,
824 #endif /* __cplusplus */
826 #endif /* SVN_RA_SVN_PRIVATE_H */