diff -r e63951c1d0f8 -r d0aa9e0a6d04 librazor/razor-internal.h --- a/librazor/razor-internal.h Thu Nov 10 10:35:21 2011 +0000 +++ b/librazor/razor-internal.h Thu Feb 09 20:42:08 2012 +0000 @@ -1,7 +1,7 @@ /* * Copyright (C) 2008 Kristian Høgsberg * Copyright (C) 2008 Red Hat, Inc - * Copyright (C) 2009, 2011 J. Ali Harlow + * Copyright (C) 2009, 2011-2012 J. Ali Harlow * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,9 @@ #ifndef _RAZOR_INTERNAL_H_ #define _RAZOR_INTERNAL_H_ +#ifdef MSWIN_API +#include +#endif #include #include #include @@ -234,4 +237,109 @@ void environment_unset(struct environment *env); void environment_release(struct environment *env); +#ifdef MSWIN_API +char *razor_utf16_to_utf8(const wchar_t *utf16, int len); +wchar_t *razor_utf8_to_utf16(const char *utf8, int len); +#endif + +/* Atomic functions */ + +#if HAVE_WINDOWS_KTM +struct razor_atomic { + HANDLE transaction; + int n_files; + struct razor_atomic_file { + wchar_t *path; + HANDLE h; + } *files; + int in_undo; + char *error_path; + char *error_str; + char *error_msg; +}; +#elif ENABLE_ATOMIC +struct atomic_action { + struct atomic_action *next; + enum atomic_action_type { + /* Complex actions */ + ACTION_MAKE_DIRS, + ACTION_REMOVE, + /* Primitive actions */ + ACTION_CREATE_DIR, +#if HAVE_SYMLINK + ACTION_CREATE_SYMLINK, +#endif + ACTION_MOVE, + } type; + struct { + char *path; + union atomic_action_args { + struct { + char *root; + } make_dirs; + struct { + mode_t mode; + } create_dir; +#if HAVE_SYMLINK + struct { + char *target; + } create_symlink; +#endif + struct { + char *dest; + } move; + } u; + } args; +}; + +struct razor_atomic { + struct atomic_action *actions; + char *description; + char *toplevel; + unsigned next_file_tag; + int in_undo; + char *error_path; + char *error_str; + char *error_msg; +}; + +char *atomic_action_attic_tmpnam(struct razor_atomic *atomic); +struct atomic_action * +atomic_action_list_prepend(struct atomic_action *list, + struct atomic_action *action); +struct atomic_action *atomic_action_new(enum atomic_action_type type); +void atomic_action_free(struct atomic_action *action); +struct atomic_action *atomic_action_list_reverse(struct atomic_action *list); +struct atomic_action * +atomic_action_do(struct razor_atomic *atomic, struct atomic_action *action); +void +atomic_action_undo(struct razor_atomic *atomic, struct atomic_action *action); +#else /* !HAVE_WINDOWS_KTM && !ENABLE_ATOMIC */ +struct razor_atomic { + int in_undo; + char *error_path; + char *error_str; + char *error_msg; +}; +#endif + +int razor_allow_all_root_names(void); +int razor_valid_root_name(const char *name); + +#ifdef MSWIN_API +void +razor_atomic_set_error_mswin(struct razor_atomic *atomic, const wchar_t *path, + DWORD error); +#endif + +#if HAVE_WINDOWS_KTM +void +razor_atomic_set_error_str(struct razor_atomic *atomic, const wchar_t *path, + const char *str); +#else +void +razor_atomic_set_error_str(struct razor_atomic *atomic, const char *path, + const char *str); +#endif + #endif /* _RAZOR_INTERNAL_H_ */