Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * SPDX-License-Identifier: GPL-2.0
0003  *
0004  * Copyright (c) 2008 Intel Corporation
0005  * Copyright (c) 2018 The Linux Foundation. All rights reserved.
0006  */
0007 
0008 #ifndef _ASCII85_H_
0009 #define _ASCII85_H_
0010 
0011 #include <linux/math.h>
0012 #include <linux/types.h>
0013 
0014 #define ASCII85_BUFSZ 6
0015 
0016 static inline long
0017 ascii85_encode_len(long len)
0018 {
0019     return DIV_ROUND_UP(len, 4);
0020 }
0021 
0022 static inline const char *
0023 ascii85_encode(u32 in, char *out)
0024 {
0025     int i;
0026 
0027     if (in == 0)
0028         return "z";
0029 
0030     out[5] = '\0';
0031     for (i = 5; i--; ) {
0032         out[i] = '!' + in % 85;
0033         in /= 85;
0034     }
0035 
0036     return out;
0037 }
0038 
0039 #endif