コード例 #1
0
ファイル: file_association.c プロジェクト: hownam/fennec
unsigned int fileassociation_geticonid(const string ext)
{
    letter         apext[255];
    letter         apcls[255];
    letter         rvalue[260];
    unsigned long  rvsize = sizeof(rvalue);
    const string   cls_name = uni("fennec.player.file.");
    int            iconid = 0;
    string         pt;

    apext[0] = uni('.');
    str_cpy(apext + 1, ext);

    str_cpy(apcls, cls_name);
    str_cat(apcls, ext); /* i.e. "fennec.player.file.ogg" */
    str_cat(apcls, uni("\\DefaultIcon"));

    if(RegQueryValue(HKEY_CLASSES_ROOT, apcls, rvalue, (PLONG)&rvsize) != ERROR_SUCCESS) goto pt_retdefaultid;
    if(!rvsize) goto pt_retdefaultid;

    pt = str_rchr(rvalue, uni(','));
    if(!pt) goto pt_retdefaultid;
    pt++; /* ',' */

    while(*pt == uni(' '))pt++;

    iconid = str_stoi(pt);
    return iconid;

pt_retdefaultid:

    /* default icon ids */

    return get_default_file_icon(ext);
}
コード例 #2
0
ファイル: Network_Code.cpp プロジェクト: kravitz/transims4
char * Network_Code::Use_Code (int code)
{
	if (code == ANY) {
		str_cpy (buffer, sizeof (buffer), "ANY");
	} else {
		bool first = true;

		buffer [0] = '\0';

		for (int i=0; i <= RESTRICTED; i++) {
			if ((code & use_mask [i]) == use_mask [i]) {
				code -= use_mask [i];

				if (!first) {
					str_cat (buffer, sizeof (buffer), "/");
				} else {
					first = false;
				}
				str_cat (buffer, sizeof (buffer), use_text [i]);
			}
		}
		if (buffer [0] == '\0' || code != 0) {
			if (Send_Messages ()) {
				exe->Error ("Converting Use Code %d", code);
			}
		}
	}
	return (buffer);
}
コード例 #3
0
ファイル: config.c プロジェクト: BackupTheBerlios/arduino
int cfg_init(cfg_s *cfg, int comm_port)
{
	int i;
	char buf[BUFSIZ];

	sprintf(buf, "%d", comm_port);
		
	for (i = 0; i < CFG_IEND; i++)
	{
		cfg->ints[i].key = NULL;
		str_assign(&cfg->ints[i].key, cfg_int_defs[i].key);

		if (comm_port > 0)
			str_cat(&cfg->ints[i].key, buf);
		
		cfg->ints[i].val = cfg_int_defs[i].val;
	}

	for (i = 0; i < CFG_SEND; i++)
	{
		cfg->strs[i].key = NULL;
		str_assign(&cfg->strs[i].key, cfg_str_defs[i].key);

		if (comm_port > 0)
			str_cat(&cfg->strs[i].key, buf);
		
		cfg->strs[i].val = NULL;;
		str_assign(&cfg->strs[i].val, cfg_str_defs[i].val);		
	}
	
	return 0;
}
コード例 #4
0
ファイル: lua.c プロジェクト: genba/clink
//------------------------------------------------------------------------------
static void load_lua_scripts(const char* path)
{
    int i;
    char path_buf[1024];
    HANDLE find;
    WIN32_FIND_DATA fd;

    str_cpy(path_buf, path, sizeof_array(path_buf));
    str_cat(path_buf, "\\", sizeof_array(path_buf));
    i = strlen(path_buf);

    str_cat(path_buf, "*.lua", sizeof_array(path_buf));
    find = FindFirstFile(path_buf, &fd);
    path_buf[i] = '\0';

    while (find != INVALID_HANDLE_VALUE)
    {
        if (_stricmp(fd.cFileName, "clink.lua") != 0)
        {
            str_cat(path_buf, fd.cFileName, sizeof_array(path_buf));
            load_lua_script(path_buf);
            path_buf[i] = '\0';
        }

        if (FindNextFile(find, &fd) == FALSE)
        {
            FindClose(find);
            break;
        }
    }
}
コード例 #5
0
ファイル: string.c プロジェクト: lindenr/Yore
void str_catf (struct String *str, const char *fmt, ...)
{
	char mystr[ATTEMPT_LEN];
	int total_len;

	va_list args;
	va_start (args, fmt);
	total_len = vsnprintf (mystr, ATTEMPT_LEN, fmt, args);
	va_end (args);

	if (total_len < 0)
		panic ("error formatting string in str_catf");

	if (total_len < ATTEMPT_LEN)
	{
		str_cat (str, mystr);
		return;
	}

	/* Try again */
	char *newstr = malloc (total_len + 1);
	va_start (args, fmt);
	vsnprintf (mystr, total_len + 1, fmt, args);
	va_end (args);

	str_cat (str, newstr);
	free (newstr);
}
コード例 #6
0
ファイル: magnet.c プロジェクト: MrJoe/gtk-gnutella
static inline void
magnet_append_item(str_t *s, bool escape_value,
	const char *key, const char *value)
{
	g_return_if_fail(s);
	g_return_if_fail(key);
	g_return_if_fail(value);

	if (0 == str_len(s)) {
		str_cat(s, "magnet:?");
	} else {
		str_putc(s, '&');
	}
	str_cat(s, key);
	str_putc(s, '=');

	if (escape_value) {
		char *escaped;

		escaped = url_escape_query(value);
		str_cat(s, escaped);
		if (escaped != value) {
			HFREE_NULL(escaped);
		}
	} else {
		str_cat(s, value);
	}
}
コード例 #7
0
ファイル: chaine_test.c プロジェクト: CottinThomas/Polytech
/* ----------------- */
void test_str_cat(void)
/* ----------------- */
{
    char *str1, *str2, *ptr;
    int len;
    
    puts("--------------------");
    puts("--- test_str_cat ---");
    puts("--------------------");
    
    str1 = "abc";
    str2 = "defg";
    ptr = str_cat(str1, str2); len = str_len(ptr);
    printf("\"%s\" + \"%s\" = \"%s\"\n", str1, str2, ptr);
    free(ptr); ptr = NULL; // desallocation de la memoire allouee dans str_cat
    
    str1 = "abc";
    str2 = NULL;
    ptr = str_cat(str1, str2); len = str_len(ptr);
    printf("\"%s\" + \"%s\" = \"%s\"\n", str1, str2, ptr);
    free(ptr); ptr = NULL; // desallocation de la memoire allouee dans str_cat
    
    str1 = NULL;
    str2 = "defg";
    ptr = str_cat(str1, str2); len = str_len(ptr);
    printf("\"%s\" + \"%s\" = \"%s\"\n", str1, str2, ptr);
    free(ptr); ptr = NULL; // desallocation de la memoire allouee dans str_cat
    
    str1 = NULL;
    str2 = NULL;
    ptr = str_cat(str1, str2); len = str_len(ptr);
    printf("\"%s\" + \"%s\" = \"%s\"\n", str1, str2, ptr);
    free(ptr); ptr = NULL; // desallocation de la memoire allouee dans str_cat
}
コード例 #8
0
ファイル: header.c プロジェクト: Haxe/gtk-gnutella
/**
 * Add header line to the `headers' hash for specified field name.
 * A private copy of the `field' name and of the `text' data is made.
 */
static void
add_header(header_t *o, const char *field, const char *text)
{
	GHashTable *ht;
	str_t *v;

	header_check(o);

	ht = header_get_table(o);
	v = g_hash_table_lookup(ht, field);
	if (v) {
		/*
		 * Header already exists, according to RFC2616 we need to append
		 * the value, comma-separated.
		 */

		str_cat(v, ", ");
		str_cat(v, text);

	} else {
		char *key;

		/*
		 * Create a new header entry in the hash table.
		 */

		key = h_strdup(field);
		v = str_new_from(text);
		g_hash_table_insert(ht, key, v);
	}
}
コード例 #9
0
ファイル: list-r.c プロジェクト: rsenn/dirlist
static const char*

last_error() {
  DWORD errCode = GetLastError();
  static char tmpbuf[1024];
  char* err;
  tmpbuf[0] = '\0';
  if(errCode == 0)
    return tmpbuf;
  SetLastError(0);
  if(!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                    0,
                    errCode,
                    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* default language */
                    (LPTSTR)&err,
                    0,
                    0))
    return 0;
  str_copy(tmpbuf, "ERROR: ");
  str_cat(tmpbuf, err);
  str_cat(tmpbuf, "\n");

  /* or otherwise log it */
  // OutputDebugString(tmpbuf);
  LocalFree(err);
  return tmpbuf;
}
コード例 #10
0
ファイル: la_loader.c プロジェクト: JustSid/Lite-C
int la_checkFile(STRING *file)
{
	STRING	*filepath;
	la_asset *asset;

	filepath = str_create(work_dir);
	str_cat(filepath, "\\");
	str_cat(filepath, file);
	
	la_lock();
	
	asset = la_assetForFile(_chr(file), _chr(filepath));
	switch(asset->state)
    {
        case LA_ASSET_STATE_LOADED:
        {
            la_unlock();
            ptr_remove(filepath);
            
            return 1;
        }
            break;
        
        case LA_ASSET_STATE_NOSUCHFILE:
        {
            printf("No such file or directory \"%s\"", asset->file);
            
            la_unlock();
            ptr_remove(filepath);
            
            return -1;
        }
            break;
        
        case LA_ASSET_STATE_READFAIL:
        {
            printf("Failed to load \"%s\"", asset->file);
            
            la_unlock();
            ptr_remove(filepath);
            
            return -2;
        }
            break;
        
        default:
            break;
    }
	
	la_unlock();
	ptr_remove(filepath);
	
	return 0;
}
コード例 #11
0
ファイル: Time_Range.cpp プロジェクト: kravitz/transims4
char * Time_Range::Range_Format (int num)
{
	Range_Data *range_ptr = (Range_Data *) Record (num);

	if (range_ptr == NULL) return (NULL);

	str_cpy (buffer, sizeof (buffer), Format_Step (range_ptr->Low ()));
	str_cat (buffer, sizeof (buffer), "..");
	str_cat (buffer, sizeof (buffer), Format_Step (range_ptr->High ()+1));

	return (buffer);
}
コード例 #12
0
ファイル: connections.c プロジェクト: bruceg/srlog2
/* ------------------------------------------------------------------------- */
const char* format_connection(const struct connections_entry* c)
{
  static str s;
  if (!str_copys(&s, ipv4_format(&c->key.ip))) return 0;
  if (!str_catc(&s, '/')) return 0;
  if (!str_catu(&s, c->key.port)) return 0;
  if (!str_catc(&s, '/')) return 0;
  if (!str_cat(&s, &c->data.service->key.sender)) return 0;
  if (!str_catc(&s, '/')) return 0;
  if (!str_cat(&s, &c->data.service->key.service)) return 0;
  if (!str_cats(&s, ": ")) return 0;
  return s.s;
}
コード例 #13
0
ファイル: audio encoder.c プロジェクト: hownam/fennec
int encoder_appendextension(unsigned long id, string fpath)
{
	int v = 0;

	if(fsettings.plugin_settings_getnum("aac", "mp4", &v, 0, 0))v = 0;

	pestreams[id].ismp4 = v;

	if(pestreams[id].ismp4)
		str_cat(pestreams[id].filepath, uni(".mp4"));
	else
		str_cat(pestreams[id].filepath, uni(".aac"));

	return 1;
}
コード例 #14
0
static char *dumptxt(struct rfc1035_reply *r, struct rfc1035_rr *rr)
{
int	len=1;
char	*p=0;
int	pass;
const char *cp;

	for (pass=0; pass<2; pass++)
	{
		if (pass && (p=(char *)malloc(len)) == 0)	return (0);
		if (pass)	*p=0;

		cp=rr->rdata;
		while (cp < rr->rdata+rr->rdlength)
		{
		int l=(int)(unsigned char)*cp;

			if (l >= rr->rdata+rr->rdlength-cp)	return (0);
			if (pass == 0)
				cp += l+1;
			len += l+4;
			if (pass && *p)
				strcat(p, "\n\t\t\t");
			if (pass)
				str_cat(p, &cp);
		}
	}
	return (p);
}
コード例 #15
0
ファイル: tw2.c プロジェクト: kernel-bz/linux-kernel-struct
//문장들을 파일에 출력(k=0: 단어, k=2: 문장)
void tw2_export_to_file (BTREE** hb[], BTREE** wi, int mode, int sh)
{
	char fname[ASIZE], *pfname, buf[ASIZE];
	register int i = 0, h;
	double	msec1, msec2;

	if (!(i = fio_getchar_fname ("Export(txt) FileName: ", fname))) return;

	//미리 초 단위(시작)
	msec1 = time_get_msec ();

	if (sh == 0) {
		//캡션 문장 출력
		fio_export (fname, hb[mode][sh], wi[mode], wi[!mode]);
	} else {
		fname[i] = '_';
		pfname = fname;
		for (h = 1; h < HASHSIZE; h++) {		
			fname[i+1] = '\0';
			str_cat (pfname, uint_to_str (h, buf));	//파일명 끝에 해시번호 추가
			fio_export (pfname, hb[mode][h], wi[mode], wi[!mode]);
		}
	}
	//미리 초 단위(종료)
	msec2 = time_get_msec ();
	//실행시간
	printf ("** Run Time: %.3f Secs\n\n", msec2 - msec1);
}
コード例 #16
0
ファイル: settings.c プロジェクト: CaptainFlint/clink
//------------------------------------------------------------------------------
const char* settings_get_str(settings_t* s, const char* name)
{
    int i;

    // Check for an environment variable override.
    {
        static char buffer[256];

        strcpy(buffer, "clink.");
        str_cat(buffer, name, sizeof_array(buffer));

        if (GetEnvironmentVariableA(buffer, buffer, sizeof_array(buffer)))
        {
            return buffer;
        }
    }

    i = get_decl_index(s, name);
    if (i != -1)
    {
        return s->values[i];
    }

    return "";
}
コード例 #17
0
ファイル: dialogs.c プロジェクト: MasterQ32/SQEditor
function dialogs_init()
{
	STRING *file = "#256";
	make_path(file, "messages.ini");
	int i;
	for(i = 0; i < MAX_DIALOG_ENTRIES; i++)
	{
		/*
		[Message 0]
		text=Oh man, nice bell!
		sound=just_stupid_sound.wav
		*/
		STRING *section = "#64";
		str_cpy(section, "Message ");
		str_cat(section, str_for_int(NULL, i));
		char buffer[256];
		ini_read_buffer(file, section, "text", "FIXIT: You forgot a message here!", buffer, 256);
		
		if(strlen(buffer) > 0)
		{
			dialogEntries[i].initialized = 1;
			dialogEntries[i].text = str_create(buffer);
			
			ini_read_buffer(file, section, "sound", "", buffer, 256);
			if(strlen(buffer) > 0)
				dialogEntries[i].sound = snd_create(buffer);
			else
				dialogEntries[i].sound = NULL;
		}
	}
	
	dialogText = txt_create(1, 20);
	dialogText->flags |= CENTER_X | TRANSLUCENT | OUTLINE;
	dialogText->font = dialogFont;
}
コード例 #18
0
ファイル: ludis.c プロジェクト: simonz05/ludis
/* build a new command by concencate an array 
*  which contains the arguments for the command 
*  returns the len of the command */
int 
format_argv(Str **dest, struct command *cmd)
{
    int i, size;
    char buf[16];
    Str *out;

    cmd->len += 1 + int_len(cmd->argc) + 2;
    out = str_new(cmd->len);
    size = sprintf(buf, "*%d\r\n", cmd->argc);
    out = str_append(out, buf, size);

    /* debug */
    /* printf("len:\t%d\n", cmd->len);
    printf("argc:\t%d\n", cmd->argc);
    printf("data:\t%s\n", out->data); */

    for (i = 0; i < cmd->argc; i++) {
        size = sprintf(buf, "$%d\r\n", cmd->argv[i]->len);
        out = str_append(out, buf, size);
        out = str_cat(out, cmd->argv[i]);
        out = str_append(out, "\r\n", 2);
        str_free(cmd->argv[i]);
    }

    lfree(cmd->argv);
    assert(str_len(out) == cmd->len);
    *dest = out;

    /* debug */
    /*log_proto(out->data);*/
    
    return cmd->len;
}
コード例 #19
0
/*
 * void encrypt_string( STRING *sstr, STRING *estr, int shift )
 *
 * Performs encrypting on a single string. Both the source string
 * (sstr) and the container (estr) must be valid.
 * Additionally a custom shift value can be passed.
 *
 * Another variant using the default shift macro (__SHIFT) can be found below.
 */
void encrypt_string( STRING *sstr, STRING *estr, int shift )
{
	if( !sstr || !estr )
		return;

	sstr = str_create(sstr);
	estr = str_create("");

	STRING *buffer = "";
	int counter = 0;
	int temp_val = 0;
	int length = str_len(sstr);

	while( counter < length )
	{
		str_cpy(buffer, sstr);
		str_clip(buffer, counter);
		str_trunc(buffer, length - counter - 1);
		temp_val = str_to_asc(buffer) + shift;
		str_for_asc(buffer, temp_val);
		str_cat(estr, buffer);

		counter++;
	}
}
コード例 #20
0
static const response* sq_recipient(str* recipient, str* params)
{
  str_cat(&qrecips, recipient);
  str_catc(&qrecips, 0);

  return 0;
  (void)params;
}
コード例 #21
0
ファイル: clink_rl.c プロジェクト: hello-xk/kiwi
//------------------------------------------------------------------------------
static void get_history_file_name(char* buffer, int size)
{
    get_config_dir(buffer, size);
    if (buffer[0])
    {
        str_cat(buffer, "/.history", size);
    }
}
コード例 #22
0
ファイル: s-exp-str.c プロジェクト: honggyukim/uftrace
int main(void)
{
	char *c;

	/*
	 * string arguments are aligned in 8-byte boundary including
	 * 2-byte length prefix so checking strings with length of
	 * 5, 6 and 7 will be enough.
	 */
	str_cpy(a, "hello");
	str_cpy(b, " world");
	c = str_cat(a, b);
	str_cpy(a, "goodbye");
	c = str_cat(a, b);

	return *c ? 0 : 1;
}
コード例 #23
0
ファイル: set.c プロジェクト: NextGenIntelligence/clink
//------------------------------------------------------------------------------
int set(int argc, char** argv)
{
    int ret;

    // Check we're running from a Clink session.
    extern int g_in_clink_context;
    if (!g_in_clink_context)
    {
        puts("ERROR: The 'set' verb must be run from a process with Clink present");
        return 1;
    }

    // Get the path where Clink's storing its settings.
    get_config_dir(g_settings_path, sizeof_array(g_settings_path));
    str_cat(g_settings_path, "/settings", sizeof_array(g_settings_path));

    // Load Clink's settings.
    g_settings = initialise_clink_settings();
    if (g_settings == NULL)
    {
        printf("ERROR: Failed to load Clink's settings from '%s'.", g_settings_path);
        return 1;
    }

    // List or set Clink's settings.
    ret = 0;
    switch (argc)
    {
    case 0:
    case 1:
        ret = print_keys();
        break;

    case 2:
        if (_stricmp(argv[1], "--help") == 0 ||
            _stricmp(argv[1], "-h") == 0)
        {
            ret = 1;
            print_usage();
        }
        else
        {
            ret = print_value(argv[1]);
        }
        break;

    default:
        ret = set_value(argv[1], argv[2]);
        if (!ret)
        {
            settings_save(g_settings, g_settings_path);
        }
        break;
    }

    settings_shutdown(g_settings);
    return ret;
}
コード例 #24
0
void mutt_expand_fmt (char *dest, size_t destlen, const char *fmt,
                      const char *src)
{
  const char *p;
  char *d;
  size_t slen;
  int found = 0;

  slen = str_len (src);
  destlen--;

  for (p = fmt, d = dest; destlen && *p; p++) {
    if (*p == '%') {
      switch (p[1]) {
      case '%':
        *d++ = *p++;
        destlen--;
        break;
      case 's':
        found = 1;
        strfcpy (d, src, destlen + 1);
        d += destlen > slen ? slen : destlen;
        destlen -= destlen > slen ? slen : destlen;
        p++;
        break;
      default:
        *d++ = *p;
        destlen--;
        break;
      }
    }
    else {
      *d++ = *p;
      destlen--;
    }
  }

  *d = '\0';

  if (!found && destlen > 0) {
    str_cat (dest, destlen, " ");
    str_cat (dest, destlen, src);
  }

}
コード例 #25
0
ファイル: backend-echo.c プロジェクト: ser/mailfront
static const response* sender(str* s, str* params)
{
  str_copys(&tmp, "Sender='");
  str_cat(&tmp, s);
  str_cats(&tmp, "'.");
  str_cat_params(&tmp, params);
  resp.message = tmp.s;
  return &resp;
}
コード例 #26
0
int main()
{
	char s[80],t[80];

	gets(s);
	gets(t);
	puts(str_cat(s,t));
	return 0;
}
コード例 #27
0
ファイル: ex5-3.c プロジェクト: redexpress/TCPL-Answers
int main(){
	char *buf;
	char *str = "hello, world!";
	str_cat(buf, str);
	printf("%s\n", buf);
	strcat(buf, str);
	printf("%s\n", buf);
	return 0;
}
コード例 #28
0
ファイル: str_cat.c プロジェクト: rfaisal/hellouniverse
/**
* USAGE: ./a.out string1 string2
**/
int main(int argc, char *argv[]){
	if(argc<3) return 1;
	char* result = malloc((strlen(argv[1])+strlen(argv[2])+1)*sizeof(char));
	strcpy(result,argv[1]); // from c library
	str_cat(result,argv[2]);
	printf("%s",result);
	free(result);
	return 0;
}
コード例 #29
0
ファイル: backend-echo.c プロジェクト: ser/mailfront
static const response* recipient(str* r, str* params)
{
  str_copys(&tmp, "Recipient='");
  str_cat(&tmp, r);
  str_cats(&tmp, "'.");
  str_cat_params(&tmp, params);
  resp.message = tmp.s;
  return &resp;
}
コード例 #30
0
///번역정보를 파일에 출력
int _fio_export_data (FILE *fp, BTREE* wi, void* keys)
{
	char	*ckeys, adigit[ASIZE], sbuf[SSIZE];
	void	*data;
	register int i;
	int		cnt = 0;
	unsigned int *pkey;

	//pkey = malloc (sizeof(unsigned int));
	//Win: <malloc.h>
	//Linux: <alloca.h> 스택에 메모리를 빠르게 할당, scope를 벗어나면 자동해제 되므로 free할 필요없음.
	pkey = alloca (sizeof(unsigned int)); 
	if (!pkey) {
		printf ("## Failure to allocate alloca in _tw1_trans_key_data().\n");
		return 0;  //메모리 할당 실패
	}

	sbuf[0] = '\0';
	ckeys = (char*)keys;
	while (*ckeys) {
		i = 0;
		while ( (adigit[i++] = *ckeys++) != '_');
		i--;
		adigit[i] = '\0';		

		*pkey = str_to_uint (adigit);
		data = bpt_search (wi, pkey);
		if (data) {
			cnt++;
			str_cat (sbuf, data);
		}
		str_cat (sbuf, " ");
	}
	sbuf[str_len (sbuf) - 1] = '\0';	//마지막 공백 제거

	//free (pkey);  //alloca 에서 스택에 할당된 메모리는 scope를 벗어나면 자동으로 해제됨
	str_cat (sbuf, ".\n");
	fputs (sbuf, fp);	//파일에 저장

	//번역 문장 보관용 스택에 입력
	if (cnt > 0) tw2_stack_push (sbuf);

	return cnt;
}