Annotation of 43BSDTahoe/new/xns/examples/print/printtest.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include <sys/types.h>
                      3: #include <netns/ns.h>
                      4: #include "Printing3_defs.h"
                      5: #include <xnscourier/except.h>
                      6: 
                      7: static FILE *ipfile = NULL;
                      8: 
                      9: SendSource(bdtconnection)
                     10: CourierConnection *bdtconnection;
                     11: {
                     12:        int count;
                     13:        char buffer[SPPMAXDATA];
                     14: 
                     15:        while ( (count = fread(buffer,1,SPPMAXDATA,ipfile)) > 0 &&
                     16:                BDTwrite(bdtconnection,buffer,count) >= 0 )
                     17:                ;
                     18:        if (count <= 0)
                     19:                BDTclosewrite(bdtconnection);   /* last packet with EOM set */
                     20:        else
                     21:                BDTabort(bdtconnection);
                     22: }
                     23: 
                     24: main(argc, argv)
                     25:        int argc;
                     26:        char *argv[];
                     27: {
                     28:        PrintResults result;
                     29:        struct xn_addr *destaddr;
                     30:        CourierConnection *conn;
                     31:        extern struct xn_addr *getXNSaddr();
                     32:        char *xnshost;
                     33:        PrintAttributes attributes;
                     34:        PrintOptions options;
                     35:        xnshost = "2-273#2-852-159-207";        /* CornellS2 */
                     36: 
                     37:                /* default to CornellS1 2-273, 2-852-151-014 */
                     38:                /* xnshost = "8E1#00.00.AA.00.5E.E6"; */
                     39: 
                     40:        if ((destaddr = getXNSaddr(xnshost)) == NULL) {
                     41:                fprintf(stderr,"Invalid machine name.\n");
                     42:        }
                     43: 
                     44:        switch (argc) {
                     45:        case 2: if ((ipfile = fopen(argv[1],"r")) != NULL)
                     46:                        break;          /* got a valid file name */
                     47:        default:
                     48:                fprintf(stderr,"Usage: %s file\n",argv[0]);
                     49:                exit(1);
                     50:        }
                     51: 
                     52:        if ((conn = CourierOpen(destaddr)) == NULL) {
                     53:                fprintf(stderr,"Can't open connection to %s\n",xnshost);
                     54:                exit(1);
                     55:        }
                     56: 
                     57:        attributes.length = 0;
                     58:        options.length = 0;
                     59: 
                     60:        DURING
                     61:                result = Print(conn, SendSource, BulkData1_immediateSource,
                     62:                                        attributes, options);
                     63:        HANDLER {
                     64:                switch (Exception.Code) {
                     65:                case Busy:
                     66:                        fprintf(stderr,"Busy\n");
                     67:                        break;
                     68:                case ConnectionError:
                     69:                        fprintf(stderr,"Connection error, %d\n",
                     70:                                CourierErrArgs(ConnectionErrorArgs,problem));
                     71:                        break;
                     72:                case InsufficientSpoolSpace:
                     73:                        fprintf(stderr,"Insufficient Spool Space error\n");
                     74:                        break;
                     75:                case InvalidPrintParameters:
                     76:                        fprintf(stderr,"InvalidPrintParameters error\n");
                     77:                        break;
                     78:                case MasterTooLarge:
                     79:                        fprintf(stderr,"MasterTooLarge error\n");
                     80:                        break;
                     81:                case MediumUnavailable:
                     82:                        fprintf(stderr,"MediumUnavailable error\n");
                     83:                        break;
                     84:                case ServiceUnavailable:
                     85:                        fprintf(stderr,"ServiceUnavailable error\n");
                     86:                        break;
                     87:                case SpoolingDisabled:
                     88:                        fprintf(stderr,"SpoolingDisabled\n");
                     89:                        break;
                     90:                case SpoolingQueueFull:
                     91:                        fprintf(stderr,"SpoolingQueueFull error\n");
                     92:                        break;
                     93:                case SystemError:
                     94:                        fprintf(stderr,"System Error\n");
                     95:                        break;
                     96:                case TooManyClients:
                     97:                        fprintf(stderr,"TooManyClients error\n");
                     98:                        break;
                     99:                case TransferError:
                    100:                        fprintf(stderr,"TransferError error\n");
                    101:                        break;
                    102:                case Undefined:
                    103:                        fprintf(stderr,"Undefined error, number %d\n",
                    104:                                CourierErrArgs(UndefinedArgs,problem));
                    105: 
                    106:                case REJECT_ERROR:
                    107:                        fprintf(stderr,"REJECT:  type = %d\n",
                    108:                                CourierErrArgs(rejectionDetails, designator));
                    109:                        break;
                    110:                default:
                    111:                        fprintf(stderr,"Some random error, code %d\n",
                    112:                                Exception.Code);
                    113:                        break;
                    114:                }
                    115:        exit(1);
                    116:        } END_HANDLER;
                    117: 
                    118:        /* CourierClose(conn); */
                    119:        /* RETURNS [printRequestID: RequestID] */
                    120:        printf("Done.  Request ID %x %x %x %x %x\n",
                    121:                result.printRequestID[0],
                    122:                result.printRequestID[1],
                    123:                result.printRequestID[2],
                    124:                result.printRequestID[3],
                    125:                result.printRequestID[4]);
                    126: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.