1.1 --- a/librazor/razor-internal.h Thu Nov 10 10:35:21 2011 +0000
1.2 +++ b/librazor/razor-internal.h Thu Feb 09 20:42:08 2012 +0000
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Copyright (C) 2008 Kristian Høgsberg <krh@redhat.com>
1.6 * Copyright (C) 2008 Red Hat, Inc
1.7 - * Copyright (C) 2009, 2011 J. Ali Harlow <ali@juiblex.co.uk>
1.8 + * Copyright (C) 2009, 2011-2012 J. Ali Harlow <ali@juiblex.co.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or modify
1.11 * it under the terms of the GNU General Public License as published by
1.12 @@ -21,6 +21,9 @@
1.13 #ifndef _RAZOR_INTERNAL_H_
1.14 #define _RAZOR_INTERNAL_H_
1.15
1.16 +#ifdef MSWIN_API
1.17 +#include <windows.h>
1.18 +#endif
1.19 #include <stdlib.h>
1.20 #include <stdint.h>
1.21 #include <stdarg.h>
1.22 @@ -234,4 +237,109 @@
1.23 void environment_unset(struct environment *env);
1.24 void environment_release(struct environment *env);
1.25
1.26 +#ifdef MSWIN_API
1.27 +char *razor_utf16_to_utf8(const wchar_t *utf16, int len);
1.28 +wchar_t *razor_utf8_to_utf16(const char *utf8, int len);
1.29 +#endif
1.30 +
1.31 +/* Atomic functions */
1.32 +
1.33 +#if HAVE_WINDOWS_KTM
1.34 +struct razor_atomic {
1.35 + HANDLE transaction;
1.36 + int n_files;
1.37 + struct razor_atomic_file {
1.38 + wchar_t *path;
1.39 + HANDLE h;
1.40 + } *files;
1.41 + int in_undo;
1.42 + char *error_path;
1.43 + char *error_str;
1.44 + char *error_msg;
1.45 +};
1.46 +#elif ENABLE_ATOMIC
1.47 +struct atomic_action {
1.48 + struct atomic_action *next;
1.49 + enum atomic_action_type {
1.50 + /* Complex actions */
1.51 + ACTION_MAKE_DIRS,
1.52 + ACTION_REMOVE,
1.53 + /* Primitive actions */
1.54 + ACTION_CREATE_DIR,
1.55 +#if HAVE_SYMLINK
1.56 + ACTION_CREATE_SYMLINK,
1.57 +#endif
1.58 + ACTION_MOVE,
1.59 + } type;
1.60 + struct {
1.61 + char *path;
1.62 + union atomic_action_args {
1.63 + struct {
1.64 + char *root;
1.65 + } make_dirs;
1.66 + struct {
1.67 + mode_t mode;
1.68 + } create_dir;
1.69 +#if HAVE_SYMLINK
1.70 + struct {
1.71 + char *target;
1.72 + } create_symlink;
1.73 +#endif
1.74 + struct {
1.75 + char *dest;
1.76 + } move;
1.77 + } u;
1.78 + } args;
1.79 +};
1.80 +
1.81 +struct razor_atomic {
1.82 + struct atomic_action *actions;
1.83 + char *description;
1.84 + char *toplevel;
1.85 + unsigned next_file_tag;
1.86 + int in_undo;
1.87 + char *error_path;
1.88 + char *error_str;
1.89 + char *error_msg;
1.90 +};
1.91 +
1.92 +char *atomic_action_attic_tmpnam(struct razor_atomic *atomic);
1.93 +struct atomic_action *
1.94 +atomic_action_list_prepend(struct atomic_action *list,
1.95 + struct atomic_action *action);
1.96 +struct atomic_action *atomic_action_new(enum atomic_action_type type);
1.97 +void atomic_action_free(struct atomic_action *action);
1.98 +struct atomic_action *atomic_action_list_reverse(struct atomic_action *list);
1.99 +struct atomic_action *
1.100 +atomic_action_do(struct razor_atomic *atomic, struct atomic_action *action);
1.101 +void
1.102 +atomic_action_undo(struct razor_atomic *atomic, struct atomic_action *action);
1.103 +#else /* !HAVE_WINDOWS_KTM && !ENABLE_ATOMIC */
1.104 +struct razor_atomic {
1.105 + int in_undo;
1.106 + char *error_path;
1.107 + char *error_str;
1.108 + char *error_msg;
1.109 +};
1.110 +#endif
1.111 +
1.112 +int razor_allow_all_root_names(void);
1.113 +int razor_valid_root_name(const char *name);
1.114 +
1.115 +#ifdef MSWIN_API
1.116 +void
1.117 +razor_atomic_set_error_mswin(struct razor_atomic *atomic, const wchar_t *path,
1.118 + DWORD error);
1.119 +#endif
1.120 +
1.121 +#if HAVE_WINDOWS_KTM
1.122 +void
1.123 +razor_atomic_set_error_str(struct razor_atomic *atomic, const wchar_t *path,
1.124 + const char *str);
1.125 +#else
1.126 +void
1.127 +razor_atomic_set_error_str(struct razor_atomic *atomic, const char *path,
1.128 + const char *str);
1.129 +#endif
1.130 +
1.131 #endif /* _RAZOR_INTERNAL_H_ */