Esempio n. 1
0
File: com.c Progetto: amery/clip-itk
int
clip_COM_INIT(ClipMachine * mp)
{
	v24_port_t *gz;
	int ret = -1, *err;
	int fd = _clip_parni(mp, 1);
	int baud = 9600, data = 8, stop = 1;
	char *parity = "N";

	if (fd < 1 || fd > 32)
		return EG_ARG;
	fd = keys[fd];

	gz = (v24_port_t *) _clip_fetch_c_item(mp, fd, _C_ITEM_TYPE_COMPORT);

	if (!gz)
		return EG_ARG;

	if (_clip_parinfo(mp, 2) == NUMERIC_t)
		baud = _clip_parni(mp, 2);
	if (_clip_parinfo(mp, 3) == CHARACTER_t)
		parity = _clip_parc(mp, 3);
	if (_clip_parinfo(mp, 4) == NUMERIC_t)
		data = _clip_parni(mp, 4);
	if (_clip_parinfo(mp, 5) == NUMERIC_t)
		stop = _clip_parni(mp, 5);

	err = _clip_fetch_item(mp, HASH_ferror);

	ret = v24SetParameters(gz, baud_val(baud), data_val(data), parity_val(parity));

	_clip_retl(mp, ret ? 0 : 1);

	return 0;
}
Esempio n. 2
0
/* Set the pixmap in a node. */
int
clip_GTK_CTREENODESETPIXTEXT(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	gint        column = _clip_parni(cm,3);
	gchar        *text = _clip_parc(cm,4);
	gint       spacing = _clip_parni(cm,5);
	C_widget  *cpixmap = _fetch_cwidget(cm,_clip_spar(cm,6));
	GdkPixmap *pixmap=NULL; GdkBitmap *mask=NULL;
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t); CHECKOPT(4,CHARACTER_t); CHECKOPT(5,NUMERIC_t);
	CHECKOPT2(6,MAP_t,NUMERIC_t); CHECKCWIDOPT(cpixmap,GTK_IS_PIXMAP);
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	if (_clip_parinfo(cm,4)==UNDEF_t) text = "";
	if (cpixmap)
	{
		pixmap = GTK_PIXMAP(cpixmap->widget)->pixmap;
		mask = GTK_PIXMAP(cpixmap->widget)->mask;
	}
	LOCALE_TO_UTF(text);
	gtk_ctree_node_set_pixtext(GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object), column-1,
			text,spacing,pixmap,mask);
	FREE_TEXT(text);
	return 0;
err:
	return 1;
}
Esempio n. 3
0
int
clip_DATE(ClipMachine * ClipMachineMemory)
{
   int yy, mm, dd;

#ifdef _WIN32
   SYSTEMTIME st;

   GetLocalTime(&st);
   yy = st.wYear;
   mm = st.wMonth;
   dd = st.wDay;
#else
   struct tm *sysTime;

   sysTime = _clip_sysdate();
   yy = sysTime->tm_year + 1900;
   mm = sysTime->tm_mon + 1;
   dd = sysTime->tm_mday;
   free(sysTime);
#endif

   if (_clip_parinfo(ClipMachineMemory, 1) == NUMERIC_type_of_ClipVarType)
      yy = _clip_parni(ClipMachineMemory, 1);
   if (_clip_parinfo(ClipMachineMemory, 2) == NUMERIC_type_of_ClipVarType)
      mm = _clip_parni(ClipMachineMemory, 2);
   if (_clip_parinfo(ClipMachineMemory, 3) == NUMERIC_type_of_ClipVarType)
      dd = _clip_parni(ClipMachineMemory, 3);

   _clip_retdc(ClipMachineMemory, yy, mm, dd);
   return 0;
}
Esempio n. 4
0
/* Sets the packing parameters for the bookmark of child.
 * See GtkBoxPackStart for the exact meanings. */
int
clip_GTK_NOTEBOOKSETTABLABELPACKING(ClipMachine * ClipMachineMemory)
{
   C_widget *cntb = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cchild = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   gboolean  expand = _clip_parl(ClipMachineMemory, 3);

   gboolean  fill = _clip_parl(ClipMachineMemory, 4);

   guint     packing_type = _clip_parni(ClipMachineMemory, 5);

   CHECKCWID(cntb, GTK_IS_NOTEBOOK);
   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cchild, GTK_IS_WIDGET);
   CHECKOPT(3, LOGICAL_type_of_ClipVarType);
   CHECKOPT(4, LOGICAL_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType)
      expand = TRUE;
   if (_clip_parinfo(ClipMachineMemory, 4) == UNDEF_type_of_ClipVarType)
      fill = TRUE;
   gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(cntb->widget), cchild->widget, expand, fill, packing_type);
   return 0;
 err:
   return 1;
}
Esempio n. 5
0
int
clip_CHMOD(ClipMachine * ClipMachineMemory)
{
   int lp = 0, *err = NULL;

   char buf[PATH_MAX];

   char *fname = _clip_parc(ClipMachineMemory, 1);

   _clip_retl(ClipMachineMemory, 1);
   err = _clip_fetch_item(ClipMachineMemory, HASH_ferror);
   *err = 0;

   if (_clip_parinfo(ClipMachineMemory, 2) == CHARACTER_type_of_ClipVarType)
      lp = _clip_fileStrModeToNumMode(_clip_parc(ClipMachineMemory, 2));
   if (_clip_parinfo(ClipMachineMemory, 2) == NUMERIC_type_of_ClipVarType)
      lp = _clip_parni(ClipMachineMemory, 2);
   if (fname == NULL || lp == 0)
   {
      _clip_retl(ClipMachineMemory, 0);
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "CHMOD");
   }

   _clip_translate_path(ClipMachineMemory, fname, buf, sizeof(buf));
   if (chmod(buf, lp) == 0)
      return 0;

   _clip_retl(ClipMachineMemory, 0);
   *err = errno;

   return 0;
}
Esempio n. 6
0
/* Moves a child of a GtkFixed container to the given position. */
int
clip_GTK_FIXEDMOVE(ClipMachine * ClipMachineMemory)
{
   C_widget *cfix = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cwid = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   gint      x = _clip_parni(ClipMachineMemory, 3);

   gint      y = _clip_parni(ClipMachineMemory, 4);

   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cfix, GTK_IS_FIXED);
   CHECKCWID(cwid, GTK_IS_WIDGET);
   if (_clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType)
      x = cwid->widget->allocation.x;
   if (_clip_parinfo(ClipMachineMemory, 4) == UNDEF_type_of_ClipVarType)
      y = cwid->widget->allocation.y;
   gtk_fixed_move(GTK_FIXED(cfix->widget), cwid->widget, x, y);

   return 0;
 err:
   return 1;
}
Esempio n. 7
0
int
clip_GTK_ALIGNMENTSET(ClipMachine * ClipMachineMemory)
{
   C_widget *cali = _fetch_cw_arg(ClipMachineMemory);

   gfloat    xalign = _clip_parnd(ClipMachineMemory, 2);

   gfloat    yalign = _clip_parnd(ClipMachineMemory, 3);

   gfloat    xscale = _clip_parnd(ClipMachineMemory, 4);

   gfloat    yscale = _clip_parnd(ClipMachineMemory, 5);

   CHECKCWID(cali, GTK_IS_ALIGNMENT);
   CHECKOPT(2, NUMERIC_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKOPT(4, NUMERIC_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);

   if (_clip_parinfo(ClipMachineMemory, 4) == UNDEF_type_of_ClipVarType)
      xscale = 1;
   if (_clip_parinfo(ClipMachineMemory, 5) == UNDEF_type_of_ClipVarType)
      yscale = 1;

   gtk_alignment_set(GTK_ALIGNMENT(cali->widget), xalign, yalign, xscale, yscale);
   return 0;
 err:
   return 1;
}
Esempio n. 8
0
int
clip_BITTOC(ClipMachine * mp)
{
	unsigned int Num = _clip_parni(mp, 1);
	int LenPattern;
	char *BitPattern = _clip_parcl(mp, 2, &LenPattern);
	char *p, res[] = "                ";
	unsigned int Mask;
	int Len = _clip_parinfo(mp, 0), RealLen;
	int t1 = _clip_parinfo(mp, 1);
	int t2 = _clip_parinfo(mp, 2);

	if (Len < 2 || t1 != NUMERIC_t || t2 != CHARACTER_t)
	{
		_clip_retc(mp, "");
		return _clip_trap_err(mp, EG_ARG, 0, 0, __FILE__, __LINE__, "BITTOC");
	}

	if (LenPattern > 16)
		LenPattern = 16;
	if (_clip_parl(mp, 3))
	{
		for (RealLen = LenPattern, Len = 0, Mask = 1 << (LenPattern - 1); Len < LenPattern; Mask >>= 1, Len++)
			if (Num & Mask)
				res[Len] = BitPattern[Len];
	}
	else
	{
		for (RealLen = 0, p = res, Len = 0, Mask = 1 << (LenPattern - 1); Len < LenPattern; Mask >>= 1, Len++)
Esempio n. 9
0
/* Sets default size for window */
int
clip_GTK_WINDOWSETDEFAULTSIZE(ClipMachine * cm)
{
	C_widget *cwin  = _fetch_cw_arg(cm);
	gint      width = _clip_parni(cm,2);
	gint     height = _clip_parni(cm,3);
	GtkArg arg;
	CHECKCWID(cwin,GTK_IS_WINDOW);
	CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t);
	if (_clip_parinfo(cm,2)==UNDEF_t)
	{
		arg.type = GTK_TYPE_INT; arg.name = "width";
		gtk_widget_get(cwin->widget, &arg);
		if (arg.d.int_data == -1) arg.d.int_data = cwin->widget->requisition.width;
		width = arg.d.int_data;
	}
	if (_clip_parinfo(cm,3)==UNDEF_t)
	{
		arg.type = GTK_TYPE_INT; arg.name = "height";
		gtk_widget_get(cwin->widget, &arg);
		if (arg.d.int_data == -1) arg.d.int_data = cwin->widget->requisition.height;
		height = arg.d.int_data;
	}
	gtk_window_set_default_size(GTK_WINDOW(cwin->widget), width, height);
	return 0;
err:
	return 1;
}
Esempio n. 10
0
CLIP_DLLEXPORT C_object*
_fetch_co_arg(ClipMachine* cm)
{
	C_object* cobj;

	if (_clip_parinfo(cm,1)==NUMERIC_t)
	{
		cobj = (C_object*)_clip_fetch_c_item(cm,_clip_parni(cm,1),
			_C_ITEM_TYPE_WIDGET);
	}
	else
	{
		if (_clip_parinfo(cm,1)==MAP_t)
		{
			double h;
			_clip_mgetn(cm, _clip_spar(cm,1), HASH_HANDLE, &h);
			cobj = (C_object *) _clip_fetch_c_item(cm, (int) h,
				_C_ITEM_TYPE_WIDGET);
		}
		else
		{
			_clip_trap_err(cm,EG_ARG,0,0,"CLIP_GTK_SYSTEM",
				EG_ARG,"Bad object descriptor");
			return NULL;
		}
	}
	if(!cobj)
	{
		_clip_trap_err(cm,EG_ARG,0,0,"CLIP_GTK_SYSTEM",
			EG_ARG,"Bad object descriptor");
		return NULL;
	}
	return cobj;
}
Esempio n. 11
0
int
clip_SCREENSTRING(ClipMachine * ClipMachineMemory)
{
   int top = _clip_parni(ClipMachineMemory, 1);

   int left = _clip_parni(ClipMachineMemory, 2);

   int l = _clip_parni(ClipMachineMemory, 3);

   Screen *sp = ClipMachineMemory->screen;

   char *r;

   if ((_clip_parinfo(ClipMachineMemory, 1) != NUMERIC_type_of_ClipVarType) || (top < 0) || (top >= sp->base->Lines))
      top = sp->y;
   if ((_clip_parinfo(ClipMachineMemory, 2) != NUMERIC_type_of_ClipVarType) || (left < 0) || (left >= sp->base->Columns))
      left = sp->x;
   if ((_clip_parinfo(ClipMachineMemory, 3) != NUMERIC_type_of_ClipVarType) || (l < 1) || (left + l > sp->base->Columns))
      l = sp->base->Columns - left;

   r = calloc(1, l + 1);
   memcpy(r, sp->chars[top] + left, l);
   _clip_retcn_m(ClipMachineMemory, r, l);
   return 0;
}
Esempio n. 12
0
/* Inserts in notebook a new page whose content is child, and whose bookmark
 * is tab_label. The page is inserted just before the page number position,
 * starting with 0. If position is out of bounds, it is assumed to be the
 * current number of pages.  */
int
clip_GTK_NOTEBOOKINSERTPAGE(ClipMachine * cm)
{
	C_widget   *cntb = _fetch_cw_arg(cm);
	C_widget *cchild = _fetch_cwidget(cm,_clip_spar(cm,2));
	C_widget *clabel; GtkWidget *label;
	gint    position = _clip_parni(cm,4);
	CHECKCWID(cntb,GTK_IS_NOTEBOOK);
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cchild,GTK_IS_WIDGET);
	CHECKARG3(3,MAP_t,NUMERIC_t,CHARACTER_t);
	CHECKOPT(4,NUMERIC_t);
	if (_clip_parinfo(cm,3)==CHARACTER_t) {
		char   * caption = _clip_parc(cm, 3);
		LOCALE_TO_UTF(caption);
		label = gtk_label_new_with_mnemonic(caption);
		FREE_TEXT(caption);
	}
	else
	{
		clabel = _fetch_cwidget(cm,_clip_spar(cm,3));
		CHECKCWID(clabel,GTK_IS_WIDGET);
		if (clabel) label = clabel->widget;
	}
	if (_clip_parinfo(cm,4)==UNDEF_t) position = 1;
	gtk_notebook_insert_page(GTK_NOTEBOOK(cntb->widget), cchild->widget, label, position-1);
	return 0;
err:
	return 1;
}
Esempio n. 13
0
/*
  winbuf_copy(scr_buf,top1,left1,height1,width1,dest_buf,top2,left2) -
  ����� ������ scr_buf, ������ ������
  top1,left1,height1,width1 �dest_buf � ������top2,left2
*/
int
clip_WINBUF_COPY(ClipMachine * ClipMachineMemory)
{
   int no;

   WinBuf *wp, *d_wp;

   int top, left, hi, wi, d_top, d_left;

   int x, y, d_y, d_x;

   if (ClipMachineMemory->argc < 6)
      return EG_ARG;

   no = _clip_parni(ClipMachineMemory, 1);
   wp = find_WinBuf(no);
   if (!wp)
      return EG_ARG;

   no = _clip_parni(ClipMachineMemory, 6);
   d_wp = find_WinBuf(no);
   if (!d_wp)
      return EG_ARG;

   top = _clip_parni(ClipMachineMemory, 2);
   left = _clip_parni(ClipMachineMemory, 3);

   if (_clip_parinfo(ClipMachineMemory, 4) == NUMERIC_type_of_ClipVarType)
      hi = _clip_parni(ClipMachineMemory, 4);
   else
      hi = wp->hi;
   if (hi > wp->hi)
      hi = wp->hi;

   if (_clip_parinfo(ClipMachineMemory, 5) == NUMERIC_type_of_ClipVarType)
      wi = _clip_parni(ClipMachineMemory, 5);
   else
      wi = wp->wi;
   if (wi > wp->wi)
      wi = wp->wi;

   d_top = _clip_parni(ClipMachineMemory, 7);
   d_left = _clip_parni(ClipMachineMemory, 8);

   for (y = top, d_y = d_top; y < hi && d_y < d_wp->hi; y++, d_y++)
   {
      if (y < 0 || d_y < 0)
	 continue;
      for (x = left, d_x = d_left; x < wi && d_x < d_wp->wi; x++, d_x++)
      {
	 if (x < 0 || d_x < 0)
	    continue;
	 d_wp->chars[d_y][d_x] = wp->chars[y][x];
	 d_wp->colors[d_y][d_x] = wp->colors[y][x];
	 d_wp->attrs[d_y][d_x] = wp->attrs[y][x];
      }
   }

   return 0;
}
Esempio n. 14
0
/* Inserts in notebook a new page whose content is child, whose bookmark is
 * tab_label, and whose menu label is menu_label. The page is inserted just
 * before the page number position, starting with 0. If position is out of
 * bounds, it is assumed to be the current number of pages. */
int
clip_GTK_NOTEBOOKINSERTPAGEMENU(ClipMachine * ClipMachineMemory)
{
   C_widget *cntb = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cchild = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   C_widget *ctab_label;

   GtkWidget *tab_label;

   C_widget *cmenu_label;

   GtkWidget *menu_label;

   gint      position = _clip_parni(ClipMachineMemory, 5);

   CHECKCWID(cntb, GTK_IS_NOTEBOOK);
   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cchild, GTK_IS_WIDGET);
   CHECKARG3(3, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType);
   CHECKARG3(4, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType);
   CHECKOPT(5, NUMERIC_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 3) == CHARACTER_type_of_ClipVarType)
    {
       char     *caption = _clip_parc(ClipMachineMemory, 3);

       LOCALE_TO_UTF(caption);
       tab_label = gtk_label_new(caption);
       FREE_TEXT(caption);
    }
   else
    {
       ctab_label = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3));
       CHECKCWID(ctab_label, GTK_IS_WIDGET);
       if (ctab_label)
	  tab_label = ctab_label->widget;
    }
   if (_clip_parinfo(ClipMachineMemory, 4) == CHARACTER_type_of_ClipVarType)
    {
       char     *menu_text = _clip_parc(ClipMachineMemory, 4);

       LOCALE_TO_UTF(menu_text);
       menu_label = gtk_label_new(menu_text);
       FREE_TEXT(menu_text);
    }
   else
    {
       cmenu_label = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 4));
       CHECKCWID(cmenu_label, GTK_IS_WIDGET);
       if (cmenu_label)
	  menu_label = cmenu_label->widget;
    }
   if (_clip_parinfo(ClipMachineMemory, 5) == UNDEF_type_of_ClipVarType)
      position = 1;
   gtk_notebook_insert_page_menu(GTK_NOTEBOOK(cntb->widget), cchild->widget, tab_label, menu_label, position - 1);
   return 0;
 err:
   return 1;
}
Esempio n. 15
0
int
clip_GDK_WINDOWGETPOINTER(ClipMachine * cm)
{
//	C_object    *cwin = _fetch_co_arg(cm);
	C_widget    *cwin = _fetch_cw_arg(cm);
	gint            x = _clip_parni(cm,2);
	gint            y = _clip_parni(cm,3);
	gint * px, * py;
	GdkWindow *win = NULL;
	GdkModifierType mask;

	CHECKCWID(cwin,GTK_IS_WIDGET);
	CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t);
	px = _clip_parinfo(cm,2) == UNDEF_t ? NULL : &x;
	py = _clip_parinfo(cm,3) == UNDEF_t ? NULL : &y;

	if (cwin && cwin->widget) win = cwin->widget->window;

	gdk_window_get_pointer(win, px, py, &mask);
	_clip_storni(cm,*px,2,0);
	_clip_storni(cm,*py,3,0);
	_clip_storni(cm,mask,4,0);

	return 0;
err:
	return 1;
}
Esempio n. 16
0
/* TREE_TYPE_PIXBUF                                                */
int
/******************************************************************************
* gtk_ListStoreNew(map, ncolumns, type1, ...)
******************************************************************************/
clip_GTK_LISTSTORENEW(ClipMachine * cm)
{
	ClipVar * cv   = _clip_spar(cm, 1);
	gint ncolumns  = _clip_parni(cm, 2);
	ClipArrVar *cvcol = (ClipArrVar *)_clip_vptr(_clip_spar(cm, 3));
        ClipVar *utypes;
        GType types[ncolumns];
	int i;
	long d;

        GtkListStore *list;
        C_object *clist;

	CHECKOPT(1,MAP_t);
	CHECKARG(2,NUMERIC_t);
        //CHECKARG2(3, NUMERIC_t, ARRAY_t);

	memset(types, 0, sizeof(types));
        utypes = NEW(ClipVar);

       	if ( _clip_parinfo(cm,3)==ARRAY_t && cvcol->count != ncolumns ) return 1;
	if ( _clip_parinfo(cm,3) != UNDEF_t ) // defined column types as parameters or in array
		__list_store_set_types(cm, ncolumns, types, utypes);
	else  { // if third parameter is empty - use column with G_TYPE_STRING type
		ClipVar type;
		d = ncolumns;
		memset(&type, 0, sizeof(type));
		type.t.type = NUMERIC_t;
		type.n.d = 0;
		_clip_array(cm, utypes, 1, &d);
		for ( i=0, d=0; i<ncolumns; i++, d++ )
                {
			types[i] = G_TYPE_STRING;
                	_clip_aset(cm, utypes, &type, 1, &d);
                }
                _clip_destroy(cm, &type);
	}

	list = gtk_list_store_newv(ncolumns, types);
	if (list)
	{
		clist = _list_get_cobject(cm,list);
		if (!clist) clist = _register_object(cm,list,GTK_TYPE_LIST_STORE,cv,__list_store_destroy);
		if (clist)
		{
			_clip_madd(cm, &clist->obj, HASH_UTYPES, utypes);
			_clip_mclone(cm,RETPTR(cm),&clist->obj);
                }
	}

	free(utypes);
	return 0;
err:
	return 1;
}
Esempio n. 17
0
int
clip_UDPSENDTO(ClipMachine *mp)
// UDPSENDTO( nCF, cIPaddr, nPort, cMsg, [nLen], [nTimeout] )
{
	int fd = _clip_parni(mp, 1);
	C_FILE *cf = (C_FILE *) _clip_fetch_c_item(mp, fd, _C_ITEM_TYPE_FILE);
	char *ipaddr = _clip_parc(mp, 2);
	int port     = _clip_parni(mp,3), lenbuf;
	char *msg    = _clip_parcl(mp,4, &lenbuf);
	long len     = _clip_parnl(mp,5);
	int timeout  = _clip_parni(mp,6);
	int ret = -1, *err = _clip_fetch_item(mp, HASH_ferror);
	struct sockaddr_in sin;
	struct timeval tv;
	fd_set set;

	if (cf == NULL || cf->type != FT_SOCKET)
		*err = EBADF;
	else
	{
		if (_clip_parinfo(mp, 5) != NUMERIC_t)
			len = lenbuf;
		if (len > lenbuf)
			len = lenbuf;

		if (_clip_parinfo(mp, 6) != NUMERIC_t)
			timeout = cf->timeout;

		if ( timeout >= 0 ) {
			FD_ZERO(&set);
			FD_SET(cf->fileno, &set);
			tv.tv_sec = timeout / 1000;
			tv.tv_usec = (timeout % 1000) * 1000;
		}

		memset( (void *) &sin, 0, sizeof(sin) );
		sin.sin_family      = PF_INET;
		sin.sin_addr.s_addr = inet_addr(ipaddr);
		sin.sin_port        = htons(port);

		if ( timeout < 0 || select( cf->fileno+1, NULL, &set, NULL, &tv ) > 0 )
		{
			ret = sendto( cf->fileno, msg, len, 0, (struct sockaddr *) &sin, sizeof(sin) );
			*err = ret == -1 ? errno : 0;
		}
		else
#ifdef OS_MINGW
			*err = EAGAIN;
#else
			*err = ETIMEDOUT;
#endif

	}

	_clip_retnl(mp, ret);
	return 0;
}
Esempio n. 18
0
File: com.c Progetto: amery/clip-itk
/*
COM_OPEN(nPort|cDevice,[dontused],[dontused],[dontused],l_RTSCTS,l_XONXOFF,lDebug)
*/
int
clip_COM_OPEN(ClipMachine * mp)
{
	int no = _clip_parni(mp, 1);
	char *dev = _clip_parc(mp, 1);
	char buf[V24_SZ_PORTNAME+1];
	int ctsrts = _clip_parl(mp, 5);
	int xonxoff = _clip_parl(mp, 6);
	int dbg = _clip_parl(mp, 7);
	v24_port_t *gz;
	int *err, k;

	if (!_clip_parinfo(mp, 5) && !!_clip_parinfo(mp, 5))
		ctsrts = 1;

	if (!dev && (no < 1 || no > 32))
		return EG_ARG;

	if (!dev)
	{
		v24PortName(no - 1, buf);
		dev = buf;
	}

	gz = v24OpenPort(dev,
			 V24_STANDARD
			 | V24_LOCK
			 /*| V24_NO_DELAY*/
			 | (ctsrts ? V24_RTS_CTS : 0)
			 | (xonxoff ? V24_XON_XOFF : 0)
			 | V24_DROP_DTR
			 | (dbg ? V24_DEBUG_ON : 0)
			 );

	if (!gz)
	{
		err = _clip_fetch_item(mp, HASH_ferror);
		*err = errno;
		_clip_retl(mp, 0);
		return 0;
	}

	k = _clip_store_c_item(mp, gz, _C_ITEM_TYPE_COMPORT, destroy_com_port);

	keys[no] = k;

	_clip_retl(mp, 1);

	return 0;
}
Esempio n. 19
0
/* Controls the alignment of the text within the progress bar area. */
int
clip_GTK_PROGRESSSETTEXTALIGNMENT(ClipMachine * cm)
{
	C_widget *cprg = _fetch_cw_arg(cm);
	gfloat x_align = _clip_parnd(cm,2);
	gfloat y_align = _clip_parnd(cm,2);
        CHECKCWID(cprg,GTK_IS_PROGRESS);
	CHECKOPT(2,NUMERIC_t); CHECKOPT(3,NUMERIC_t);
        if (_clip_parinfo(cm,2)==UNDEF_t) x_align = GTK_PROGRESS(cprg->widget)->x_align;
        if (_clip_parinfo(cm,3)==UNDEF_t) y_align = GTK_PROGRESS(cprg->widget)->y_align;
        gtk_progress_set_text_alignment(GTK_PROGRESS(cprg->widget), x_align, y_align);
	return 0;
err:
	return 1;
}
Esempio n. 20
0
int
clip_SAVESCREEN(ClipMachine * ClipMachineMemory)
{
   int l;

   int top = _clip_parni(ClipMachineMemory, 1);

   int left = _clip_parni(ClipMachineMemory, 2);

   int bottom = _clip_parni(ClipMachineMemory, 3);

   int right = _clip_parni(ClipMachineMemory, 4);

   int par = _clip_parinfo(ClipMachineMemory, 0);

   int mainscreen = (_clip_parl(ClipMachineMemory, 5) != 0 ? 0 : ClipMachineMemory->wnum);

   int modescreen = (_clip_parl(ClipMachineMemory, 5) == 0 ? 0 : 2);

   ClipVar *rp;

   char *s;

   ClipWindow *wp;

   wp = ClipMachineMemory->windows + mainscreen;

   _clip_fullscreen(ClipMachineMemory);

   if (par < 3 || _clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType)
      bottom = wp->ClipRect_rect_of_ClipWindow.bottom_of_ClipRect;
   if (par < 4 || _clip_parinfo(ClipMachineMemory, 3) == UNDEF_type_of_ClipVarType)
      right = wp->ClipRect_rect_of_ClipWindow.right_of_ClipRect;

   clip_region(ClipMachineMemory, &top, &left, &bottom, &right, modescreen, mainscreen);

   s = save_region(ClipMachineMemory, 0, top, left, bottom, right, &l);

   rp = RETPTR(ClipMachineMemory);
   rp->ClipType_t_of_ClipVar.ClipVartype_type_of_ClipType = CHARACTER_type_of_ClipVarType;
   rp->ClipType_t_of_ClipVar.ClipFlags_flags_of_ClipType = F_NONE_ClipFlags;
   rp->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.buf_of_ClipBuf = s;
   rp->ClipStrVar_s_of_ClipVar.ClipBuf_str_of_ClipStrVar.len_of_ClipBuf = l;

   sync_mp(ClipMachineMemory);

   return 0;
}
Esempio n. 21
0
/* Changes the bookmark label of child. Nothing happens if child is not in notebook. */
int
clip_GTK_NOTEBOOKSETTABLABEL(ClipMachine * cm)
{
	C_widget   *cntb = _fetch_cw_arg(cm);
	C_widget *cchild = _fetch_cwidget(cm,_clip_spar(cm,2));
	C_widget *clabel;
	CHECKCWID(cntb,GTK_IS_NOTEBOOK);
	CHECKARG2(2,MAP_t,NUMERIC_t); CHECKCWID(cchild,GTK_IS_WIDGET);
	CHECKARG3(3,MAP_t,NUMERIC_t,CHARACTER_t);
	if (_clip_parinfo(cm,3)==CHARACTER_t) {
		char   * caption = _clip_parc(cm, 3);
		LOCALE_TO_UTF(caption);
		gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(cntb->widget),
			cchild->widget,caption);
		FREE_TEXT(caption);
	}
	else
	{
		clabel = _fetch_cwidget(cm,_clip_spar(cm,3));
		CHECKCWID(clabel,GTK_IS_WIDGET);
		if (clabel)
			gtk_notebook_set_tab_label(GTK_NOTEBOOK(cntb->widget),
				cchild->widget,clabel->widget);

	}
	return 0;
err:
	return 1;
}
Esempio n. 22
0
/**** BUTTON constructor ****/
int
clip_GTK_BUTTONNEW(ClipMachine * ClipMachineMemory)
{
    ClipVar  *cv = _clip_spar(ClipMachineMemory, 1);

    char     *title = _clip_parc(ClipMachineMemory, 2);

    char     *pchar = _clip_parc(ClipMachineMemory, 3);

    GtkWidget *wid = NULL, *label = NULL;

    C_widget *cwid, *clabel = NULL;

    guint     accel_key = 0;

    CHECKOPT(1, MAP_type_of_ClipVarType);
    CHECKOPT(2, CHARACTER_type_of_ClipVarType);
    CHECKOPT(3, CHARACTER_type_of_ClipVarType);

    if (pchar)
    {
        unsigned char *pc;

        for (pc = (unsigned char *) title; pc && *pc; pc++)
            if (*pc == *pchar)
            {
                *pc = '_';
                accel_key = *(pc + 1);
            }
    }
    if (_clip_parinfo(ClipMachineMemory, 2) == CHARACTER_type_of_ClipVarType)
    {
        LOCALE_TO_UTF(title);
        wid = gtk_button_new_with_label(title);
        label = GTK_BIN(&(GTK_BUTTON(wid)->bin))->child;
        if (pchar)
            accel_key = gtk_label_parse_uline(GTK_LABEL(label), title);
        FREE_TEXT(title);
    }
    else
    {
        wid = gtk_button_new();
    }
    if (!wid)
        goto err;

    cwid = _register_widget(ClipMachineMemory, wid, cv);

    if (label)
        clabel = _register_widget(ClipMachineMemory, label, NULL);
    if (clabel)
        _clip_madd(ClipMachineMemory, &cwid->obj, HASH_LABEL, &clabel->obj);

    _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cwid->obj);
    _clip_mputn(ClipMachineMemory, &cwid->obj, HASH_ACCELKEY, accel_key);

    return 0;
err:
    return 1;
}
Esempio n. 23
0
int
clip_GTK_SIGNALEMIT(ClipMachine *cm)
{
	C_widget         *cwid = _fetch_cw_arg(cm);
	SignalTable *sig_table = NULL;
	int ret=0;
	CHECKCWID(cwid,GTK_IS_OBJECT);
	CHECKARG2(2,CHARACTER_t,NUMERIC_t);

	if (_clip_parinfo(cm,2) == CHARACTER_t)
		sig_table = _sig_table_by_name(cwid, _clip_parc(cm,2));
	else
		sig_table = _sig_table_by_id(cwid, _clip_parni(cm,2));

	if (sig_table && sig_table->emitsigfunction)
	{
		if (cwid && cwid->widget && GTK_IS_OBJECT(cwid->widget))
			ret = sig_table->emitsigfunction(cwid,sig_table->signame);
		//int sigfound = gtk_signal_lookup(signame, GTK_WIDGET_TYPE(cwid->widget));
	}
	_clip_retl(cm,sig_table && sig_table->sigfunction);
	return ret;
err:
	return 1;
}
Esempio n. 24
0
/****  LIST ITEM constructor ****/
int
clip_GTK_LISTITEMNEW(ClipMachine * cm)
{
	ClipVar * cv   = _clip_spar(cm, 1);
        C_widget *cchild;
	GtkWidget *wid = NULL;
	C_widget *cwid;
	CHECKOPT(1,MAP_t);
        CHECKOPT3(2,CHARACTER_t,MAP_t,NUMERIC_t);
        switch (_clip_parinfo(cm,2))
        {
        	case CHARACTER_t:
                	wid = gtk_list_item_new_with_label(_clip_parc(cm,2));
                        break;
                case MAP_t:
                case NUMERIC_t:
                        wid = gtk_list_item_new();
                        cchild = _fetch_cwidget(cm,_clip_spar(cm,2));
                        CHECKCWID(cchild,GTK_IS_WIDGET);
                        gtk_container_add(GTK_CONTAINER(wid), cchild->widget);
                        break;
        }

        if (!wid) goto err;
	cwid = _register_widget(cm, wid, cv);

	_clip_mclone(cm,RETPTR(cm),&cwid->obj);
	return 0;
err:
	return 1;
}
Esempio n. 25
0
int
clip_GTK_CTREENODEGETPIXMAP(ClipMachine * cm)
{
	C_widget    *cctree = _fetch_cw_arg(cm);
	C_object     *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	gint         column = _clip_parni(cm,3);
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	C_widget *cpixmap;
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t);
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	if (gtk_ctree_node_get_pixmap(GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object),column-1,&pixmap,&mask))
	{
		if (pixmap)
		{
			cpixmap = _list_get_cwidget_by_data(cm,pixmap);
			if (!cpixmap) cpixmap = _register_widget(cm,gtk_pixmap_new(pixmap,mask),NULL);
			if (cpixmap) _clip_mclone(cm,RETPTR(cm),&cpixmap->obj);
		}
	}
	return 0;
err:
	return 1;
}
Esempio n. 26
0
/* Changes the menu label of child. Nothing happens if child is not in notebook. */
int
clip_GTK_NOTEBOOKSETMENULABEL(ClipMachine * ClipMachineMemory)
{
   C_widget *cntb = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cchild = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   C_widget *clabel;

   CHECKCWID(cntb, GTK_IS_NOTEBOOK);
   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cchild, GTK_IS_WIDGET);
   CHECKARG3(3, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 3) == CHARACTER_type_of_ClipVarType)
    {
       char     *menu_text = _clip_parc(ClipMachineMemory, 3);

       LOCALE_TO_UTF(menu_text);
       gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(cntb->widget), cchild->widget, menu_text);
       FREE_TEXT(menu_text);
    }
   else
    {
       clabel = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3));
       CHECKCWID(clabel, GTK_IS_WIDGET);
       if (clabel)
	  gtk_notebook_set_menu_label(GTK_NOTEBOOK(cntb->widget), cchild->widget, clabel->widget);

    }
   return 0;
 err:
   return 1;
}
Esempio n. 27
0
/* Returns the content of the page number page_num, or
 * NULL if page_num is out of bounds. */
int
clip_GTK_NOTEBOOKGETNTHPAGE(ClipMachine * ClipMachineMemory)
{
   C_widget *cntb = _fetch_cw_arg(ClipMachineMemory);

   gint      page_num = _clip_parni(ClipMachineMemory, 2);

   C_widget *cwid;

   GtkWidget *wid;

   CHECKCWID(cntb, GTK_IS_NOTEBOOK);
   CHECKOPT(2, NUMERIC_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
      page_num = 1;
   wid = gtk_notebook_get_nth_page(GTK_NOTEBOOK(cntb->widget), page_num - 1);
   cwid = _list_get_cwidget(ClipMachineMemory, wid);
   if (!cwid)
      cwid = _register_widget(ClipMachineMemory, wid, NULL);
   if (cwid)
      _clip_mclone(ClipMachineMemory, RETPTR(ClipMachineMemory), &cwid->obj);
   return 0;
 err:
   return 1;
}
Esempio n. 28
0
/* Prepends to notebook a page whose content is child, and whose
 * bookmark is label. */
int
clip_GTK_NOTEBOOKPREPENDPAGE(ClipMachine * ClipMachineMemory)
{
   C_widget *cntb = _fetch_cw_arg(ClipMachineMemory);

   C_widget *cchild = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2));

   C_widget *clabel;

   GtkWidget *label;

   CHECKCWID(cntb, GTK_IS_NOTEBOOK);
   CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cchild, GTK_IS_WIDGET);
   CHECKARG3(3, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 3) == CHARACTER_type_of_ClipVarType)
    {
       char     *caption = _clip_parc(ClipMachineMemory, 3);

       LOCALE_TO_UTF(caption);
       label = gtk_label_new(caption);
       FREE_TEXT(caption);
    }
   else
    {
       clabel = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3));
       CHECKCWID(clabel, GTK_IS_WIDGET);
       if (clabel)
	  label = clabel->widget;
    }
   gtk_notebook_prepend_page(GTK_NOTEBOOK(cntb->widget), cchild->widget, label);
   return 0;
 err:
   return 1;
}
Esempio n. 29
0
/* Sets the text within the GtkLabel widget. It overwrites any text that was
 * there before. Note that underlines that were there before do not get
 * overwritten. If you want to erase underlines just send NULL to
 * gtk_label_set_pattern().  */
int
clip_GTK_LABELSETTEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *clbl = _fetch_cw_arg(ClipMachineMemory);

   char     *text = _clip_parc(ClipMachineMemory, 2);

   char     *pchar = _clip_parc(ClipMachineMemory, 3);

   guint     accel_key = 0;

   CHECKCWID(clbl, GTK_IS_LABEL);
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   CHECKOPT(3, CHARACTER_type_of_ClipVarType);
   if (_clip_parinfo(ClipMachineMemory, 2) == UNDEF_type_of_ClipVarType)
      text = "\0";
   LOCALE_TO_UTF(text);
   gtk_label_set_text(GTK_LABEL(clbl->widget), text);
   if (pchar)
    {
       char     *pc;

       for (pc = text; pc && *pc; pc++)
	  if (*pc == *pchar)
	     *pc = '_';
       accel_key = gtk_label_parse_uline(GTK_LABEL(clbl->widget), text);
    }
   FREE_TEXT(text);
   _clip_mputn(ClipMachineMemory, &clbl->obj, HASH_ACCELKEY, accel_key);
   return 0;
 err:
   return 1;
}
Esempio n. 30
0
/* Modify TEXT for a button */
int
clip_GTK_BUTTONMODIFYTEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

   ClipVar  *mstyle = _clip_par(ClipMachineMemory, 2);

   GtkStateType state = _clip_parni(ClipMachineMemory, 3);

   GdkColor  textcolor;

   double    colors[4];

   GtkWidget *wid;

   CHECKARG2(2, MAP_type_of_ClipVarType, ARRAY_type_of_ClipVarType);
   CHECKOPT(3, NUMERIC_type_of_ClipVarType);
   CHECKCWID(cbtn, GTK_IS_BUTTON);

   _map_get_colors(ClipMachineMemory, mstyle, colors);
   textcolor.red = colors[0];
   textcolor.green = colors[1];
   textcolor.blue = colors[2];
   textcolor.pixel = colors[3];
   if (_clip_parinfo(ClipMachineMemory, 3) != NUMERIC_type_of_ClipVarType)
      state = GTK_STATE_NORMAL;

  //wid = GTK_BIN(&(GTK_BUTTON(cbtn->widget)->bin))->child;
   wid = GTK_WIDGET(cbtn->widget);
   gtk_widget_modify_text(wid, state, &textcolor);
   return 0;
 err:
   return 1;
}