Exemplo n.º 1
0
int
clip_BIN2I(ClipMachine * ClipMachineMemory)
{
   int vl = 0;

   short ret;

   char *vp = _clip_parcl(ClipMachineMemory, 1, &vl);

   if (vp == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "BIN2I");
   }
   ret = *((short *) vp);
   _clip_retni(ClipMachineMemory, ret);
   return 0;
}
Exemplo n.º 2
0
int
clip_GTK_FONTBUTTONGETTITLE(ClipMachine * ClipMachineMemory)
{
   C_widget *cbtn = _fetch_cw_arg(ClipMachineMemory);

   gchar    *title;

   CHECKCWID(cbtn, GTK_IS_FONT_BUTTON);

   title = (gchar *) gtk_font_button_get_title(GTK_FONT_BUTTON(cbtn->widget));
   LOCALE_FROM_UTF(title);
   _clip_retc(ClipMachineMemory, title);
   FREE_TEXT(title);

   return 0;
 err:
   return 1;
}
Exemplo n.º 3
0
int
clip_GTK_COMBOBOXGETACTIVETEXT(ClipMachine * ClipMachineMemory)
{
   C_widget *ccmb = _fetch_cw_arg(ClipMachineMemory);

   gchar    *text;

   CHECKCWID(ccmb, GTK_IS_COMBO_BOX);

   text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(ccmb->widget));
   LOCALE_FROM_UTF(text);
   _clip_retc(ClipMachineMemory, text);
   FREE_TEXT(text);

   return 0;
 err:
   return 1;
}
Exemplo n.º 4
0
/******************************************************************************
* gtk_TreeStoreInsert(tree, parent_path_string/NULL, position, ncol, val, ....) -->path_string
******************************************************************************/
int
clip_GTK_TREESTOREINSERT(ClipMachine * ClipMachineMemory)
{

   C_object *cstree = _fetch_co_arg(ClipMachineMemory);

   gchar    *parent = _clip_parc(ClipMachineMemory, 2);

   gint      position = _clip_parni(ClipMachineMemory, 3);

   GtkTreeIter iter;

   GtkTreeIter parentiter;

   GtkTreePath *path;

   gchar    *path_string;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object));
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   CHECKARG(3, NUMERIC_type_of_ClipVarType);

   if (parent)
      gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)),
			      &parentiter, gtk_tree_path_new_from_string(parent));

   gtk_tree_store_insert(GTK_TREE_STORE(cstree->object), &iter, (parent ? &parentiter : NULL), position);

   __tree_store_set(ClipMachineMemory, &iter, 4);

   path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)), &iter);

   path_string = gtk_tree_path_to_string(path);

   _clip_retc(ClipMachineMemory, path_string);

   g_free(path_string);

   return 0;
 err:
   return 1;
}
Exemplo n.º 5
0
/* Returns the text indicating the progress based on the supplied value.
 * The current value for the GtkProgress remains unchanged.  */
int
clip_GTK_PROGRESSGETTEXTFROMVALUE(ClipMachine * ClipMachineMemory)
{
   C_widget *cprg = _fetch_cw_arg(ClipMachineMemory);

   gfloat    value = _clip_parnd(ClipMachineMemory, 2);

   gchar    *text;

   CHECKCWID(cprg, GTK_IS_PROGRESS);
   CHECKOPT(2, NUMERIC_type_of_ClipVarType);
   text = gtk_progress_get_text_from_value(GTK_PROGRESS(cprg->widget), value);
   LOCALE_TO_UTF(text);
   _clip_retc(ClipMachineMemory, text);
   FREE_TEXT(text);
   return 0;
 err:
   return 1;
}
Exemplo n.º 6
0
int
clip_GTK_EXTEXTGETCHARATPOS(ClipMachine * cm)
{
	C_widget *extext = _fetch_cw_arg(cm);
	gint         pos = _clip_parni(cm, 2);
	guchar       str;

	CHECKCWID(extext, GTK_IS_EXTEXT);
	CHECKOPT(2, NUMERIC_t);

	if (_clip_parinfo(cm, 2) != NUMERIC_t)
		pos = GTK_EXTEXT(extext->widget)->line_number;

	str = gtk_extext_get_char_at_pos(GTK_EXTEXT(extext->widget), pos);
	_clip_retc(cm, &str);
	return 0;
err:
	return 1;
}
Exemplo n.º 7
0
/* Returns text in item */
int
clip_GTK_LISTITEMGETTEXT(ClipMachine *cm)
{
	C_widget *clitm = _fetch_cw_arg(cm);
        GtkWidget *child = NULL;
        char *text;
        CHECKCWID(clitm,GTK_IS_LIST_ITEM);
        child = GTK_BIN(&(GTK_ITEM(clitm->widget)->bin))->child;
        if (GTK_IS_LABEL(child))
        {
        	gtk_label_get(GTK_LABEL(child), &text);
		LOCALE_TO_UTF(text);
		_clip_retc(cm,text);
        	FREE_TEXT(text);
	}
	return 0;
err:
	return 1;
}
Exemplo n.º 8
0
int
clip_STRUNFORMAT(ClipMachine * ClipMachineMemory)
{
   int i, len, nw;

   char *str1;

   char *str2 = _clip_parcl(ClipMachineMemory, 1, &len);

   if (str2 == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "STRUNFORMAT");
   }
   for (nw = 0; str2[nw] == ' '; nw++);
   for (i = 0; i < len;)
   {
      nw++;
      if (str2[i] == ' ')
	 while (str2[i] == ' ')
	    i++;
      else
	 i++;
   }
   str1 = (char *) malloc(nw + 1);

   for (i = 0, nw = 0; str2[i] == ' '; i++, nw++)
      str1[nw] = str2[i];
   for (; i < len;)
   {
      str1[nw] = str2[i];
      nw++;
      if (str2[i] == ' ')
	 while (str2[i] == ' ')
	    i++;
      else
	 i++;
   }
   str1[nw] = 0;
   _clip_retcn_m(ClipMachineMemory, str1, nw);
   return 0;
}
Exemplo n.º 9
0
int
clip_GTK_MENUGETTITLE(ClipMachine * ClipMachineMemory)
{
   C_widget *cmnu = _fetch_cw_arg(ClipMachineMemory);

   gchar    *title;

   CHECKCWID(cmnu, GTK_IS_MENU);

   title = (gchar *) gtk_menu_get_title(GTK_MENU(cmnu->widget));

   LOCALE_FROM_UTF(title);

   _clip_retc(ClipMachineMemory, title);

   FREE_TEXT(title);
   return 0;
 err:
   return 1;
}
Exemplo n.º 10
0
int
clip_SQLFIELDNAME(ClipMachine * ClipMachineMemory)
{
   SQLROWSET *rowset = (SQLROWSET *) _clip_fetch_c_item(ClipMachineMemory, _clip_parni(ClipMachineMemory, 1),
							_C_ITEM_TYPE_SQL);

   int fieldno = _clip_parni(ClipMachineMemory, 2);

   if (!rowset)
   {
      _clip_trap_err(ClipMachineMemory, 0, 0, 0, subsys, ER_NOROWSET, er_norowset);
      return 1;
   }
   if (fieldno < 1 || fieldno > rowset->nfields)
   {
      _clip_trap_err(ClipMachineMemory, 0, 0, 0, subsys, ER_NOFIELD, er_nofield);
      return 1;
   }
   _clip_retc(ClipMachineMemory, rowset->fields[fieldno - 1].name);
   return 0;
}
Exemplo n.º 11
0
int
clip_GTK_ACTIONGROUPGETNAME(ClipMachine * ClipMachineMemory)
{
   C_object *cagroup = _fetch_co_arg(ClipMachineMemory);

   gchar    *name;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cagroup, GTK_IS_ACTION_GROUP(cagroup->object));

   name = (gchar *) gtk_action_group_get_name(GTK_ACTION_GROUP(cagroup->object));

   LOCALE_FROM_UTF(name);

   _clip_retc(ClipMachineMemory, name);

   FREE_TEXT(name);
   return 0;
 err:
   return 1;
}
Exemplo n.º 12
0
int
clip_GTK_EXTEXTGETCHARS(ClipMachine * cm)
{
	C_widget *extext = _fetch_cw_arg(cm);
	gint       start = _clip_parni(cm, 2);
	gint         end = _clip_parni(cm, 3);

	CHECKCWID(extext, GTK_IS_EXTEXT);
	CHECKOPT(2, NUMERIC_t); CHECKOPT(3, NUMERIC_t);

	if (_clip_parinfo(cm, 2) != NUMERIC_t)
		start = 0;
	if (_clip_parinfo(cm, 3) != NUMERIC_t)
		end = GTK_EXTEXT(extext->widget)->length;

	_clip_retc(cm, (char *)gtk_extext_get_chars(GTK_EXTEXT(extext->widget), start, end));

	return 0;
err:
	return 1;
}
Exemplo n.º 13
0
int
clip_ALT2KOI(ClipMachine * ClipMachineMemory)
{

   int l;

   unsigned char *ret;

   unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l);

   if (str == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return 0;
   }
   ret = malloc(l + 1);
   memcpy(ret, str, l);
   ret[l] = 0;
   _clip_recodeString((char *) ret, l, CS_ALT, CS_KOI);
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l);
   return 0;
}
Exemplo n.º 14
0
int
clip_GTK_TREESTOREAPPEND(ClipMachine * ClipMachineMemory)
{
   C_object *cstree = _fetch_co_arg(ClipMachineMemory);

   gchar    *parent = _clip_parc(ClipMachineMemory, 2);

   GtkTreeIter iter;

   GtkTreeIter parentiter;

   GtkTreePath *path;

   gchar    *path_string;

   CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object));
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);

   memset(&parentiter, 0, sizeof(parentiter));
   if (parent)
      gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)),
			      &parentiter, gtk_tree_path_new_from_string(parent));

   gtk_tree_store_append(GTK_TREE_STORE(cstree->object), &iter, (parent ? &parentiter : NULL));

   __tree_store_set(ClipMachineMemory, &iter, 3);

   path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)), &iter);

   path_string = gtk_tree_path_to_string(path);

   _clip_retc(ClipMachineMemory, path_string);

   g_free(path_string);

   return 0;
 err:
   return 1;
}
Exemplo n.º 15
0
/*
	GETTEXT(cMsg [,cModule])->cTranslated
*/
int
clip_GETTEXT(ClipMachine * ClipMachineMemory)
{
   char *msgid = _clip_parc(ClipMachineMemory, 1);

   char *module = _clip_parc(ClipMachineMemory, 2);

   if (msgid && module)
   {
      char *rp = 0;

      int l;

      _clip_locale_msg(module, msgid, &rp);
      l = strlen(rp);
      _clip_retcn_m(ClipMachineMemory, rp, l);
   }
   else
      _clip_retc(ClipMachineMemory, msgid);

   return 0;
}
Exemplo n.º 16
0
int
clip_GTK_ACCELERATORGETLABEL(ClipMachine * ClipMachineMemory)
{
   guint     accelerator_key = _clip_parni(ClipMachineMemory, 1);

   GdkModifierType type = _clip_parni(ClipMachineMemory, 2);

   gchar    *label;

   CHECKARG(1, NUMERIC_type_of_ClipVarType);
   CHECKARG(2, NUMERIC_type_of_ClipVarType);

   label = gtk_accelerator_get_label(accelerator_key, type);

   LOCALE_FROM_UTF(label);
   _clip_retc(ClipMachineMemory, label);
   FREE_TEXT(label);

   return 0;
 err:
   return 1;
}
Exemplo n.º 17
0
int
clip_JUSTRIGHT(ClipMachine * ClipMachineMemory)
{
   int l1, l2, i;

   unsigned char *e, *ret, *end, *cur;

   unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l1);

   int ch = _clip_parni(ClipMachineMemory, 2);

   unsigned char *s = (unsigned char *) _clip_parcl(ClipMachineMemory, 2, &l2);

   int rset = (*(char *) (_clip_fetch_item(ClipMachineMemory, HASH_csetref)) == 't');

   if (s != NULL)
      ch = *s;
   if (ch == 0)
      ch = ' ';

   if (str == NULL || l1 == 0)
   {
      _clip_retc(ClipMachineMemory, "");
      return 0;
   }
   ret = malloc(l1 + 1);
   for (e = str + l1 - 1, end = str; e > end && *e == ch; e--);
   i = str + l1 - e - 1;
   end = str + l1 - i;
   for (cur = ret; i > 0; i--, cur++)
      *cur = ch;
   for (e = str; e < end; e++, cur++)
      *cur = *e;
   ret[l1] = 0;
   if (rset && _clip_par_isref(ClipMachineMemory, 1))
      _clip_par_assign_str(ClipMachineMemory, 1, (char *) ret, l1);
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l1);
   return 0;
}
Exemplo n.º 18
0
int
clip_CHARODD(ClipMachine * ClipMachineMemory)
{
   int l, l1, i;

   unsigned char *ret, *e, *end;

   unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l1);

   if (str == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "CHARODD");
   }
   l = (l1 + 1) / 2;
   ret = malloc(l + 2);
   for (i = 0, e = str, end = str + l1; e < end; e += 2, i++)
      ret[i] = *e;
   ret[l] = 0;
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l);
   return 0;
}
Exemplo n.º 19
0
/*
 * read CONTENT_LENGTH input and return as string
 */
int
clip_FCGI_READ(ClipMachine *mp)
{
	char *clen;
	int len;

	if (!inited)
		return EG_ARG;

	clen =  FCGX_GetParam("CONTENT_LENGTH", envp);
	/*clen =  getenv("CONTENT_LENGTH");*/

	if (clen)
		len = strtol(clen, NULL, 10);
	else
		len = 0;

	if(len)
	{
		OutBuf buf;
		int i, ch, l;

		init_Buf(&buf);
		for (i = 0; i < len; i++)
		{
			if ((ch = FCGX_GetChar(in)) < 0)
			/*if ((ch = FCGI_fgetc(FCGI_stdin)) < 0)*/
				break;
			putByte_Buf(&buf, ch);
		}
		l = buf.ptr - buf.buf;
		putByte_Buf(&buf, 0);
		_clip_retcn_m(mp, buf.buf, l);
	}
	else
		_clip_retc(mp, "");

	return 0;
}
Exemplo n.º 20
0
int
clip_HARDCR(ClipMachine * ClipMachineMemory)
{
   int vl = 0;

   char *ret, *e;

   char *vp = _clip_parcl(ClipMachineMemory, 1, &vl);

   if (vp == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "HARDCR");
   }
   ret = malloc(vl + 1);
   memcpy(ret, vp, vl);
   for (e = ret; e < ret + vl; e++)
      if (*e == (char) 141)
	 *e = '\n';
   ret[vl] = 0;
   _clip_retcn_m(ClipMachineMemory, ret, vl);
   return 0;
}
Exemplo n.º 21
0
int
clip_TABLEEXT(ClipMachine * ClipMachineMemory)
{
   int i, j;

   for (i = 0; i < *ClipMachineMemory->ndbdrivers; i++)
   {
      if (strncasecmp(ClipMachineMemory->def_db_driver, (*ClipMachineMemory->dbdrivers)[i].id_of_DBDriver, 6) == 0)
      {
	 for (j = 0; j < *ClipMachineMemory->ndata_drivers; j++)
	 {
	    if (strncasecmp((*ClipMachineMemory->data_drivers)[j]->id, (*ClipMachineMemory->dbdrivers)[i].data_of_DBDriver, sizeof((*ClipMachineMemory->data_drivers)[j]->id)) == 0)
	    {

	       _clip_retc(ClipMachineMemory, (*ClipMachineMemory->data_drivers)[j]->suff);
	       break;
	    }
	 }
	 break;
      }
   }
   return 0;
}
Exemplo n.º 22
0
int clip_PG_OUT_DATE(ClipMachine* mp){
	PG_ROWSET* rowset = (PG_ROWSET*)_clip_fetch_c_item(
		mp,_clip_parni(mp,1),_C_ITEM_TYPE_SQL);
	long date = _clip_pardj(mp,2);
	int totext = _clip_parl(mp,3);

	if(!rowset){
		_clip_trap_err(mp,0,0,0,subsys,ER_NOROWSET,er_norowset);
		return 1;
	}
	if((!totext)&&rowset->binary){
		long d = date-2451545;
		_clip_retcn(mp,(char*)&d,4);
	} else {
		char str[11];
		int y,m,d,w;

		_clip_cdate(date,&d,&m,&y,&w);
		snprintf(str,sizeof(str),"%04d-%02d-%02d",y,m,d);
		_clip_retc(mp,str);
	}
	return 0;
}
Exemplo n.º 23
0
int
clip_FCGI_GETENV(ClipMachine *mp)
{
	ClipVar *rp;
	char *str = _clip_parc(mp, 1);
	int i = 0;

	if (!inited)
		return EG_ARG;

	if (str)
	{
		_clip_retc(mp, FCGX_GetParam(str, envp));
		/*_clip_retc(mp, getenv(str));*/
	}
	else
	{
		rp = RETPTR(mp);
		_clip_map(mp, rp);
		while (envp[i])
		{
			int l;
			char *s = envp[i];
			char *e;
			/*char *s = environ[i];*/

			l = strcspn(s, "=");
			if (s[l]=='=')
				e = s+l+1;
			else
				e = "";
			_clip_mputc(mp, rp, _clip_casehashbytes(0, s, l), e, strlen(e));
			i++;
		}
	}
	return 0;
}
Exemplo n.º 24
0
int
clip_REPLLEFT(ClipMachine * ClipMachineMemory)
{
   int l;

   unsigned char *ret, *e, *end;

   unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l);

   unsigned char *s1 = (unsigned char *) _clip_parc(ClipMachineMemory, 2);

   int ch1 = _clip_parni(ClipMachineMemory, 2);

   unsigned char *s2 = (unsigned char *) _clip_parc(ClipMachineMemory, 3);

   int ch2 = _clip_parni(ClipMachineMemory, 3);

   int rset = (*(char *) (_clip_fetch_item(ClipMachineMemory, HASH_csetref)) == 't');

   if (str == NULL || s1 == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "REPLLEFT");
   }
   ch1 = s1 == NULL ? ch1 : *s1;
   ch1 = ch1 == 0 ? ' ' : ch1;
   ch2 = s2 == NULL ? ch2 : *s2;
   ch2 = ch2 == 0 ? ' ' : ch2;
   ret = malloc(l + 1);
   memcpy(ret, str, l);
   for (e = ret, end = ret + l; e < end && (*e == ch2); e++)
      *e = ch1;
   if (rset && _clip_par_isref(ClipMachineMemory, 1))
      _clip_par_assign_str(ClipMachineMemory, 1, (char *) ret, l);
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l);
   return 0;
}
Exemplo n.º 25
0
/******************************************************************************
* gtk_ListStoreInsertAfter(list, sibling_path_string/NULL, ncol, val, ....)-->path_string
******************************************************************************/
int
clip_GTK_LISTSTOREINSERTAFTER(ClipMachine * cm)
{

	C_object *cslist = _fetch_co_arg(cm);
        gchar   *sibling = _clip_parc(cm, 2);
        GtkTreeIter iter;
        GtkTreeIter siblingiter;
        GtkTreePath *path;
        gchar *path_string;


        CHECKARG2(1, MAP_t, NUMERIC_t); CHECKCOBJ(cslist, GTK_IS_LIST_STORE(cslist->object));
        CHECKOPT(2, CHARACTER_t);

        if (sibling)
        	gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_LIST_STORE(cslist->object)),
        		&siblingiter, gtk_tree_path_new_from_string(sibling));

	gtk_list_store_insert_after(GTK_LIST_STORE(cslist->object), &iter,
				    (sibling?&siblingiter:NULL));

        __list_store_set(cm, &iter, 3);

        path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_LIST_STORE(cslist->object)),
        	&iter);

        path_string = gtk_tree_path_to_string(path);

        _clip_retc(cm, path_string);

	g_free(path_string);

	return 0;
err:
	return 1;
}
Exemplo n.º 26
0
int
clip_WORDSWAP(ClipMachine * ClipMachineMemory)
{
   int l, i;

   short *ret = 0, ch;

   short *str = (short *) _clip_parcl(ClipMachineMemory, 1, &l);

   int rset = (*(char *) (_clip_fetch_item(ClipMachineMemory, HASH_csetref)) == 't');

   l = l >> 1;

   if (str == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "WORDSWAP");
   }
   ret = malloc((l + 1) * 2);
   for (i = 0; i < l; i += 2)
   {
      if (i < l - 1)
      {
	 ch = str[i];
	 ret[i] = str[i + 1];
	 ret[i + 1] = ch;
      }
      else
	 ret[i] = str[i];
   }
   ret[l] = 0;
   if (rset && _clip_par_isref(ClipMachineMemory, 1))
      _clip_par_assign_str(ClipMachineMemory, 1, (char *) ret, l * 2);
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l * 2);
   return 0;
}
Exemplo n.º 27
0
int clip_PG_IN_TIMESTAMP(ClipMachine* mp){
	PG_ROWSET* rowset = (PG_ROWSET*)_clip_fetch_c_item(
		mp,_clip_parni(mp,1),_C_ITEM_TYPE_SQL);
	char* date;
	int len;
	struct tm* time;

	if(!rowset){
		_clip_trap_err(mp,0,0,0,subsys,ER_NOROWSET,er_norowset);
		return 1;
	}
	if(rowset->binary){
		date = _clip_parcl(mp,2,&len);
		if(date){
			time = gmtime((time_t*)date);
			_clip_retdc(mp,time->tm_year+1900,time->tm_mon+1,time->tm_mday);
		}
	} else {
		date = _clip_parcl(mp,2,&len);
		_clip_retc(mp,date);
//		_pg_in_date(mp,rowset->conn->datestyle,rowset->conn->textdate,date);
	}
	return 0;
}
Exemplo n.º 28
0
int
clip_UNAME(ClipMachine * ClipMachineMemory)
{
   int val = _clip_parni(ClipMachineMemory, 1);

   struct utsname namesys;

   int ret = uname(&namesys);

   _clip_retc(ClipMachineMemory, "");
   if (ret < 0)
      return 0;
   switch (val)
   {
   case 1:
      _clip_retc(ClipMachineMemory, namesys.sysname);
      break;
   case 2:
      _clip_retc(ClipMachineMemory, namesys.release);
      break;
   case 3:
      _clip_retc(ClipMachineMemory, namesys.version);
      break;
   case 4:
      _clip_retc(ClipMachineMemory, namesys.machine);
      break;
#ifdef _GNU_SOURCE
   case 5:
      _clip_retc(ClipMachineMemory, namesys.domainname);
      break;
#endif
   default:
      _clip_retc(ClipMachineMemory, namesys.nodename);
      break;
   }
   return 0;
}
Exemplo n.º 29
0
int
clip_CHARSORT(ClipMachine * ClipMachineMemory)
{
   int l, i, nsort, epos;

   int *set;

   unsigned char *ret, *beg, *end;

   unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l);

   int elen = _clip_parni(ClipMachineMemory, 2);

   int clen = _clip_parni(ClipMachineMemory, 3);

   int ignore = _clip_parni(ClipMachineMemory, 4);

   int bpos = _clip_parni(ClipMachineMemory, 5);

   int slen = _clip_parni(ClipMachineMemory, 6);

   int flag = _clip_parl(ClipMachineMemory, 7);

   int rset = (*(char *) (_clip_fetch_item(ClipMachineMemory, HASH_csetref)) == 't');

   if (str == NULL)
   {
      _clip_retc(ClipMachineMemory, "");
      return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "CHARSORT");
   }
   for (i = 2; i < 7; i++)
   {
      if (_clip_parinfo(ClipMachineMemory, i) != LOGICAL_type_of_ClipVarType)
	 continue;
      flag = _clip_parl(ClipMachineMemory, i);
      break;
   }
   ret = malloc(l + 1);
   memcpy(ret, str, l);
   ret[l] = 0;
   if (elen <= 0)
      elen = 1;
   if (bpos <= 0)
      bpos = 0;
   if (clen <= 0)
      clen = elen - bpos;
   if ((clen + bpos) > elen)
      clen = elen - bpos;
   epos = bpos + clen;
   if (_clip_parinfo(ClipMachineMemory, 6) != NUMERIC_type_of_ClipVarType)
      slen = l;
   if (slen <= 0)
      slen = 0;
   if (ignore <= 0)
      ignore = 0;
   beg = ret + ignore;
   end = beg + slen;
   end -= ((end - beg) % elen);
   if (end > (ret + l))
      end = ret + l;
   if (elen > l || ignore > l || beg == end)
   {
      _clip_retcn_m(ClipMachineMemory, (char *) ret, l);
      return 0;
   }
   nsort = (end - beg) / elen;
   set = _clip_fetch_item(ClipMachineMemory, HASH_charsort_param);
   set[0] = flag;
   set[1] = elen;
   set[2] = bpos;
   set[3] = epos;
   _clip_charsort_mp = ClipMachineMemory;
   qsort(beg, nsort, elen, _clip_charsort);
   if (rset && _clip_par_isref(ClipMachineMemory, 1))
      _clip_par_assign_str(ClipMachineMemory, 1, (char *) ret, l);
   _clip_retcn_m(ClipMachineMemory, (char *) ret, l);
   return 0;
}
Exemplo n.º 30
0
int
clip_GDK_KEYVALTOUNICODE(ClipMachine * ClipMachineMemory)
{
   guint     keyval = INT_OPTION(ClipMachineMemory, 1, 0);

   wchar_t   wc;		//= INT_OPTION(ClipMachineMemory, 1,0);

   gchar    *result;

   int       total_len, first, clen;

   wc = gdk_keyval_to_unicode(keyval);

   total_len = 0;
   if (wc < 0x80)
      total_len += 1;
   else if (wc < 0x800)
      total_len += 2;
   else if (wc < 0x10000)
      total_len += 3;
   else if (wc < 0x200000)
      total_len += 4;
   else if (wc < 0x4000000)
      total_len += 5;
   else
      total_len += 6;

   result = calloc(total_len + 1, sizeof(char));

   if (wc < 0x80)
    {
       first = 0;
       clen = 1;
    }
   else if (wc < 0x800)
    {
       first = 0xc0;
       clen = 2;
    }
   else if (wc < 0x10000)
    {
       first = 0xe0;
       clen = 3;
    }
   else if (wc < 0x200000)
    {
       first = 0xf0;
       clen = 4;
    }
   else if (wc < 0x4000000)
    {
       first = 0xf8;
       clen = 5;
    }
   else
    {
       first = 0xfc;
       clen = 6;
    }

   switch (clen)
    {
    case 6:
       result[5] = (wc & 0x3f) | 0x80;
       wc >>= 6;		/* Fall through */
    case 5:
       result[4] = (wc & 0x3f) | 0x80;
       wc >>= 6;		/* Fall through */
    case 4:
       result[3] = (wc & 0x3f) | 0x80;
       wc >>= 6;		/* Fall through */
    case 3:
       result[2] = (wc & 0x3f) | 0x80;
       wc >>= 6;		/* Fall through */
    case 2:
       result[1] = (wc & 0x3f) | 0x80;
       wc >>= 6;		/* Fall through */
    case 1:
       result[0] = wc | first;

    }

   _clip_retc(ClipMachineMemory, result);
   free(result);
   return 0;
}