00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MISC_H_
00023 #define MISC_H_
00024
00025
00026
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
00038 uint64_t ntohll(uint64_t);
00039 #define htonll(x) ntohll(x)
00040
00041
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 int ssh_make_milliseconds(long sec, long usec);
00082 void ssh_timestamp_init(struct ssh_timestamp *ts);
00083 int ssh_timeout_elapsed(struct ssh_timestamp *ts, int timeout);
00084 int ssh_timeout_update(struct ssh_timestamp *ts, int timeout);
00085
00086 #endif