~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/comm/test_cl_hostname_list.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/*___INFO__MARK_BEGIN__*/
 
3
/*************************************************************************
 
4
 * 
 
5
 *  The Contents of this file are made available subject to the terms of
 
6
 *  the Sun Industry Standards Source License Version 1.2
 
7
 * 
 
8
 *  Sun Microsystems Inc., March, 2001
 
9
 * 
 
10
 * 
 
11
 *  Sun Industry Standards Source License Version 1.2
 
12
 *  =================================================
 
13
 *  The contents of this file are subject to the Sun Industry Standards
 
14
 *  Source License Version 1.2 (the "License"); You may not use this file
 
15
 *  except in compliance with the License. You may obtain a copy of the
 
16
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
17
 * 
 
18
 *  Software provided under this License is provided on an "AS IS" basis,
 
19
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
20
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
21
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
22
 *  See the License for the specific provisions governing your rights and
 
23
 *  obligations concerning the Software.
 
24
 * 
 
25
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
26
 * 
 
27
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
28
 * 
 
29
 *   All Rights Reserved.
 
30
 * 
 
31
 ************************************************************************/
 
32
/*___INFO__MARK_END__*/
 
33
 
 
34
 
 
35
#include <stdio.h>
 
36
#include <stdlib.h>
 
37
#include <string.h>
 
38
#include <unistd.h>
 
39
#include <signal.h>
 
40
 
 
41
#include <arpa/inet.h>  /* for inet_makeaddr() */
 
42
#include <netinet/in.h>
 
43
 
 
44
#include "cl_commlib.h"
 
45
#include "cl_host_list.h"
 
46
 
 
47
 
 
48
 
 
49
 
 
50
extern int
 
51
main(int argc, char** argv)
 
52
{
 
53
  int retval = 0;
 
54
  int arg = 0;
 
55
  struct in_addr addr;
 
56
  struct in_addr addr2;
 
57
  char* rhost = NULL;
 
58
  int loops = -1;
 
59
 
 
60
 
 
61
  if (argc < 3) {
 
62
      printf("usage: test_cl_hostname_list <DEBUGLEVEL> hostnames\n");
 
63
      exit(1);
 
64
  }
 
65
 
 
66
  printf("commlib setup ...\n");
 
67
  retval = cl_com_setup_commlib(CL_NO_THREAD, (cl_log_t)atoi(argv[1]), NULL);
 
68
  printf("%s\n\n",cl_get_error_text(retval));
 
69
 
 
70
  printf("reslovling host addr 129.157.141.10 ...\n");
 
71
  addr = inet_makeaddr(129*256+157,141*256+10);
 
72
  printf("ip addr: %s\n",inet_ntoa(addr));  /* inet_ntoa() is not MT save */
 
73
  addr2 = inet_makeaddr(192*256+168,11*256+1);
 
74
  printf("ip addr2: %s\n",inet_ntoa(addr2));  /* inet_ntoa() is not MT save */
 
75
 
 
76
 
 
77
 
 
78
  while ((loops--) != 0) { 
 
79
  arg = 2;
 
80
  printf("loop\n\n\n");
 
81
     while( argv[arg] != NULL) {
 
82
        printf("resolving host \"%s\" ...\n", argv[arg]);
 
83
        retval = cl_com_cached_gethostbyname(argv[arg],&rhost,NULL,NULL,NULL);
 
84
        printf("%s\n",cl_get_error_text(retval));
 
85
   
 
86
        if (rhost != NULL) {
 
87
           printf(" -> host resolved as \"%s\"\n", rhost );
 
88
           free(rhost);
 
89
           rhost = NULL;
 
90
        }
 
91
   
 
92
        printf("cl_com_gethostbyaddr ... %s\n", inet_ntoa(addr)); /* inet_ntoa() is not MT save */
 
93
 
 
94
        retval = cl_com_cached_gethostbyaddr(&addr, &rhost, NULL, NULL);
 
95
        printf("%s\n",cl_get_error_text(retval));
 
96
   
 
97
        if (retval == CL_RETVAL_OK) {
 
98
           printf(" -> host name is \"%s\"\n", rhost);
 
99
        }
 
100
        free(rhost);
 
101
        rhost = NULL;
 
102
   
 
103
        printf("cl_com_gethostbyaddr ... %s\n",inet_ntoa(addr2) ); /* inet_ntoa() is not MT save */
 
104
 
 
105
   
 
106
        retval = cl_com_cached_gethostbyaddr(&addr2, &rhost, NULL, NULL);
 
107
        printf("%s\n",cl_get_error_text(retval));
 
108
   
 
109
        if (retval == CL_RETVAL_OK) {
 
110
           printf(" -> host name is \"%s\"\n", rhost);
 
111
        }
 
112
        free(rhost);
 
113
        rhost = NULL;
 
114
   
 
115
        printf("***********************************************************\n");
 
116
        arg++;
 
117
     }
 
118
     sleep(1); 
 
119
  }
 
120
  
 
121
  
 
122
  printf("commlib cleanup ...\n");
 
123
  retval = cl_com_cleanup_commlib();
 
124
  printf("%s\n\n",cl_get_error_text(retval));
 
125
 
 
126
 
 
127
  printf("main done\n");
 
128
  return 0;
 
129
}
 
130
 
 
131
 
 
132
 
 
133
 
 
134