2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
16 #include <netinet/in.h>
24 #define N_SECURITY_OBJECTS 1
26 extern BULK_ExecuteRequest();
30 rx_PrintStats(stdout);
36 struct rx_securityClass *(securityObjects[N_SECURITY_OBJECTS]);
37 struct rx_service *service;
39 signal(SIGINT, InterruptSignal);
41 /* Initialize Rx, telling it port number this server will use for its single service */
42 if (rx_Init(BULK_SERVER_PORT) < 0)
45 /* Create a single security object, in this case the null security object, for unauthenticated connections, which will be used to control security on connections made to this server */
46 securityObjects[BULK_NULL] = rxnull_NewServerSecurityObject();
47 if (securityObjects[BULK_NULL] == (struct rx_securityClass *)0)
48 Quit("rxnull_NewServerSecurityObject");
50 /* Instantiate a single BULK service. The rxgen-generated procedure which is called to decode requests is passed in here (BULK_ExecuteRequest). */
52 rx_NewService(0, BULK_SERVICE_ID, "BULK", securityObjects,
53 N_SECURITY_OBJECTS, BULK_ExecuteRequest);
54 if (service == (struct rx_service *)0)
55 Quit("rx_NewService");
56 rx_SetMaxProcs(service, 5);
58 rx_StartServer(1); /* Donate this process to the server process pool */
59 Quit("StartServer returned?");
62 int bulk_operationNumber = 0;
65 BULK_FetchFile(call, verbose, name)
71 int opnum = ++bulk_operationNumber;
74 printf("%d: fetch %s\n", opnum, name);
75 fd = open(name, O_RDONLY, 0);
76 if (fd < 0 || fstat(fd, &status) < 0) {
78 printf("%d: failed to open %s\n", opnum, name);
82 error = bulk_SendFile(fd, call, &status);
84 printf("%d: fetch of %s failed, error %d\n", opnum, name, error);
86 printf("%d: fetch of %s complete\n", opnum, name);
94 BULK_StoreFile(call, verbose, name)
99 int opnum = ++bulk_operationNumber;
104 printf("%d: store file %s\n", opnum, name);
105 fd = open(name, O_CREAT | O_TRUNC | O_WRONLY, 0666);
106 if (fd < 0 || fstat(fd, &status) < 0) {
107 fprintf(stderr, "%d: could not create %s\n", opnum, name);
111 error = bulk_ReceiveFile(fd, call, &status);
113 printf("%d: store of %s failed, error %d\n", opnum, name, error);
115 printf("%d: store of %s complete\n", opnum, name);
126 fprintf(stderr, msg, a, b);