00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef MISC_H_
00022 #define MISC_H_
00023
00024
00025
00026 char *ssh_get_user_home_dir(void);
00027 char *ssh_get_local_username(void);
00028 int ssh_file_readaccess_ok(const char *file);
00029
00030 char *ssh_path_expand_tilde(const char *d);
00031 char *ssh_path_expand_escape(ssh_session session, const char *s);
00032 int ssh_analyze_banner(ssh_session session, int server, int *ssh1, int *ssh2);
00033 int ssh_is_ipaddr_v4(const char *str);
00034 int ssh_is_ipaddr(const char *str);
00035
00036 #ifndef HAVE_NTOHLL
00037
00038 uint64_t ntohll(uint64_t);
00039 #endif
00040
00041 #ifndef HAVE_HTONLL
00042 #define htonll(x) ntohll((x))
00043 #endif
00044
00045
00046
00047 struct ssh_list {
00048 struct ssh_iterator *root;
00049 struct ssh_iterator *end;
00050 };
00051
00052 struct ssh_iterator {
00053 struct ssh_iterator *next;
00054 const void *data;
00055 };
00056
00057 struct ssh_timestamp {
00058 long seconds;
00059 long useconds;
00060 };
00061
00062 struct ssh_list *ssh_list_new(void);
00063 void ssh_list_free(struct ssh_list *list);
00064 struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
00065 struct ssh_iterator *ssh_list_find(const struct ssh_list *list, void *value);
00066 int ssh_list_append(struct ssh_list *list, const void *data);
00067 int ssh_list_prepend(struct ssh_list *list, const void *data);
00068 void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator);
00069 char *ssh_lowercase(const char* str);
00070 char *ssh_hostport(const char *host, int port);
00071
00072 const void *_ssh_list_pop_head(struct ssh_list *list);
00073
00074 #define ssh_iterator_value(type, iterator)\
00075 ((type)((iterator)->data))
00076
00082 #define ssh_list_pop_head(type, ssh_list)\
00083 ((type)_ssh_list_pop_head(ssh_list))
00084
00085 int ssh_make_milliseconds(long sec, long usec);
00086 void ssh_timestamp_init(struct ssh_timestamp *ts);
00087 int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout);
00088 int ssh_timeout_update(struct ssh_timestamp *ts, int timeout);
00089
00090 int ssh_match_group(const char *group, const char *object);
00091
00092 #endif