コード例 #1
0
ファイル: vips2dj.c プロジェクト: anasazi/POP-REU-Project
/* Send the file to fp. width and height are the size to print at in points.
 */
static int
send_file( PrinterGeometry *geo, IMAGE *im, char *mode, 
	FILE *out, int width, int height )
{
	/* Send all the start stuff.
	 */
	if( transmit_file( mode, "head1", out ) )
		return( -1 );
	
	/* Set page size. 
	 */
	fprintf( out, "<</PageSize[%d %d]/ImagingBBox null>>setpagedevice\n",
		geo->pwidth, height + 2*geo->top );

	if( transmit_file( mode, "head2", out ) )
		return( -1 );

	/* Set mT (margin transform? don't know)
	 */
	fprintf( out, "/mT[1 0 0 -1 %d %d]def\n", 
		geo->left, height + geo->top );

	if( transmit_file( mode, "head3", out ) )
		return( -1 );

	/* Set rC ... printable area.
	 */
	fprintf( out, "gS 0 0 %d %d rC\n", width, height );

	if( transmit_file( mode, "head4", out ) )
		return( -1 );

	/* Set image params.
	 */
	fprintf( out, "/rows %d def\n", im->Ysize );
	fprintf( out, "/cols %d def\n", im->Xsize );
	fprintf( out, "%d %d scale\n", width, height );

	if( transmit_file( mode, "head5", out ) )
		return( -1 );

	/* Send the body of the image.
	 */
	if( vips2asciihex( im, out ) )
		return( -1 );

	if( transmit_file( mode, "head6", out ) )
		return( -1 );

	return( 0 );
}
コード例 #2
0
gint
mono_w32socket_disconnect (SOCKET sock, gboolean reuse)
{
	LPFN_DISCONNECTEX disconnect;
	LPFN_TRANSMITFILE transmit_file;
	DWORD output_bytes;
	gint ret;

	/* Use the SIO_GET_EXTENSION_FUNCTION_POINTER to determine
	 * the address of the disconnect method without taking
	 * a hard dependency on a single provider
	 *
	 * For an explanation of why this is done, you can read the
	 * article at http://www.codeproject.com/internet/jbsocketserver3.asp
	 *
	 * I _think_ the extension function pointers need to be looked
	 * up for each socket.
	 *
	 * FIXME: check the best way to store pointers to functions in
	 * managed objects that still works on 64bit platforms. */

	GUID disconnect_guid = WSAID_DISCONNECTEX;
	ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &disconnect_guid, sizeof (GUID), &disconnect, sizeof (LPFN_DISCONNECTEX), &output_bytes, NULL, NULL);
	if (ret == 0) {
		if (!disconnect (sock, NULL, reuse ? TF_REUSE_SOCKET : 0, 0))
			return WSAGetLastError ();

		return 0;
	}

	GUID transmit_file_guid = WSAID_TRANSMITFILE;
	ret = WSAIoctl (sock, SIO_GET_EXTENSION_FUNCTION_POINTER, &transmit_file_guid, sizeof (GUID), &transmit_file, sizeof (LPFN_TRANSMITFILE), &output_bytes, NULL, NULL);
	if (ret == 0) {
		if (!transmit_file (sock, NULL, 0, 0, NULL, NULL, TF_DISCONNECT | (reuse ? TF_REUSE_SOCKET : 0)))
			return WSAGetLastError ();

		return 0;
	}

	return ERROR_NOT_SUPPORTED;
}
コード例 #3
0
ファイル: HSDEMO2.C プロジェクト: mcyril/ravel-ftn
int hslink_input(user_data_rec *udta,           /* current user data record */
                 int argc,                      /* argument count */
                 char *argv[])                  /* argument values */
{
        /* allocate application workspace if needed */
        if (udta->substt == 0)
        {
                udta->appws = (workspace_rec*)mem_alloc(sizeof(workspace_rec));
                if (udta->appws == 0)
                {
                        cprintf("Cannot allocate workspace for user %d!\r\n",usrnum);
                        return 0;
                }
        }

        /* current workspace to application workspace for this user */
        current_hsws = udta->appws;

        /* process current substate */
        switch (udta->substt)
        {
        case 0:
                if (top_init())
                {
                        udta->substt = 0;
                        break;
                }

                set_defaults();

                if (argc == 1)
                {
                        usage("No command line given\r\n","");
                        udta->substt = 0;
                        break;
                }

                if (process_options(argc,argv))
                {
                        usage("No command line given\r\n","");
                        udta->substt = 0;
                        break;
                }

                ComOpen();

                WS.Option.ComSpeed = ComGetSpeed();
                if (!WS.Option.EffSpeed)
                        WS.Option.EffSpeed = WS.Option.ComSpeed;

                /* we're now ready for SlowHandshake to work */
                WS.IoLevel = 0;

                /* allocate up to 10k for file buffers, but no more */
                WS.buffer_sizes = mem_avail()-1000>10240: 10240:mem_avail()-1000;

                /* display opening screen */
                prepare_display();
                process_filespecs(argc,argv);

                /* verify hardware handshake status */
                if (!ComGetCts() && !WS.Option.ForceCts)
                {
                        cprintf("CTS signal missing!  Please use -HC or -FC option.\r\n");
                        WS.Option.CtsHandshake = 0;
                }

                udta->substt = 1;
                break;

        case 1:
                /* wait for ready handshake with remote */
                service_receive();
                udta->substt = wait_for_ready()? 1:2;
                break;

        case 2:
                /* select first file in batch and begin transmit */
                udta->curnode = WS.first_send;
                udta->substt = 3;
                break;

        case 3:
                /* end of batch? change to state 4 */
                if (udta->curnode == NULL)
                {
                        udta->substt = 4;
                        PSEND("%d file%s transmitted.\r\n",WS.files_sent,
                                                           WS.files_sent==1?"":"s");
                        break;
                }

                service_receive();
                if (transmit_file(udta->curnode->name))
                        break;          /* remain in state 3 */

                /* advance to next file in the batch */
                udta->curnode = udta->curnode->next;
                break;

        case 4:
                /* wait for remaining receive activity to terminate */
                service_receive();
                udta->substt = finish_receive()? 4:5;
                break;

        case 5:
                /* close down link */
                udta->substt = terminate_link()? 5:6;
                break;

        case 6:
                /* process exit codes */
                if (ComCarrierLost())
                        set_cancel_link(CANCEL_CARRIER_LOST);
                if ((WS.files_received+WS.files_sent) ==0)
                        set_cancel_link(CANCEL_NO_FILES);

                ComClose();
                close_display();
                cprintf("HS/Link finished! (t:%d r:%d)",WS.files_sent,WS.files_received);
                cprintf("  Exit code = %d\r\n",(int)WS.cancel_link);
                udta->substt = 0;
                break;
        }

        /* if substt is 0 we are done and need to free the workspace */
        if (udta->substt == 0)
        {
                current_hsws = 0;
                mem_free(udta->appws);
                udta->appws = 0;
        }

        /* otherwise we need more calls- return non 0 */
        return udta->substt;
}
コード例 #4
0
int Trick::VariableServerThread::send_sie_top_level_objects() {
    sie_top_level_objects_print_xml() ;
    return transmit_file(std::string(command_line_args_get_default_dir()) + "/" + "S_sie_top_level_objects.xml") ;
}
コード例 #5
0
int Trick::VariableServerThread::send_sie_enum() {
    sie_enum_attr_map_print_xml() ;
    return transmit_file(std::string(command_line_args_get_default_dir()) + "/" + "S_sie_enum.xml") ;
}
コード例 #6
0
int Trick::VariableServerThread::send_sie_resource() {
    sie_print_xml() ;
    return transmit_file(std::string(command_line_args_get_default_dir()) + "/S_sie.resource") ;
}
コード例 #7
0
int Trick::VariableServerThread::send_file(std::string file_name) {
    return transmit_file(file_name) ;
}