2004-03-23 09:22:20 +03:00
/*
2005-07-22 20:35:58 +04:00
* udev_utils . c - generic stuff used by udev
2004-03-23 09:22:20 +03:00
*
2005-07-22 20:35:58 +04:00
* Copyright ( C ) 2004 - 2005 Kay Sievers < kay . sievers @ vrfy . org >
2004-03-23 09:22:20 +03:00
*
* This program is free software ; you can redistribute it and / or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License .
*
* This program is distributed in the hope that it will be useful , but
* WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
* General Public License for more details .
*
* You should have received a copy of the GNU General Public License along
* with this program ; if not , write to the Free Software Foundation , Inc . ,
* 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*
*/
2005-07-22 20:35:58 +04:00
# ifndef _UDEV_COMMON_H_
# define _UDEV_COMMON_H_
2004-03-23 09:22:20 +03:00
2004-10-19 06:11:51 +04:00
# include "udev.h"
2005-07-22 20:35:58 +04:00
# include "list.h"
2004-03-23 09:22:20 +03:00
2005-08-11 19:32:59 +04:00
# define UDEV_MAX(a,b) ((a) > (b) ? (a) : (b))
2005-08-28 22:25:37 +04:00
/* pipes */
# define READ_END 0
# define WRITE_END 1
2005-03-04 23:33:57 +03:00
struct name_entry {
struct list_head node ;
2005-03-07 06:29:43 +03:00
char name [ PATH_SIZE ] ;
2005-03-04 23:33:57 +03:00
} ;
2005-08-28 15:49:32 +04:00
/* udev_utils.c */
2005-06-05 07:11:29 +04:00
extern int log_priority ( const char * priority ) ;
2005-08-28 15:49:32 +04:00
extern int kernel_release_satisfactory ( unsigned int version , unsigned int patchlevel , unsigned int sublevel ) ;
2005-03-04 23:33:57 +03:00
extern int name_list_add ( struct list_head * name_list , const char * name , int sort ) ;
2005-06-26 20:55:24 +04:00
extern int name_list_key_add ( struct list_head * name_list , const char * key , const char * value ) ;
2005-08-27 18:15:41 +04:00
extern void name_list_cleanup ( struct list_head * name_list ) ;
2005-03-17 11:59:32 +03:00
extern int add_matching_files ( struct list_head * name_list , const char * dirname , const char * suffix ) ;
2005-08-28 15:49:32 +04:00
/* udev_utils_string.c */
extern int strcmp_pattern ( const char * p , const char * s ) ;
extern int string_is_true ( const char * str ) ;
2005-08-29 01:15:51 +04:00
extern void remove_trailing_chars ( char * path , char c ) ;
2005-08-28 15:49:32 +04:00
extern int utf8_encoded_valid_unichar ( const char * str ) ;
2005-08-28 17:55:58 +04:00
extern int replace_untrusted_chars ( char * str ) ;
2005-08-28 15:49:32 +04:00
/* udev_utils_file.c */
extern int create_path ( const char * path ) ;
extern int file_map ( const char * filename , char * * buf , size_t * bufsize ) ;
extern void file_unmap ( void * buf , size_t bufsize ) ;
extern int unlink_secure ( const char * filename ) ;
extern size_t buf_get_line ( const char * buf , size_t buflen , size_t cur ) ;
/* udev_utils_run.c */
2005-08-01 07:07:19 +04:00
extern int pass_env_to_socket ( const char * name , const char * devpath , const char * action ) ;
2005-08-11 19:32:59 +04:00
extern int run_program ( const char * command , const char * subsystem ,
char * result , size_t ressize , size_t * reslen , int log ) ;
2005-03-17 11:59:32 +03:00
2004-03-23 09:22:20 +03:00
# endif