1 /*
2 OWFS -- One-Wire filesystem
3 OWHTTPD -- One-Wire Web Server
4 Written 2003 Paul H Alfille
5 email: paul.alfille@gmail.com
6 Released under the GPL
7 See the header file: ow.h for full attribution
8 1wire/iButton system from Dallas Semiconductor
9 */
10
11 #include <config.h>
12 #include "owfs_config.h"
13 #include "ow_devices.h"
14
15 char *ePN_name[] = {
16 "",
17 "",
18 "statistics",
19 "system",
20 "settings",
21 "structure",
22 "interface",
23 0,
24 };
25
26 /* device display format */
FS_devicename(char * buffer,const size_t length,const BYTE * sn,const struct parsedname * pn)27 void FS_devicename(char *buffer, const size_t length, const BYTE * sn, const struct parsedname *pn)
28 {
29 UCLIBCLOCK;
30 switch (DeviceFormat(pn)) {
31 case fi:
32 snprintf(buffer, length, "%02X%02X%02X%02X%02X%02X%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6]);
33 break;
34 case fdidc:
35 snprintf(buffer, length, "%02X.%02X%02X%02X%02X%02X%02X.%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7]);
36 break;
37 case fdic:
38 snprintf(buffer, length, "%02X.%02X%02X%02X%02X%02X%02X%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7]);
39 break;
40 case fidc:
41 snprintf(buffer, length, "%02X%02X%02X%02X%02X%02X%02X.%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7]);
42 break;
43 case fic:
44 snprintf(buffer, length, "%02X%02X%02X%02X%02X%02X%02X%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6], sn[7]);
45 break;
46 case fdi:
47 default:
48 snprintf(buffer, length, "%02X.%02X%02X%02X%02X%02X%02X", sn[0], sn[1], sn[2], sn[3], sn[4], sn[5], sn[6]);
49 break;
50 }
51 UCLIBCUNLOCK;
52 }
53
54 /* Return the last part of the file name specified by pn */
55 /* This can be a device, directory, subdiirectory, if property file */
56 /* Prints this directory element (not the whole path) */
57 /* Suggest that size = OW_FULLNAME_MAX */
FS_DirName(const struct parsedname * pn)58 const char *FS_DirName(const struct parsedname *pn)
59 {
60 char *slash;
61 if (pn == NULL) {
62 return "";
63 }
64 slash = strrchr(pn->path, '/');
65 if (slash == NULL) {
66 return "";
67 }
68 return slash + 1;
69 }
70