Beispiel #1
0
static int end_hline(void)
{
    h_ptr->col = col;
    h_ptr->fptr = h_ptr;
    write_boundary(h_ptr);
    h_ptr = NULPTR;

    return 0;
}
Beispiel #2
0
static int end_vline(void)
{
    v_list[col]->row = row;
    v_list[col]->fptr = v_list[col];
    write_boundary(v_list[col]);
    v_list[col] = NULPTR;

    return 0;
}
void
mexFunction(int nlhs, mxArray *plhs[],
            int nrhs, const mxArray *prhs[])
{
   FILE *fob;
   mxArray *internal;
   element_t *pe;
   double *pd;
   int compound;
   double uu_to_dbu;

   /* check argument number */
   if (nrhs != 4) {
      mexErrMsgTxt("gds_write_element :  4 input arguments expected.");
   }
   
   /* get file handle argument */
   fob = get_file_ptr((mxArray *)prhs[0]);

   /* get unit conversion factor user units --> database units */
   pd = (double *)mxGetData(prhs[2]);
   uu_to_dbu = pd[0];

   /* decide what to do */
   if ( !get_field_ptr((mxArray *)prhs[1], "internal", &internal) )
      mexErrMsgTxt("gds_write_element :  missing internal data field.");
   pe = (element_t *)mxGetData(internal);

   switch (pe->kind) {
     
      case GDS_BOUNDARY:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_boundary(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_boundary(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_PATH:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_path(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_path(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_SREF:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_sref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_sref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_AREF:
	 write_aref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_TEXT:
	 write_text(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_NODE:
	 write_node(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_BOX:
	 write_box(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      default:
	 mexErrMsgTxt("gds_write_element :  unknown element type.");
   }
}
Beispiel #4
0
static int update_list(int i)
{
    struct COOR *new_ptr, *new_ptr1, *new_ptr2, *new_ptr3;
    double right, left;

    switch (i) {
    case 0:
	/* Vertical line - Just update width information */
	/* update_width(a_list + v_list[col]->left,0); */
	tl_area = v_list[col]->left;
	break;
    case 1:
	/* Bottom right corner - Point in middle of new line */
	/* (growing) <- ptr2 -><- ptr1 -><- ptr3 -> (growing) */
	/*            (?, col) (row, col) (row, ?) */
	new_ptr1 = get_ptr();	/* corner point */
	new_ptr2 = get_ptr();	/* downward-growing point */
	new_ptr3 = get_ptr();	/* right-growing point */
	new_ptr1->bptr = new_ptr2;
	new_ptr1->fptr = new_ptr3;
	new_ptr2->bptr = new_ptr3->bptr = new_ptr1;

	/* if(G_is_c_null_value(&tl_area)) {
	   new_ptr1->left = new_ptr2->right = new_ptr3->left = 0;
	   assign_area(tl,1);
	   } else {
	 */
	new_ptr1->left = new_ptr2->right = new_ptr3->left = tl_area;
	new_ptr1->right = new_ptr2->left = new_ptr3->right = area_num;

	assign_area(br, 1);
	update_width(a_list_old, 1);
	v_list[col] = new_ptr2;
	h_ptr = new_ptr3;
	break;
    case 3:
	/* Bottom left corner - Add point to line already under construction */
	/* (fixed) -><- original h_ptr -><- new_ptr -> (growing) */
	/*                (row, col)       (?, col) */
	tl_area = h_ptr->left;
	new_ptr = get_ptr();	/* downward-growing point */
	h_ptr->col = col;
	h_ptr->fptr = new_ptr;
	new_ptr->bptr = h_ptr;
	new_ptr->left = h_ptr->left;
	new_ptr->right = h_ptr->right;

	/* update_width(a_list + new_ptr->left,3); */
	v_list[col] = new_ptr;
	h_ptr = NULPTR;
	break;
    case 4:
	/* Top left corner - Join two lines already under construction */
	/* (fixed) -><- original v_list -><- (fixed) */
	/*                 (row, col) */
	tl_area = v_list[col]->left;
	equiv_areas(h_ptr->left, v_list[col]->right);
	equiv_areas(h_ptr->right, v_list[col]->left);
	v_list[col]->row = row;	/* keep downward-growing point */
	v_list[col]->fptr = h_ptr->bptr;	/*   and join it to predecessor */
	h_ptr->bptr->fptr = v_list[col];	/*   of right-growing point */
	G_free(h_ptr);		/* right-growing point disappears */
	h_ptr = NULPTR;		/* turn loose of pointers */
	write_boundary(v_list[col]);	/* try to write line */
	v_list[col] = NULPTR;	/* turn loose of pointers */
	break;
    case 5:
	/* Top right corner - Add point to line already under construction */
	/* (fixed) -><- original v_list -><- new_ptr -> (growing) */
	/*                 (row, col)        (row, ?) */
	new_ptr = get_ptr();	/* right-growing point */
	v_list[col]->row = row;
	new_ptr->bptr = v_list[col];
	new_ptr->left = v_list[col]->left;
	new_ptr->right = v_list[col]->right;
	v_list[col]->fptr = new_ptr;
	h_ptr = new_ptr;
	v_list[col] = NULPTR;
	break;
    case 6:
	/* T upward - End one vertical and one horizontal line */
	/*            Start horizontal line */
	v_list[col]->node = h_ptr->node = 1;
	left = v_list[col]->left;
	right = h_ptr->right;
	end_vline();
	end_hline();
	start_hline();
	h_ptr->bptr->node = 1;	/* where we came from is a node */
	h_ptr->left = h_ptr->bptr->left = left;
	h_ptr->right = h_ptr->bptr->right = right;
	break;
    case 7:
	/* T downward - End horizontal line */
	/*              Start one vertical and one horizontal line */
	h_ptr->node = 1;
	right = h_ptr->right;
	left = h_ptr->left;
	end_hline();
	start_hline();
	start_vline();
	h_ptr->bptr->node = v_list[col]->bptr->node = 1;
	h_ptr->left = h_ptr->bptr->left = left;
	h_ptr->right = h_ptr->bptr->right = v_list[col]->left =
	    v_list[col]->bptr->left = area_num;
	assign_area(br, 7);
	update_width(a_list_old, 7);
	v_list[col]->right = v_list[col]->bptr->right = right;
	break;
    case 8:
	/* T left - End one vertical and one horizontal line */
	/*          Start one vertical line */
	tl_area = v_list[col]->left;
	h_ptr->node = v_list[col]->node = 1;
	right = h_ptr->right;
	left = v_list[col]->left;
	end_vline();
	end_hline();
	start_vline();
	v_list[col]->bptr->node = 1;	/* where we came from is a node */
	v_list[col]->left = v_list[col]->bptr->left = left;
	v_list[col]->right = v_list[col]->bptr->right = right;
	/* update_width(a_list + v_list[col]->left,8); */
	break;
    case 9:
	/* T right - End one vertical line */
	/*           Start one vertical and one horizontal line */
	v_list[col]->node = 1;
	right = v_list[col]->right;
	left = v_list[col]->left;
	end_vline();
	start_vline();
	start_hline();
	v_list[col]->bptr->node = h_ptr->bptr->node = 1;
	h_ptr->left = h_ptr->bptr->left = left;
	h_ptr->right = h_ptr->bptr->right = v_list[col]->left =
	    v_list[col]->bptr->left = area_num;
	assign_area(br, 9);
	update_width(a_list_old, 9);
	v_list[col]->right = v_list[col]->bptr->right = right;
	break;
    case 10:
	/* Cross - End one vertical and one horizontal line */
	/*         Start one vertical and one horizontal line */
	v_list[col]->node = h_ptr->node = 1;
	left = v_list[col]->left;
	right = h_ptr->right;
	end_vline();
	end_hline();
	start_vline();
	start_hline();
	v_list[col]->bptr->node = h_ptr->bptr->node = 1;
	h_ptr->left = h_ptr->bptr->left = left;
	v_list[col]->left = v_list[col]->bptr->left = h_ptr->right =
	    h_ptr->bptr->right = area_num;
	assign_area(br, 10);
	update_width(a_list_old, 10);
	v_list[col]->right = v_list[col]->bptr->right = right;
	break;
    }				/* switch */

    return 0;
}				/* update_list */
Beispiel #5
0
int mail_SendMessage( KMail mail, KMsg msg )
{
    Pair addr;
    int rc = 1;
    string out = NULL;
    string related = NULL;
    string multipart = NULL;
    char mp_boundary[36];
    char r_boundary[36];

    if( !smtp_MAIL_FROM( mail->smtp, A_EMAIL(msg->from) ) )
    {
        rc = 0;
        goto pmend;
    }

    addr = lfirst( msg->to );
    while( addr )
    {
        if( !smtp_RCPT_TO( mail->smtp, A_EMAIL(addr) ) )
        {
            rc = 0;
            goto pmend;
        }
        addr = lnext( msg->to );
    }
    addr = lfirst( msg->cc );
    while( addr )
    {
        if( !smtp_RCPT_TO( mail->smtp, A_EMAIL(addr) ) )
        {
            rc = 0;
            goto pmend;
        }
        addr = lnext( msg->cc );
    }

    addr = lfirst( msg->bcc );
    while( addr )
    {
        if( !smtp_RCPT_TO( mail->smtp, A_EMAIL(addr) ) )
        {
            rc = 0;
            goto pmend;
        }
        addr = lnext( msg->bcc );
    }

    out = msg_CreateHeaders( msg );
    if( !out )
    {
        rc = 0;
        goto pmend;
    }

    if( mail->flags & KMAIL_VERBOSE_MSG )
    {
        fprintf( stderr, "%s", sstr( out ) );
    }

    if( !smtp_DATA( mail->smtp ) || !smtp_write( mail->smtp, sstr( out ) ) )
    {
        rc = 0;
        goto pmend;
    }

    sdel( out );
    out = msg_CreateBody( msg );
    if( !out )
    {
        rc = 0;
        goto pmend;
    }

    if( mail->flags & KMAIL_VERBOSE_MSG )
    {
        fprintf( stderr, "%s", sstr( out ) );
    }

    if( msg->efiles->size )
    {
        mimeMakeBoundary( r_boundary );
        related = sfromchar( "Content-Type: multipart/related; boundary=\"" );
        if( !related || !xscatc( related, r_boundary, "\"\r\n\r\n", NULL ) )
        {
            rc = 0;
            goto pmend;
        }
    }

    if( msg->afiles->size )
    {
        mimeMakeBoundary( mp_boundary );
        multipart = sfromchar( "Content-Type: multipart/mixed; boundary=\"" );
        if( !multipart
                || !xscatc( multipart, mp_boundary, "\"\r\n\r\n", NULL ) )
        {
            rc = 0;
            goto pmend;
        }
        if( !smtp_write( mail->smtp, sstr( multipart ) ) )
        {
            rc = 0;
            goto pmend;
        }
        if( slen(out) && !write_boundary( mail->smtp, mp_boundary ) )
        {
            rc = 0;
            goto pmend;
        }

        if( related )
        {
            if( !smtp_write( mail->smtp, sstr( related ) )
                    || !write_boundary( mail->smtp, r_boundary )
                    || !smtp_write( mail->smtp, sstr( out ) )
                    || !mail_EmbedFiles( mail, msg, r_boundary )
                    || !write_boundary_end( mail->smtp, r_boundary ) )
            {
                rc = 0;
                goto pmend;
            }
        }

        if( !mail_AttachFiles( mail, msg, mp_boundary )
                || !write_boundary_end( mail->smtp, mp_boundary ) )
        {
            rc = 0;
            goto pmend;
        }
    }
    else if( msg->efiles->size )
    {
        if( !smtp_write( mail->smtp, sstr( related ) )
                || !write_boundary( mail->smtp, r_boundary )
                || !smtp_write( mail->smtp, sstr( out ) )
                || !mail_EmbedFiles( mail, msg, r_boundary )
                || !write_boundary_end( mail->smtp, r_boundary ) )
        {
            rc = 0;
            goto pmend;
        }
    }
    else
    {
        if( slen( out ) && !smtp_write( mail->smtp, sstr( out ) ) )
        {
            rc = 0;
            goto pmend;
        }
    }

    pmend: sdel( out );
    sdel( related );
    sdel( multipart );
    smtp_END_DATA( mail->smtp );
    return rc;
}