~ubuntu-branches/ubuntu/quantal/nspr/quantal-security

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/tests/nbconn.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
#include <stdio.h>
62
62
#include <string.h>
63
63
 
64
 
#ifdef XP_MAC
65
 
#define printf PR_LogPrint
66
 
extern void SetupMacPrintfLog(char *logFile);
67
 
static char *hosts[4] = {"cynic", "warp", "gandalf", "neon"};
68
 
#endif
69
 
 
70
64
#define SERVER_MAX_BIND_COUNT        100
71
65
#define DATA_BUF_SIZE                    256
72
66
#define TCP_SERVER_PORT            10000
94
88
        const char *hostname = NULL;
95
89
    PRIntn default_case, n, bytes_read, bytes_sent;
96
90
        PRInt32 failed_already = 0;
97
 
#ifdef XP_MAC
98
 
        int index;
99
 
        PRIntervalTime timeout;
100
 
#endif
101
91
 
102
92
    /*
103
93
     * -d           debug mode
122
112
    }
123
113
    PL_DestroyOptState(opt);
124
114
 
125
 
#ifdef XP_MAC
126
 
        SetupMacPrintfLog("nbconn.log");
127
 
        for (index=0; index<4; index++) {
128
 
        argv[1] = hosts[index];
129
 
        timeout = PR_INTERVAL_NO_TIMEOUT;
130
 
        if (index == 3)
131
 
                timeout = PR_SecondsToInterval(10UL);
132
 
#endif
133
 
 
134
 
 
135
115
    PR_STDIO_INIT();
136
 
#ifndef XP_MAC
137
116
    if (hostname)
138
117
                default_case = 0;
139
118
        else
140
119
                default_case = 1;
141
 
#endif
142
120
 
143
121
        if (default_case) {
144
122
 
175
153
 
176
154
                pd.fd = sock;
177
155
                pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
178
 
#ifndef XP_MAC
179
156
                n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);
180
 
#else
181
 
                n = PR_Poll(&pd, 1, timeout);
182
 
#endif
183
157
                if (n == -1) {
184
158
                        printf( "PR_Poll failed\n");
185
159
                        exit(1);
203
177
 
204
178
                if (PR_GetConnectStatus(&pd) == PR_SUCCESS) {
205
179
                        printf("PR_GetConnectStatus: connect succeeded\n");
206
 
                        /* Mac and Win16 have trouble printing to the console. */
207
 
#if !defined(XP_MAC) && !defined(WIN16)
208
180
                        PR_Write(sock, "GET /\r\n\r\n", 9);
209
181
                        PR_Shutdown(sock, PR_SHUTDOWN_SEND);
210
182
                        pd.in_flags = PR_POLL_READ;
218
190
                                }
219
191
                                PR_Write(PR_STDOUT, buf, n);
220
192
                        }
221
 
#endif
222
193
                } else {
223
194
                        if (PR_GetError() == PR_IN_PROGRESS_ERROR) {
224
195
                                printf( "PR_GetConnectStatus: connect still in progress\n");
228
199
                                        PR_GetError(), PR_GetOSError());
229
200
                }
230
201
                PR_Close(sock);
231
 
#ifdef XP_MAC
232
 
                } /* end of for loop */
233
 
#endif
234
202
        printf( "PASS\n");
235
203
        return 0;
236
204
 
378
346
        DPRINTF(("Created TCP_Server thread [0x%x]\n",thr));
379
347
        pd.fd = conn_fd;
380
348
        pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
381
 
#ifndef XP_MAC
382
349
        n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);
383
 
#else
384
 
        n = PR_Poll(&pd, 1, timeout);
385
 
#endif
386
350
        if (n == -1) {
387
351
                fprintf(stderr,"Error - PR_Poll failed: (%d, %d)\n",
388
352
                                                                        PR_GetError(), PR_GetOSError());
556
520
        }
557
521
        pd.fd = conn_fd;
558
522
        pd.in_flags = PR_POLL_WRITE | PR_POLL_EXCEPT;
559
 
#ifndef XP_MAC
560
523
        n = PR_Poll(&pd, 1, PR_INTERVAL_NO_TIMEOUT);
561
 
#else
562
 
        n = PR_Poll(&pd, 1, timeout);
563
 
#endif
564
524
        if (n == -1) {
565
525
                fprintf(stderr,"Error - PR_Poll failed: (%d, %d)\n",
566
526
                                                                        PR_GetError(), PR_GetOSError());