libssh
0.5.2
|
00001 /* 00002 * This file is part of the SSH Library 00003 * 00004 * Copyright (c) 2009 by Aris Adamantiadis 00005 * 00006 * The SSH Library is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * The SSH Library is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00013 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00014 * License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with the SSH Library; see the file COPYING. If not, write to 00018 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00019 * MA 02111-1307, USA. 00020 */ 00021 00022 #ifndef MISC_H_ 00023 #define MISC_H_ 00024 00025 /* in misc.c */ 00026 /* gets the user home dir. */ 00027 char *ssh_get_user_home_dir(void); 00028 char *ssh_get_local_username(ssh_session session); 00029 int ssh_file_readaccess_ok(const char *file); 00030 00031 char *ssh_path_expand_tilde(const char *d); 00032 char *ssh_path_expand_escape(ssh_session session, const char *s); 00033 int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2); 00034 int ssh_is_ipaddr_v4(const char *str); 00035 int ssh_is_ipaddr(const char *str); 00036 00037 /* macro for byte ordering */ 00038 uint64_t ntohll(uint64_t); 00039 #define htonll(x) ntohll(x) 00040 00041 /* list processing */ 00042 00043 struct ssh_list { 00044 struct ssh_iterator *root; 00045 struct ssh_iterator *end; 00046 }; 00047 00048 struct ssh_iterator { 00049 struct ssh_iterator *next; 00050 const void *data; 00051 }; 00052 00053 struct ssh_timestamp { 00054 long seconds; 00055 long useconds; 00056 }; 00057 00058 struct ssh_list *ssh_list_new(void); 00059 void ssh_list_free(struct ssh_list *list); 00060 struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list); 00061 struct ssh_iterator *ssh_list_find(const struct ssh_list *list, void *value); 00062 int ssh_list_append(struct ssh_list *list, const void *data); 00063 int ssh_list_prepend(struct ssh_list *list, const void *data); 00064 void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator); 00065 char *ssh_lowercase(const char* str); 00066 char *ssh_hostport(const char *host, int port); 00067 00068 const void *_ssh_list_pop_head(struct ssh_list *list); 00069 00070 #define ssh_iterator_value(type, iterator)\ 00071 ((type)((iterator)->data)) 00072 00078 #define ssh_list_pop_head(type, ssh_list)\ 00079 ((type)_ssh_list_pop_head(ssh_list)) 00080 00081 void ssh_timestamp_init(struct ssh_timestamp *ts); 00082 int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout); 00083 int ssh_timeout_update(struct ssh_timestamp *ts, int timeout); 00084 00085 #endif /* MISC_H_ */