2 * utils.h - Part of the Linux-NTFS project.
4 * Copyright (c) 2002 Richard Russon
6 * A set of shared functions for ntfs utilities
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program (in the main directory of the Linux-NTFS
20 * distribution in the file COPYING); if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #ifndef _NTFS_UTILS_H_
25 #define _NTFS_UTILS_H_
34 extern const char *ntfs_bugs;
35 extern const char *ntfs_home;
36 extern const char *ntfs_gpl;
40 #define GEN_PRINTF(NAME, STREAM, CONTROL, TRIGGER) \
41 __attribute__ ((format (printf, 1, 2))) \
42 int NAME (const char *format, ...) \
44 int ret, olderr = errno, *control = (CONTROL); \
50 ((*control && !(TRIGGER)) || (!*control && (TRIGGER)))) \
53 va_start (args, format); \
54 ret = vfprintf ((STREAM), format, args); \
62 int ntfs_printf (struct _IO_FILE *stream, int *control, BOOL trigger,
63 const char *format, ...) __attribute__ ((format (printf, 4, 5)));
65 int utils_valid_device (const char *name, int force);
66 int utils_set_locale (void);
67 ntfs_volume * utils_mount_volume (const char *device, unsigned long flags, BOOL force);
68 int utils_parse_size (const char *value, s64 *size, BOOL scale);
69 int utils_parse_range (const char *string, s64 *start, s64 *finish, BOOL scale);
70 int utils_inode_get_name (ntfs_inode *inode, char *buffer, int bufsize);
71 int utils_attr_get_name (ntfs_volume *vol, ATTR_RECORD *attr, char *buffer, int bufsize);
72 int utils_cluster_in_use (ntfs_volume *vol, long long lcn);
73 int utils_mftrec_in_use (ntfs_volume *vol, MFT_REF mref);
75 time_t ntfs2utc (s64 time);
76 s64 utc2ntfs (time_t time);
78 ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx);
79 ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft);
81 #endif /* _NTFS_UTILS_H_ */