xref: /nrf52832-nimble/rt-thread/components/dfs/filesystems/uffs/src/uffs/uffs_version.c (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2   This file is part of UFFS, the Ultra-low-cost Flash File System.
3 
4   Copyright (C) 2005-2009 Ricky Zheng <[email protected]>
5 
6   UFFS is free software; you can redistribute it and/or modify it under
7   the GNU Library General Public License as published by the Free Software
8   Foundation; either version 2 of the License, or (at your option) any
9   later version.
10 
11   UFFS is distributed in the hope that it will be useful, but WITHOUT
12   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14   or GNU Library General Public License, as applicable, for more details.
15 
16   You should have received a copy of the GNU General Public License
17   and GNU Library General Public License along with UFFS; if not, write
18   to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19   Boston, MA  02110-1301, USA.
20 
21   As a special exception, if other files instantiate templates or use
22   macros or inline functions from this file, or you compile this file
23   and link it with other works to produce a work based on this file,
24   this file does not by itself cause the resulting work to be covered
25   by the GNU General Public License. However the source code for this
26   file must still be made available in accordance with section (3) of
27   the GNU General Public License v2.
28 
29   This exception does not invalidate any other reasons why a work based
30   on this file might be covered by the GNU General Public License.
31 */
32 
33 /**
34  * \file uffs_version.c
35  * \brief uffs version information
36  * \author Ricky Zheng, created 8th May, 2005
37  */
38 
39 #include "uffs_config.h"
40 #include "uffs/uffs_version.h"
41 
42 #include <stdio.h>
43 #define PFX "ver : "
44 
45 
46 static char version_buf[16];
47 
uffs_Version2Str(int ver)48 const char * uffs_Version2Str(int ver)
49 {
50 	sprintf(version_buf, "%1d.%02d.%04d",
51 			(ver & 0xff000000) >> 24, (ver & 0xff0000) >> 16, (ver & 0xffff));
52 	return version_buf;
53 }
54 
uffs_GetVersion(void)55 int uffs_GetVersion(void)
56 {
57 	return UFFS_VERSION;
58 }
59 
uffs_GetMainVersion(int ver)60 int uffs_GetMainVersion(int ver)
61 {
62 	return (ver & 0xff000000) >> 24;
63 }
64 
uffs_GetMinorVersion(int ver)65 int uffs_GetMinorVersion(int ver)
66 {
67 	return (ver & 0xff0000) >> 16;
68 }
69 
uffs_GetTrivialVersion(int ver)70 int uffs_GetTrivialVersion(int ver)
71 {
72 	return (ver & 0xff00) >> 8;
73 }