Beispiel #1
0
/**
 * @brief
 */
static void WriteAASFile(void) {
	char path[MAX_QPATH];
	file_t *f;

	StripExtension(bsp_name, path);
	g_strlcat(path, ".aas", sizeof(path));

	if (!(f = Fs_OpenWrite(path))) {
		Com_Error(ERROR_FATAL, "Couldn't open %s for writing\n", path);
	}

	Com_Print("Writing %d AAS nodes..\n", d_aas.num_nodes);

	SwapAASFile();

	bsp_header_t header;
	memset(&header, 0, sizeof(header));

	header.ident = LittleLong(AAS_IDENT);
	header.version = LittleLong(AAS_VERSION);

	Fs_Write(f, &header, 1, sizeof(header));

	d_bsp_lump_t *lump = &header.lumps[AAS_LUMP_NODES];
	WriteLump(f, lump, d_aas.nodes, sizeof(d_aas_node_t) * d_aas.num_nodes);

	// rewrite the header with the populated lumps

	Fs_Seek(f, 0);
	Fs_Write(f, &header, 1, sizeof(header));

	Fs_Close(f);
}
Beispiel #2
0
void flag_click(GtkButton *button,gpointer data)
{
	gtk_label_set_markup(GTK_LABEL(label),title);
	
	const char *text1;
	char num[100]="";
	char num2[100]="";
	gint i=0;

	text1=gtk_entry_get_text(GTK_ENTRY(entry));
	strcpy(num,text1);
	
	if(Is_bksp==YES)
	{
		if(num[0]=='-')
			while(num[i])
			{
				num[i]=num[i+1];
				i++;
			}
		else
		{
			num2[0]='-';
			g_strlcat(num2,num,100);
			strcpy(num,num2);
		}
	}
	
	gtk_entry_set_text(GTK_ENTRY(entry),num);
}
static int dt_imageio_load_modules_storage(dt_imageio_t *iio)
{
  iio->plugins_storage = NULL;
  dt_imageio_module_storage_t *module;
  char plugindir[PATH_MAX] = { 0 }, plugin_name[256];
  const gchar *d_name;
  dt_loc_get_plugindir(plugindir, sizeof(plugindir));
  g_strlcat(plugindir, "/plugins/imageio/storage", sizeof(plugindir));
  GDir *dir = g_dir_open(plugindir, 0, NULL);
  if(!dir) return 1;
  const int name_offset = strlen(SHARED_MODULE_PREFIX),
            name_end = strlen(SHARED_MODULE_PREFIX) + strlen(SHARED_MODULE_SUFFIX);
  while((d_name = g_dir_read_name(dir)))
  {
    // get lib*.so
    if(!g_str_has_prefix(d_name, SHARED_MODULE_PREFIX)) continue;
    if(!g_str_has_suffix(d_name, SHARED_MODULE_SUFFIX)) continue;
    strncpy(plugin_name, d_name + name_offset, strlen(d_name) - name_end);
    plugin_name[strlen(d_name) - name_end] = '\0';
    module = (dt_imageio_module_storage_t *)malloc(sizeof(dt_imageio_module_storage_t));
    gchar *libname = g_module_build_path(plugindir, (const gchar *)plugin_name);
    if(dt_imageio_load_module_storage(module, libname, plugin_name))
    {
      free(module);
      continue;
    }
    module->gui_data = NULL;
    module->gui_init(module);
    if(module->widget) g_object_ref(module->widget);
    g_free(libname);
    dt_imageio_insert_storage(module);
  }
  g_dir_close(dir);
  return 0;
}
Beispiel #4
0
void reg(int clntSocket) {     //A registration function -> game mechanics
	FILE *p;
	gchar path[36], name[31], pass[31];

	g_stpcpy(path, "user/");     //prepare the path
	recv(clntSocket, name, RCVBUFSIZE, 0);     //receive name
	g_strlcat(path, name, 36);     //make the path
	recv(clntSocket, pass, RCVBUFSIZE, 0);     //receive password
	//g_printf("%s", path);

	if (!access(path, F_OK)) {     //check if file is present -> as in already registered or not
		//file was present
		send(clntSocket, "FALSE", 6, 0);		//send the failed signal
		return;     //end function
	}
	//file was NOT present
	send(clntSocket, "TRUE", 5, 0);     //send the OK signal
	p = fopen(path, "w");     //make the user's file
	fprintf(
			p,     //if we made it we should write something to it
			"Name: ;Gender: ; Born: ;height;weight: ;House: ;STR ;DEX ;INT ;VIT ;WIS ;STA ;SPD ;CHA ;HLY ;"
					" Talents: ; Abilities: ; Techniques: ; Personality Traits: ; Reputation: ; Known Locations: ;");
	fclose(p);     //close the file
	return;     //end function
}
static gchar *to_real_section(gchar * confSection, MkdgBackend * backend,
                              const gchar * section)
{

    if (!STRING_IS_EMPTY(backend->basePath)) {
        g_strlcpy(confSection, backend->basePath, KEY_BUFFER_SIZE);
    } else {
        g_strlcpy(confSection, "", KEY_BUFFER_SIZE);
    }

    if (!STRING_IS_EMPTY(section)) {
        g_strlcat(confSection, section, KEY_BUFFER_SIZE);
        g_strlcat(confSection, "/", KEY_BUFFER_SIZE);
    }
    return confSection;
}
static void
gst_info_dump_mem16_line (gchar * linebuf, gsize linebuf_size,
    const guint16 * mem, gsize mem_offset, gsize mem_size)
{
  gchar hexstr[50], digitstr[6];

  if (mem_size > 8)
    mem_size = 8;

  hexstr[0] = '\0';

  if (mem != NULL) {
    guint i = 0;

    mem += mem_offset;
    while (i < mem_size) {
      g_snprintf (digitstr, sizeof (digitstr), "%04x ", mem[i]);
      g_strlcat (hexstr, digitstr, sizeof (hexstr));
      ++i;
    }
  }

  g_snprintf (linebuf, linebuf_size, "%08x: %-48.48s",
      (guint) mem_offset, hexstr);
}
Beispiel #7
0
G_MODULE_EXPORT int hexchat_plugin_init(hexchat_plugin *plugin_handle, char **name, char **description, char **version, char *arg)
{
    if (g_str_has_prefix(LUA_VERSION, "Lua "))
    {
        strcat(plugin_version, "/");
        g_strlcat(plugin_version, LUA_VERSION + 4, sizeof(plugin_version));
    }

    *name = plugin_name;
    *description = plugin_description;
    *version = plugin_version;

    ph = plugin_handle;

    hexchat_hook_command(ph, "", HEXCHAT_PRI_NORM, command_console_exec, NULL, NULL);
    hexchat_hook_command(ph, "LOAD", HEXCHAT_PRI_NORM, command_load, NULL, NULL);
    hexchat_hook_command(ph, "UNLOAD", HEXCHAT_PRI_NORM, command_unload, NULL, NULL);
    hexchat_hook_command(ph, "RELOAD", HEXCHAT_PRI_NORM, command_reload, NULL, NULL);
    hexchat_hook_command(ph, "lua", HEXCHAT_PRI_NORM, command_lua, command_help, NULL);

    hexchat_printf(ph, "%s version %s loaded.\n", plugin_name, plugin_version);

    scripts = g_ptr_array_new_with_free_func((GDestroyNotify)destroy_script);
    create_interpreter();

    if(!arg)
        autoload_scripts();
    return 1;
}
Beispiel #8
0
static void
gst_info_dump_mem_line (gchar * linebuf, gsize linebuf_size,
    const guint8 * mem, gsize mem_offset, gsize mem_size)
{
  gchar hexstr[50], ascstr[18], digitstr[4];

  if (mem_size > 16)
    mem_size = 16;

  hexstr[0] = '\0';
  ascstr[0] = '\0';

  if (mem != NULL) {
    guint i = 0;

    mem += mem_offset;
    while (i < mem_size) {
      ascstr[i] = (g_ascii_isprint (mem[i])) ? mem[i] : '.';
      g_snprintf (digitstr, sizeof (digitstr), "%02x ", mem[i]);
      g_strlcat (hexstr, digitstr, sizeof (hexstr));
      ++i;
    }
    ascstr[i] = '\0';
  }

  g_snprintf (linebuf, linebuf_size, "%08x: %-48.48s %-16.16s",
      (guint) mem_offset, hexstr, ascstr);
}
Beispiel #9
0
static void _add_property_button_clicked(GtkWidget *widget, gpointer user_data)
{
  dt_lib_camera_t *lib = (dt_lib_camera_t *)user_data;
  const gchar *label = gtk_entry_get_text(GTK_ENTRY(lib->gui.plabel));
  const gchar *property = gtk_entry_get_text(GTK_ENTRY(lib->gui.pname));

  /* let's try to add property */
  if(label && property)
  {
    dt_lib_camera_property_t *prop = NULL;
    if((prop = _lib_property_add_new(lib, label, property)) != NULL)
    {
      gtk_grid_insert_row(lib->gui.main_grid, lib->gui.prop_end); // make space for the new row
      _lib_property_add_to_gui(prop, lib);

      gchar key[256] = { "plugins/capture/tethering/properties/" };
      g_strlcat(key, label, sizeof(key));
      gchar *p = key;
      const char *end = key + strlen(key);
      while(p++ < end)
        if(*p == ' ') *p = '_';
      dt_conf_set_string(key, property);

      /* clean entries */
      gtk_entry_set_text(GTK_ENTRY(lib->gui.plabel), "");
      gtk_entry_set_text(GTK_ENTRY(lib->gui.pname), "");
    }
  }
}
Beispiel #10
0
static void vncws_send_handshake_response(VncState *vs, const char* key)
{
    char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1];
    char *accept = NULL, *response = NULL;
    Error *err = NULL;

    g_strlcpy(combined_key, key, WS_CLIENT_KEY_LEN + 1);
    g_strlcat(combined_key, WS_GUID, WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1);

    /* hash and encode it */
    if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,
                            combined_key,
                            WS_CLIENT_KEY_LEN + WS_GUID_LEN,
                            &accept,
                            &err) < 0) {
        VNC_DEBUG("Hashing Websocket combined key failed %s\n",
                  error_get_pretty(err));
        error_free(err);
        vnc_client_error(vs);
        return;
    }

    response = g_strdup_printf(WS_HANDSHAKE, accept);
    vnc_client_write_buf(vs, (const uint8_t *)response, strlen(response));

    g_free(accept);
    g_free(response);

    vs->encode_ws = 1;
    vnc_init_state(vs);
}
Beispiel #11
0
static void _dt_style_update_from_image(int id, int imgid, GList *filter, GList *update)
{
  if(update && imgid != -1)
  {
    GList *list = filter;
    GList *upd = update;
    char query[4096] = { 0 };
    char tmp[500];
    char *fields[] = { "op_params",       "module",         "enabled",    "blendop_params",
                       "blendop_version", "multi_priority", "multi_name", 0 };
    do
    {
      query[0] = '\0';

      // included and update set, we then need to update the corresponding style item
      if(GPOINTER_TO_INT(upd->data) != -1 && GPOINTER_TO_INT(list->data) != -1)
      {
        g_strlcpy(query, "update style_items set ", sizeof(query));

        for(int k = 0; fields[k]; k++)
        {
          if(k != 0) g_strlcat(query, ",", sizeof(query));
          snprintf(tmp, sizeof(tmp), "%s=(select %s from history where imgid=%d and num=%d)", fields[k],
                   fields[k], imgid, GPOINTER_TO_INT(upd->data));
          g_strlcat(query, tmp, sizeof(query));
        }
        snprintf(tmp, sizeof(tmp), " where styleid=%d and style_items.num=%d", id,
                 GPOINTER_TO_INT(list->data));
        g_strlcat(query, tmp, sizeof(query));
      }
      // update only, so we want to insert the new style item
      else if(GPOINTER_TO_INT(upd->data) != -1)
        snprintf(query, sizeof(query), "insert into style_items "
                                       "(styleid,num,module,operation,op_params,enabled,blendop_params,"
                                       "blendop_version,multi_priority,multi_name) select %d,(select num+1 "
                                       "from style_items where styleid=%d order by num desc limit "
                                       "1),module,operation,op_params,enabled,blendop_params,blendop_version,"
                                       "multi_priority,multi_name from history where imgid=%d and num=%d",
                 id, id, imgid, GPOINTER_TO_INT(upd->data));

      if(*query) DT_DEBUG_SQLITE3_EXEC(dt_database_get(darktable.db), query, NULL, NULL, NULL);

      list = g_list_next(list);
      upd = g_list_next(upd);
    } while(list);
  }
}
Beispiel #12
0
void
append_cgroup_name(char *line, gchar **current_cgroup_name)
{
    gchar *controller, *path, *tmp, *path_plus_space;
    int paren_offset, off, tmp_size;

    controller = g_strstr_len(line, -1, ":") + 1;
    if (!controller)
        return;

    path = g_strstr_len(controller, -1, ":") + 1;
    if (!path)
        return;

    *(path - 1) = '\0';
    g_strdelimit(controller, ",", '/');

    if ((std::strcmp(path, "/") == 0) || (std::strncmp(controller, "name=", 5) == 0))
        return;

    if (*current_cgroup_name == NULL) {
        *current_cgroup_name = g_strdup_printf("%s (%s)", path, controller);
        return;
    }

    /* add a space to the end of the path string */
    path_plus_space = g_strdup_printf("%s ", path);

    if ((tmp = g_strstr_len(*current_cgroup_name, -1, path_plus_space))) {
        tmp_size = strlen(*current_cgroup_name) + strlen(controller) + 1;
        paren_offset = g_strstr_len(tmp + strlen(path), -1, ")") - *current_cgroup_name;
        *(*current_cgroup_name + paren_offset) = '\0';
        tmp = (gchar *)g_strnfill(tmp_size, '\0');
        off = g_strlcat(tmp, *current_cgroup_name, tmp_size);
        *(tmp + off) = '/';
        off++;
        off += g_strlcat(tmp + off, controller, tmp_size);
        *(tmp + off) = ')';
        off++;
        g_strlcat(tmp + off, *current_cgroup_name + paren_offset + 1, tmp_size);
    } else
        tmp = g_strdup_printf("%s, %s(%s)", *current_cgroup_name, path_plus_space, controller);

    g_free(path_plus_space);
    g_free(*current_cgroup_name);
    *current_cgroup_name = tmp;
}
Beispiel #13
0
static gboolean logcat_text_read_packet(FILE_T fh, struct wtap_pkthdr *phdr,
        Buffer *buf, gint file_type) {
    gint8 *pd;
    gchar cbuff[WTAP_MAX_PACKET_SIZE];
    gchar *ret = NULL;

    do {
        ret = file_gets(cbuff, WTAP_MAX_PACKET_SIZE, fh);
    } while (NULL != ret && 3 > strlen(cbuff) && !file_eof(fh));

    if (NULL == ret || 3 > strlen(cbuff)) {
        return FALSE;
    }

    if (WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type &&
            !g_regex_match_simple(SPECIAL_STRING, cbuff, (GRegexCompileFlags)((gint) G_REGEX_ANCHORED | (gint) G_REGEX_RAW), G_REGEX_MATCH_NOTEMPTY)) {
        gint64 file_off = 0;
        gchar lbuff[WTAP_MAX_PACKET_SIZE];
        int err;
        gchar *ret2 = NULL;

        file_off = file_tell(fh);
        ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE, fh);
        while (NULL != ret2 && 2 < strlen(lbuff) && !file_eof(fh)) {
            g_strlcat(cbuff,lbuff,WTAP_MAX_PACKET_SIZE);
            file_off = file_tell(fh);
            ret2 = file_gets(lbuff,WTAP_MAX_PACKET_SIZE, fh);
        }

        if(NULL == ret2 || 2 < strlen(lbuff)) {
            return FALSE;
        }

        file_seek(fh,file_off,SEEK_SET,&err);
    }

    phdr->rec_type = REC_TYPE_PACKET;
    phdr->caplen = (guint32)strlen(cbuff);
    phdr->len = phdr->caplen;

    ws_buffer_assure_space(buf, phdr->caplen + 1);
    pd = ws_buffer_start_ptr(buf);
    if ((WTAP_FILE_TYPE_SUBTYPE_LOGCAT_TIME == file_type
            || WTAP_FILE_TYPE_SUBTYPE_LOGCAT_THREADTIME == file_type
            || WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type)
            && '-' != cbuff[0]) { /* the last part filters out the -- beginning of... lines */
        if (WTAP_FILE_TYPE_SUBTYPE_LOGCAT_LONG == file_type) {
            get_time(cbuff+2, phdr);
        } else {
            get_time(cbuff, phdr);
        }
    } else {
        phdr->presence_flags = 0;
        phdr->ts.secs = (time_t) 0;
        phdr->ts.nsecs = (int) 0;
    }
    memcpy(pd, cbuff, phdr->caplen + 1);
    return TRUE;
}
Beispiel #14
0
MsnSlpMessage *
msn_slpmsg_sip_new(MsnSlpCall *slpcall, int cseq,
				   const char *header, const char *branch,
				   const char *content_type, const char *content)
{
	MsnSlpLink *slplink;
	MsnSlpMessage *slpmsg;
	char *body;
	gsize body_len;
	gsize content_len;

	g_return_val_if_fail(slpcall != NULL, NULL);
	g_return_val_if_fail(header  != NULL, NULL);

	slplink = slpcall->slplink;

	/* Let's remember that "content" should end with a 0x00 */

	content_len = (content != NULL) ? strlen(content) + 1 : 0;

	body = g_strdup_printf(
		"%s\r\n"
		"To: <msnmsgr:%s>\r\n"
		"From: <msnmsgr:%s>\r\n"
		"Via: MSNSLP/1.0/TLP ;branch={%s}\r\n"
		"CSeq: %d\r\n"
		"Call-ID: {%s}\r\n"
		"Max-Forwards: 0\r\n"
		"Content-Type: %s\r\n"
		"Content-Length: %" G_GSIZE_FORMAT "\r\n"
		"\r\n",
		header,
		slplink->remote_user,
		slplink->local_user,
		branch,
		cseq,
		slpcall->id,
		content_type,
		content_len);

	body_len = strlen(body);

	if (content_len > 0)
	{
		body_len += content_len;
		body = g_realloc(body, body_len);
		g_strlcat(body, content, body_len);
	}

	slpmsg = msn_slpmsg_new(slplink);
	msn_slpmsg_set_body(slpmsg, body, body_len);

	slpmsg->sip = TRUE;
	slpmsg->slpcall = slpcall;

	g_free(body);

	return slpmsg;
}
Beispiel #15
0
/** @arg n entry node
 * @arg len size of @a *s in bytes
 * @arg s pointer where result will be saved, error string on failure
 * @retval TRUE on success
 * @retval FALSE on error
 */
gboolean entry_orths_to_string(xmlNodePtr n, int len, char *s)
{
  g_return_val_if_fail(n, FALSE);
  g_return_val_if_fail(s, FALSE);
  g_return_val_if_fail(len>0, FALSE);

  xmlDocPtr doc = copy_node_to_doc(n);

  // find the orth children of the current entry
  xmlNodeSetPtr set = find_node_set("/entry/form/orth", doc, NULL);

  if(!set || !set->nodeNr)
  {
    g_strlcpy(s, _("No nodes (form/orth)!"), len);
    if(set) xmlXPathFreeNodeSet(set);
    xmlFreeDoc(doc);
    return FALSE;
  }

  // alloc temporary buffer
  // if glib offered g_utf8_strlcat(), we would not need
  // this buffer
  char *e = (char *) g_malloc(len);
  e[0] = '\0';

  int i;
  xmlNodePtr *n2;
  for(i=0, n2 = set->nodeTab; *n2 && i<set->nodeNr; n2++, i++)
  {
    xmlChar* content = xmlNodeGetContent(*n2);
    int l = strlen(e);
    if(l) g_strlcat(e, ", ", len);
    if(!content) g_strlcat(e, "(null)", len);
    else g_strlcat(e, (gchar *) content, len);
    if(content) xmlFree(content);
  }

  xmlXPathFreeNodeSet(set);

  // copy again, caring for utf8 chars longer than 1 byte
  g_utf8_strncpy(s, e, len/2);

  g_free(e);
  xmlFreeDoc(doc);
  return TRUE;
}
Beispiel #16
0
static char *
get_default_spell_languages (void)
{
	const gchar* const *langs = g_get_language_names ();
	char *last = NULL;
	char *p;
	char lang_list[64];
	char *ret = lang_list;
	int i;

	if (langs != NULL)
	{
		memset (lang_list, 0, sizeof(lang_list));

		for (i = 0; langs[i]; i++)
		{
			if (g_ascii_strncasecmp (langs[i], "C", 1) != 0 && strlen (langs[i]) >= 2)
			{
				/* Avoid duplicates */
				if (!last || !g_str_has_prefix (langs[i], last))
				{
					if (last != NULL)
					{
						g_free(last);
						g_strlcat (lang_list, ",", sizeof(lang_list));
					}

					/* ignore .utf8 */
					if ((p = strchr (langs[i], '.')))
						*p='\0';

					last = g_strndup (langs[i], 2);

					g_strlcat (lang_list, langs[i], sizeof(lang_list));
				}
			}
		}

		g_free (last);

		if (lang_list[0])
			return g_strdup (ret);
	}

	return g_strdup ("en");
}
Beispiel #17
0
static gchar *get_full_keystr(guint keyval, guint state)
{
	/* strlen("Ctrl+Alt+Shift+Meta+")+1 == 21 */
	const gsize max_modstr_len = 21;
	gchar modstr[max_modstr_len];
	gboolean found = FALSE;
	const gchar *keystr = gdk_keyval_name(keyval);
	const gchar *keystrmap[] = KEYSTRING_MAP;
	modstr[0] = '\0';

	if((state&GDK_SHIFT_MASK) != 0)
	{
		g_strlcat(modstr, "Shift+", max_modstr_len);
	}

	if((state&GDK_CONTROL_MASK) != 0)
	{
		g_strlcat(modstr, "Ctrl+", max_modstr_len);
	}

	if((state&GDK_MOD1_MASK) != 0)
	{
		g_strlcat(modstr, "Alt+", max_modstr_len);
	}

	if((state&GDK_META_MASK) != 0 || (state&GDK_SUPER_MASK) != 0)
	{
		g_strlcat(modstr, "Meta+", max_modstr_len);
	}

	/* Translate GDK key name to mpv key name */
	for(gint i = 0; !found && keystrmap[i]; i += 2)
	{
		gint rc = g_ascii_strncasecmp(	keystr,
						keystrmap[i+1],
						KEYSTRING_MAX_LEN );

		if(rc == 0)
		{
			keystr = keystrmap[i];
			found = TRUE;
		}
	}

	return (strlen(keystr) > 0)?g_strconcat(modstr, keystr, NULL):NULL;
}
Beispiel #18
0
int store(dt_imageio_module_storage_t *self, dt_imageio_module_data_t *sdata, const int imgid,
          dt_imageio_module_format_t *format, dt_imageio_module_data_t *fdata, const int num, const int total,
          const gboolean high_quality, const gboolean upscale, dt_colorspaces_color_profile_type_t icc_type,
          const gchar *icc_filename, dt_iop_color_intent_t icc_intent)
{
  dt_imageio_email_t *d = (dt_imageio_email_t *)sdata;

  _email_attachment_t *attachment = (_email_attachment_t *)g_malloc(sizeof(_email_attachment_t));
  attachment->imgid = imgid;

  /* construct a temporary file name */
  char tmpdir[PATH_MAX] = { 0 };
  dt_loc_get_tmp_dir(tmpdir, sizeof(tmpdir));

  char dirname[PATH_MAX] = { 0 };
  gboolean from_cache = FALSE;
  dt_image_full_path(imgid, dirname, sizeof(dirname), &from_cache);
  gchar *filename = g_path_get_basename(dirname);

  g_strlcpy(dirname, filename, sizeof(dirname));

  dt_image_path_append_version(imgid, dirname, sizeof(dirname));

  gchar *end = g_strrstr(dirname, ".") + 1;

  if(end) *end = '\0';

  g_strlcat(dirname, format->extension(fdata), sizeof(dirname));

  // set exported filename

  attachment->file = g_build_filename(tmpdir, dirname, (char *)NULL);

  if(dt_imageio_export(imgid, attachment->file, format, fdata, high_quality, upscale, FALSE, icc_type, icc_filename,
                       icc_intent, self, sdata, num, total) != 0)
  {
    fprintf(stderr, "[imageio_storage_email] could not export to file: `%s'!\n", attachment->file);
    dt_control_log(_("could not export to file `%s'!"), attachment->file);
    g_free(attachment);
    g_free(filename);
    return 1;
  }


  char *trunc = attachment->file + strlen(attachment->file) - 32;
  if(trunc < attachment->file) trunc = attachment->file;
  dt_control_log(ngettext("%d/%d exported to `%s%s'", "%d/%d exported to `%s%s'", num),
                 num, total, trunc != filename ? ".." : "", trunc);

#ifdef _OPENMP // store can be called in parallel, so synch access to shared memory
#pragma omp critical
#endif
  d->images = g_list_append(d->images, attachment);

  g_free(filename);

  return 0;
}
char *common_utils_get_device_icon(const char *image_path_dir, wifi_device_info_t *device_info)
{
	char tmp_str[MAX_DEVICE_ICON_PATH_STR_LEN] = {'\0', };
	char *ret;

	g_strlcpy(tmp_str, image_path_dir, sizeof(tmp_str));
	g_strlcat(tmp_str, "/37_wifi_icon", sizeof(tmp_str));

	if (device_info->security_mode != WLAN_SEC_MODE_NONE) {
		g_strlcat(tmp_str, "_lock", sizeof(tmp_str));
	}

	switch (wlan_manager_get_signal_strength(device_info->rssi)) {
	case SIGNAL_STRENGTH_TYPE_EXCELLENT:
		g_strlcat(tmp_str, "_03", sizeof(tmp_str));
		break;
	case SIGNAL_STRENGTH_TYPE_GOOD:
		g_strlcat(tmp_str, "_02", sizeof(tmp_str));
		break;
	case SIGNAL_STRENGTH_TYPE_WEAK:
		g_strlcat(tmp_str, "_01", sizeof(tmp_str));
		break;
	case SIGNAL_STRENGTH_TYPE_VERY_WEAK:
	case SIGNAL_STRENGTH_TYPE_NULL:
	default:
		g_strlcat(tmp_str, "_00", sizeof(tmp_str));
		break;
	}

	/* Adding .png to the end of file */
	g_strlcat(tmp_str, ".png", sizeof(tmp_str));

	ret = g_strdup(tmp_str);
	return ret;
}
Beispiel #20
0
static gchar *to_real_key(gchar * confKey, MkdgBackend * backend,
                          const gchar * section, const gchar * key)
{
    gchar *camalCasedKey = gconf2_backend_get_key(backend, section, key, NULL);

    if (!STRING_IS_EMPTY(backend->basePath)) {
        g_strlcpy(confKey, backend->basePath, KEY_BUFFER_SIZE);
        g_strlcat(confKey, "/", KEY_BUFFER_SIZE);
    } else {
        g_strlcpy(confKey, "/", KEY_BUFFER_SIZE);
    }

    if (!STRING_IS_EMPTY(section)) {
        g_strlcat(confKey, section, KEY_BUFFER_SIZE);
        g_strlcat(confKey, "/", KEY_BUFFER_SIZE);
    }
    g_strlcat(confKey, camalCasedKey, KEY_BUFFER_SIZE);
    return confKey;
}
Beispiel #21
0
Datei: calc.c Projekt: zerist/c-
//当小数点按下时
void on_dot_clicked(GtkButton * button, gpointer data){
    gint i;
    if(have_result)
        clear_all(); //全部清除
    if(have_dot == FALSE){
        have_dot = TRUE;
        i = g_strlcat(number, ".", 100);
        gtk_entry_set_text(GTK_ENTRY(entry), number);
    }
}
Beispiel #22
0
/**
 *  set buff_err to the current gfal error, reentrant function
 *  @return pointer to buff_err for convenience
 */
char* gfal_str_GError_r(GError** err, char* buff_err, size_t s_err){
	if(err==NULL || *err==NULL){
		 gfal_log(GFAL_VERBOSE_DEBUG,"copy string NULL error");
		 g_strlcpy(buff_err,"[gfal] No Error reported", s_err);
	}else{
		 g_strlcpy(buff_err,"[gfal]", s_err);
		 g_strlcat(buff_err, (*err)->message, s_err);
	}
	return buff_err;	
 }
Beispiel #23
0
void
misc_exec_file (const gchar *filepath)
{
    gchar *command;

    command = (gchar *) g_malloc (MAX_COMMAND_LENGTH);
    g_strlcpy (command, "xterm -e ", MAX_COMMAND_LENGTH);
    g_strlcat (command, filepath, MAX_COMMAND_LENGTH);
    system (command);
}
Beispiel #24
0
/*
 * @brief
 */
static void S_LoadSampleChunk(s_sample_t *sample) {
	char path[MAX_QPATH];
	void *buf;
	int32_t i, len;
	SDL_RWops *rw;

	if (sample->media.name[0] == '*') // place holder
		return;

	if (sample->media.name[0] == '#') { // global path
		g_strlcpy(path, (sample->media.name + 1), sizeof(path));
	} else { // or relative
		g_snprintf(path, sizeof(path), "sounds/%s", sample->media.name);
	}

	buf = NULL;
	rw = NULL;

	i = 0;
	while (SAMPLE_TYPES[i]) {

		StripExtension(path, path);
		g_strlcat(path, SAMPLE_TYPES[i++], sizeof(path));

		if ((len = Fs_Load(path, &buf)) == -1)
			continue;

		if (!(rw = SDL_RWFromMem(buf, len))) {
			Fs_Free(buf);
			continue;
		}

		if (!(sample->chunk = Mix_LoadWAV_RW(rw, false)))
			Com_Warn("%s\n", Mix_GetError());

		Fs_Free(buf);

		SDL_FreeRW(rw);

		if (sample->chunk) { // success
			break;
		}
	}

	if (sample->chunk) {
		Mix_VolumeChunk(sample->chunk, s_volume->value * MIX_MAX_VOLUME);
		Com_Debug("Loaded %s\n", path);
	} else {
		if (g_str_has_prefix(sample->media.name, "#players")) {
			Com_Debug("Failed to load player sample %s\n", sample->media.name);
		} else {
			Com_Warn("Failed to load %s\n", sample->media.name);
		}
	}
}
void PressNum(GtkButton *button,gpointer data)
        {
            /*创建一个指向字符的指针变量:"num"(用来操作输入量)*/
            const gchar *num;             
            int i;
                                 
            /*控制输入数字的位数*/
            if(num_count == 9)
            return;
          
            /*输入位数记数*/
            num_count++;
          
            /*通过button的label获取每次输入的数值(字符串型)*/
            num=gtk_button_get_label(GTK_BUTTON(button));
          
            /*g_strlcat() 可以用来组合每次输入数字(字符串)起到累加作用*/
            i=g_strlcat(number,num,100);

                                
            /*输入第一个数和第二个数的控制开关,strtod()是把字符串转换为gdouble型*/
            if(first_num )
            {
            /*第一次输入*/
            fnum=strtod(number,NULL);

            }         
            else
            {
                    /*第二次输入*/
                    /*防止除法时除数为0*/
                    if(num_count == 1);
                    snum=strtod(number,NULL);
    
                    if(num_count == 1 && operator ==4 && snum == 0)
                    //gtk_entry_set_text(GTK_ENTRY(entry),"ERROR");
                    return;
            }

           if (number[0]=='0' && number[1]!='.' &&num_count>=2 )
            {
                   gint i;
               for (i =0 ; i<100; i++)
                   {   
                      number[i] = number[i+1];
                   }
            }
                  
            /*把输入的数字显示出来*/
            gtk_entry_set_text(GTK_ENTRY(entry),number);

            //g_print("F:%f\n",fnum);
            //g_print("S:%f\n",snum);

        }
Beispiel #26
0
 static int SaveColors(GtkComboBox *combo)
 {
	int 			f;
	gchar			clr[4096];
	GtkTreeIter 	iter;

#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 12
	gchar			*ptr;
#else
	int				sz;
#endif

	*clr = 0;

 	for(f=0;f < TERMINAL_COLOR_COUNT;f++)
 	{
 		if(f > 0)
			g_strlcat(clr,",",4095);

#if GTK_MAJOR_VERSION >= 2 && GTK_MINOR_VERSION >= 12
		ptr = gdk_color_to_string(color+f);
		g_strlcat(clr,ptr,4095);
		g_free(ptr);
#else
		sz = strlen(clr);
		g_snprintf(clr+sz,4094-sz,"#%04x%04x%04x",(color+f)->red,(color+f)->green,(color+f)->blue);
#endif

 	}

	SetString("Terminal","Colors",clr);

 	if(gtk_combo_box_get_active_iter(combo,&iter))
 	{
		GValue		value	= { 0, };

		gtk_tree_model_get_value(gtk_combo_box_get_model(combo),&iter,1,&value);
		SetString("Terminal","ColorScheme",g_value_get_string(&value));
 	}

 	return 0;
 }
Beispiel #27
0
/**
 * @return A string containing all enabled debug categories.
 */
const char *Com_GetDebug(void) {
	static char debug[MAX_STRING_CHARS];

	debug[0] = '\0';

	for (size_t i = 0; i < lengthof(DEBUG_CATEGORIES); i++) {
		if (quetoo.debug_mask & (1 << i)) {
			if (strlen(debug)) {
				g_strlcat(debug, " ", sizeof(debug));
			}
			g_strlcat(debug, DEBUG_CATEGORIES[i], sizeof(debug));
		}
	}

	if (quetoo.debug_mask & DEBUG_BREAKPOINT) {
		g_strlcat(debug, " breakpoint", sizeof(debug));
	}

	return debug;
}
Beispiel #28
0
bool write_sudo_directives(const GString* data, const gchar* filename, int oflags) {
	gchar sudoers_file[PATH_MAX] = { 0 };
	g_strlcpy(sudoers_file, SUDOERS_PATH, PATH_MAX);
	if (make_dir(sudoers_file, S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) != 0) {
		return false;
	}

	g_strlcat(sudoers_file, filename, PATH_MAX);

	return write_file(data->str, data->len, sudoers_file, oflags, S_IRUSR|S_IRGRP);
}
Beispiel #29
0
Datei: misc.c Projekt: gapan/spkg
gchar* gen_slackdesc(const gchar* sname, gchar* desc[MAX_SLACKDESC_LINES])
{
  gchar buf[MAXLNLEN*MAX_SLACKDESC_LINES];
  buf[0]=0;
  gint i;

  g_assert(sname != 0);
  g_assert(desc != 0);

  for (i=0;i<MAX_SLACKDESC_LINES;i++)
  {
    if (desc[i] == 0)
      break;
    g_strlcat(buf, sname, MAXLNLEN * MAX_SLACKDESC_LINES);
    g_strlcat(buf, ": ", MAXLNLEN * MAX_SLACKDESC_LINES);
    g_strlcat(buf, desc[i], MAXLNLEN * MAX_SLACKDESC_LINES);
    g_strlcat(buf, "\n", MAXLNLEN * MAX_SLACKDESC_LINES);
  }
  return buf[0]?g_strdup(buf):0;
}
Beispiel #30
0
/**
 * Builds the tooltip text for a GtkEntry. Uses the same datatype as
 * used for initializing the auto completion table above.
 *
 * @return g_malloc()'ed string. Must be free'd by the caller.
 */
gchar *
dt_gtkentry_build_completion_tooltip_text (const gchar *header,
    const dt_gtkentry_completion_spec *compl_list)
{
  const unsigned int tooltip_len = 1024;
  gchar *tt = g_malloc0_n(tooltip_len, sizeof(gchar));
  gsize tt_size = sizeof(gchar)*tooltip_len;
  dt_gtkentry_completion_spec const *p;

  g_strlcat(tt, header, tt_size);
  g_strlcat(tt, "\n", tt_size);

  for(p = compl_list; p->description != NULL; p++)
  {
    g_strlcat(tt, p->description, tt_size);
    g_strlcat(tt, "\n", tt_size);
  }

  return tt;
}