extattr.c (1bc2362e07cefcd69039f2a713faf17832150846) | extattr.c (d51048c93b51a6811343d87d9db9c771a4496347) |
---|---|
1/*- 2 * Copyright (c) 2001 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 32#include <sys/types.h> 33#include <sys/extattr.h> 34 35#include <errno.h> 36#include <string.h> 37 38int | 1/*- 2 * Copyright (c) 2001 Robert N. M. Watson 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 32#include <sys/types.h> 33#include <sys/extattr.h> 34 35#include <errno.h> 36#include <string.h> 37 38int |
39extattr_namespace_to_string(int namespace, char **string) | 39extattr_namespace_to_string(int attrnamespace, char **string) |
40{ 41 | 40{ 41 |
42 switch(namespace) { | 42 switch(attrnamespace) { |
43 case EXTATTR_NAMESPACE_USER: 44 if (*string != NULL) 45 *string = strdup(EXTATTR_NAMESPACE_USER_STRING); 46 return (0); 47 48 case EXTATTR_NAMESPACE_SYSTEM: 49 if (*string != NULL) 50 *string = strdup(EXTATTR_NAMESPACE_SYSTEM_STRING); 51 return (0); 52 53 default: 54 errno = EINVAL; 55 return (-1); 56 } 57} 58 59int | 43 case EXTATTR_NAMESPACE_USER: 44 if (*string != NULL) 45 *string = strdup(EXTATTR_NAMESPACE_USER_STRING); 46 return (0); 47 48 case EXTATTR_NAMESPACE_SYSTEM: 49 if (*string != NULL) 50 *string = strdup(EXTATTR_NAMESPACE_SYSTEM_STRING); 51 return (0); 52 53 default: 54 errno = EINVAL; 55 return (-1); 56 } 57} 58 59int |
60extattr_string_to_namespace(const char *string, int *namespace) | 60extattr_string_to_namespace(const char *string, int *attrnamespace) |
61{ 62 63 if (!strcmp(string, EXTATTR_NAMESPACE_USER_STRING)) { | 61{ 62 63 if (!strcmp(string, EXTATTR_NAMESPACE_USER_STRING)) { |
64 if (namespace != NULL) 65 *namespace = EXTATTR_NAMESPACE_USER; | 64 if (attrnamespace != NULL) 65 *attrnamespace = EXTATTR_NAMESPACE_USER; |
66 return (0); 67 } else if (!strcmp(string, EXTATTR_NAMESPACE_SYSTEM_STRING)) { | 66 return (0); 67 } else if (!strcmp(string, EXTATTR_NAMESPACE_SYSTEM_STRING)) { |
68 if (namespace != NULL) 69 *namespace = EXTATTR_NAMESPACE_SYSTEM; | 68 if (attrnamespace != NULL) 69 *attrnamespace = EXTATTR_NAMESPACE_SYSTEM; |
70 return (0); 71 } else { 72 errno = EINVAL; 73 return (-1); 74 } 75} | 70 return (0); 71 } else { 72 errno = EINVAL; 73 return (-1); 74 } 75} |