comparison src/fileio.c @ 2266:ae2e615a7320 vim73

Fix tiny build, move functions to undo.c.
author Bram Moolenaar <bram@vim.org>
date Mon, 14 Jun 2010 01:39:13 +0200
parents b7cb69ab616d
children c08f91142c41
comparison
equal deleted inserted replaced
2265:b7cb69ab616d 2266:ae2e615a7320
3009 return header; 3009 return header;
3010 } 3010 }
3011 3011
3012 #endif /* FEAT_CRYPT */ 3012 #endif /* FEAT_CRYPT */
3013 3013
3014 /*
3015 * Like fwrite() but crypt the bytes when 'key' is set.
3016 * Returns 1 if successful.
3017 */
3018 size_t
3019 fwrite_crypt(buf, ptr, len, fp)
3020 buf_T *buf UNUSED;
3021 char_u *ptr;
3022 size_t len;
3023 FILE *fp;
3024 {
3025 #ifdef FEAT_CRYPT
3026 char_u *copy;
3027 char_u small_buf[100];
3028 size_t i;
3029
3030 if (*buf->b_p_key == NUL)
3031 return fwrite(ptr, len, (size_t)1, fp);
3032 if (len < 100)
3033 copy = small_buf; /* no malloc()/free() for short strings */
3034 else
3035 {
3036 copy = lalloc(len, FALSE);
3037 if (copy == NULL)
3038 return 0;
3039 }
3040 crypt_encode(ptr, len, copy);
3041 i = fwrite(copy, len, (size_t)1, fp);
3042 if (copy != small_buf)
3043 vim_free(copy);
3044 return i;
3045 #else
3046 return fwrite(ptr, len, (size_t)1, fp);
3047 #endif
3048 }
3049
3050 /*
3051 * Read a string of length "len" from "fd".
3052 * When 'key' is set decrypt the bytes.
3053 */
3054 char_u *
3055 read_string_decrypt(buf, fd, len)
3056 buf_T *buf UNUSED;
3057 FILE *fd;
3058 int len;
3059 {
3060 char_u *ptr;
3061
3062 ptr = read_string(fd, len);
3063 #ifdef FEAT_CRYPT
3064 if (ptr != NULL || *buf->b_p_key != NUL)
3065 crypt_decode(ptr, len);
3066 #endif
3067 return ptr;
3068 }
3069
3070
3071 #ifdef UNIX 3014 #ifdef UNIX
3072 static void 3015 static void
3073 set_file_time(fname, atime, mtime) 3016 set_file_time(fname, atime, mtime)
3074 char_u *fname; 3017 char_u *fname;
3075 time_t atime; /* access time */ 3018 time_t atime; /* access time */