~ubuntu-branches/ubuntu/maverick/ncbi-tools6/maverick

« back to all changes in this revision

Viewing changes to connect/test/http_connector_hit.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: http_connector_hit.c,v 6.5 2001/01/11 16:42:45 lavr Exp $
 
1
/*  $Id: http_connector_hit.c,v 6.13 2004/04/01 14:14:02 lavr Exp $
2
2
 * ===========================================================================
3
3
 *
4
4
 *                            PUBLIC DOMAIN NOTICE
28
28
 * File Description:
29
29
 *   Hit an arbitrary URL using HTTP-based CONNECTOR
30
30
 *
31
 
 * --------------------------------------------------------------------------
32
 
 * $Log: http_connector_hit.c,v $
33
 
 * Revision 6.5  2001/01/11 16:42:45  lavr
34
 
 * Registry Get/Set methods got the 'user_data' argument, forgotten earlier
35
 
 *
36
 
 * Revision 6.4  2000/11/15 17:27:29  vakatov
37
 
 * Fixed path to the test CGI application.
38
 
 *
39
 
 * Revision 6.3  2000/09/27 16:00:24  lavr
40
 
 * Registry entries adjusted
41
 
 *
42
 
 * Revision 6.2  2000/05/30 23:24:40  vakatov
43
 
 * Cosmetic fix for the C++ compilation
44
 
 *
45
 
 * Revision 6.1  2000/04/21 19:56:28  vakatov
46
 
 * Initial revision
47
 
 *
48
 
 * ==========================================================================
49
31
 */
50
32
 
51
 
 
52
 
#if defined(NDEBUG)
53
 
#  undef NDEBUG
54
 
#endif 
55
 
 
 
33
#include "../ncbi_ansi_ext.h"
56
34
#include <connect/ncbi_http_connector.h>
57
35
#include <connect/ncbi_util.h>
58
 
#include <string.h>
 
36
/* This header must go last */
 
37
#include "test_assert.h"
59
38
 
60
39
 
61
40
/* Holder for the cmd.-line arg values describing the URL to hit
91
70
        return;
92
71
    }
93
72
 
94
 
#define X_GET_VALUE(x_name, x_value) \
95
 
    if (strcmp(name, x_name) == 0) { \
96
 
                                         strncpy(value, x_value, value_size); \
97
 
    value[value_size - 1] = '\0'; \
98
 
    return; \
 
73
#define X_GET_VALUE(x_name, x_value)              \
 
74
    if (strcmp(name, x_name) == 0) {              \
 
75
        strncpy0(value, x_value, value_size - 1); \
 
76
        return;                                   \
99
77
    }
100
78
 
101
79
    X_GET_VALUE(REG_CONN_HOST,           s_Args.host);
152
130
    if (argc < 4) {
153
131
        fprintf(stderr,
154
132
                "Usage:   %s host port path [args] [inp_file] [user_header]\n"
155
 
                "Example: %s ray.nlm.nih.gov 6224 "
 
133
                "Example: %s yar.ncbi.nlm.nih.gov 6224 "
156
134
                "/tools/vakatov/con_url.cgi 'arg1+arg2+arg3'\n",
157
135
                argv[0], argv[0]);
158
136
        fprintf(stderr, "Too few arguments.\n");
181
159
                break; /* EOF */
182
160
            }
183
161
 
184
 
            status = CONN_Write(conn, buffer, n_read, &n_written);
 
162
            status = CONN_Write(conn, buffer, n_read,
 
163
                                &n_written, eIO_WritePersist);
185
164
            if (status != eIO_Success) {
186
165
                fprintf(stderr, "Error writing to URL (%s)",
187
166
                        IO_StatusStr(status));
188
167
                assert(0);
189
168
            }
 
169
            assert(n_written == n_read);
190
170
        }
191
171
        fclose(inp_fp);
192
172
    }
194
174
    /* Read reply from connection, write it to standard output */
195
175
    fprintf(stdout, "\n\n----- [BEGIN] HTTP Content -----\n");
196
176
    for (;;) {
197
 
        status = CONN_Read(conn, buffer, sizeof(buffer), &n_read, eIO_Plain);
 
177
        status = CONN_Read(conn,buffer,sizeof(buffer),&n_read,eIO_ReadPlain);
198
178
        if (status != eIO_Success)
199
179
            break;
200
180
 
214
194
    CORE_SetLOG(0);
215
195
    return 0;
216
196
}
 
197
 
 
198
 
 
199
/*
 
200
 * --------------------------------------------------------------------------
 
201
 * $Log: http_connector_hit.c,v $
 
202
 * Revision 6.13  2004/04/01 14:14:02  lavr
 
203
 * Spell "occurred", "occurrence", and "occurring"
 
204
 *
 
205
 * Revision 6.12  2004/02/23 15:23:42  lavr
 
206
 * New (last) parameter "how" added in CONN_Write() API call
 
207
 *
 
208
 * Revision 6.11  2003/04/15 14:06:09  lavr
 
209
 * Changed ray.nlm.nih.gov -> ray.ncbi.nlm.nih.gov
 
210
 *
 
211
 * Revision 6.10  2002/11/22 15:09:40  lavr
 
212
 * Replace all occurrences of "ray" with "yar"
 
213
 *
 
214
 * Revision 6.9  2002/10/28 15:47:12  lavr
 
215
 * Use "ncbi_ansi_ext.h" privately and use strncpy0()
 
216
 *
 
217
 * Revision 6.8  2002/08/07 16:38:08  lavr
 
218
 * EIO_ReadMethod enums changed accordingly; log moved to end
 
219
 *
 
220
 * Revision 6.7  2002/03/22 19:45:55  lavr
 
221
 * Test_assert.h made last among the include files
 
222
 *
 
223
 * Revision 6.6  2002/01/16 21:23:14  vakatov
 
224
 * Utilize header "test_assert.h" to switch on ASSERTs in the Release mode too
 
225
 *
 
226
 * Revision 6.5  2001/01/11 16:42:45  lavr
 
227
 * Registry Get/Set methods got the 'user_data' argument, forgotten earlier
 
228
 *
 
229
 * Revision 6.4  2000/11/15 17:27:29  vakatov
 
230
 * Fixed path to the test CGI application.
 
231
 *
 
232
 * Revision 6.3  2000/09/27 16:00:24  lavr
 
233
 * Registry entries adjusted
 
234
 *
 
235
 * Revision 6.2  2000/05/30 23:24:40  vakatov
 
236
 * Cosmetic fix for the C++ compilation
 
237
 *
 
238
 * Revision 6.1  2000/04/21 19:56:28  vakatov
 
239
 * Initial revision
 
240
 *
 
241
 * ==========================================================================
 
242
 */