libssh 0.4.8

include/libssh/misc.h

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 
00034 /* macro for byte ordering */
00035 uint64_t ntohll(uint64_t);
00036 #define htonll(x) ntohll(x)
00037 
00038 /* list processing */
00039 
00040 struct ssh_list {
00041   struct ssh_iterator *root;
00042   struct ssh_iterator *end;
00043 };
00044 
00045 struct ssh_iterator {
00046   struct ssh_iterator *next;
00047   const void *data;
00048 };
00049 
00050 struct ssh_list *ssh_list_new(void);
00051 void ssh_list_free(struct ssh_list *list);
00052 struct ssh_iterator *ssh_list_get_iterator(const struct ssh_list *list);
00053 int ssh_list_append(struct ssh_list *list, const void *data);
00054 int ssh_list_prepend(struct ssh_list *list, const void *data);
00055 void ssh_list_remove(struct ssh_list *list, struct ssh_iterator *iterator);
00056 char *ssh_hostport(const char *host, int port);
00057 
00058 const void *_ssh_list_pop_head(struct ssh_list *list);
00059 
00060 #define ssh_iterator_value(type, iterator)\
00061   ((type)((iterator)->data))
00062 
00068 #define ssh_list_pop_head(type, ssh_list)\
00069   ((type)_ssh_list_pop_head(ssh_list))
00070 
00071 #endif /* MISC_H_ */