File: connection.c

package info (click to toggle)
libssh 0.5.4-1%2Bdeb7u3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,364 kB
  • sloc: ansic: 27,753; cpp: 377; makefile: 22; sh: 22; python: 9
file content (31 lines) | stat: -rw-r--r-- 793 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
This file is distributed in public domain. You can do whatever you want
with its content.
*/

#include <libssh/libssh.h>
#include <stdio.h>
#include "tests.h"
SSH_OPTIONS *set_opts(int argc, char **argv){
	SSH_OPTIONS *options=ssh_options_new();
	char *host=NULL;
	if(ssh_options_getopt(options,&argc, argv)){
	    fprintf(stderr,"error parsing command line :%s\n",ssh_get_error(options));
	    return NULL;
	}
    int i;
    while((i=getopt(argc,argv,""))!=-1){
        switch(i){
            default:
                fprintf(stderr,"unknown option %c\n",optopt);
        }
    }
    if(optind < argc)
        host=argv[optind++];
    if(host==NULL){
    	fprintf(stderr,"must provide an host name\n");
    	return NULL;
    }
    ssh_options_set_host(options,host);
    return options;
}