예제 #1
0
STRPAIR_INFO *strpair_str_mix(STRPAIR_INFO *p_info,
                              UCHAR *str,
                              STRPAIR_CONCAT_MODE mode)
{
     STRLIST tmpstrlist;
     STATUS status;

     switch(mode)
     {
     case AA_S:
       status = strlist_concat(p_info->lstr, p_info->rstr);
       p_info->rstr = strlist_create(str, RO_STR, &status);
       break;
  
     case A_SA:
       tmpstrlist = strlist_create(str, RO_STR, &status);
       status = strlist_concat(tmpstrlist, p_info->rstr);
       p_info->rstr = tmpstrlist;
       break;

     case A_AS:
       tmpstrlist = strlist_create(str, RO_STR, &status);
       status = strlist_concat(p_info->rstr, tmpstrlist);
       break;

     default:
       status = ST_INVALID_FLAG;
     }

     return p_info;
}
예제 #2
0
STRLIST strpair2strlist(STRPAIR_INFO *p_info)
{
     STRLIST slist;

     strlist_concat(p_info->lstr, p_info->rstr);
     slist = p_info->lstr;

     /* we dont need the pair any more */
     free(p_info);

     return slist;
}
예제 #3
0
UCHAR *strpair2string(STRPAIR_INFO *p_info)
{
     UCHAR *str;
     STATUS status;

     strlist_concat(p_info->lstr, p_info->rstr);
     str = strlist2string(p_info->lstr, &status);

     /* we dont need the pair any more */
     free(p_info);

     return str;
}
예제 #4
0
파일: semeru.c 프로젝트: bmellstrom/semeru
static char* create_class_path_option(char *cp) {
  struct strlist parts;
  char *result;
  strlist_init(&parts, 128);
  strlist_add(&parts, "-Djava.class.path=");
  expand_class_path(cp, &parts);
  if (parts.size > 1) {
    strlist_remove_last(&parts); /* last entry is a ':' */
  }
  result = strlist_concat(&parts);
  strlist_destroy(&parts);
  return result;
}
예제 #5
0
STRPAIR_INFO *strpair_concat(STRPAIR_INFO *p_info1,
                             STRPAIR_INFO *p_info2,
                             STRPAIR_CONCAT_MODE mode)
{
     /* this function will move(not copy) all substrings from
      * second pair to first one. And the second pair is destroyed */

     STATUS status;

     switch(mode)
     {
     case AA_BB:
         strlist_concat(p_info1->lstr, p_info1->rstr);
         strlist_concat(p_info2->lstr, p_info2->rstr);
         p_info1->rstr = p_info2->lstr;
         break;

     case A_BAB:
         strlist_concat(p_info2->lstr, p_info1->rstr);
         strlist_concat(p_info2->lstr, p_info2->rstr);
         p_info1->rstr = p_info2->lstr;
         break;

     case AB_BA:
         strlist_concat(p_info1->lstr, p_info2->lstr);
         strlist_concat(p_info2->rstr, p_info1->rstr);
         p_info1->rstr = p_info2->rstr;
         break;

     default:
          status = ST_INVALID_FLAG;
          return NULL;
     }

     /* second pair is destroyed */
     free(p_info2);

     status = ST_SUCCESS;
     return p_info1;
}
예제 #6
0
파일: aptmethod.c 프로젝트: Noctem/reprepro
retvalue aptmethod_newmethod(struct aptmethodrun *run, const char *uri, const char *fallbackuri, const struct strlist *config, struct aptmethod **m) {
	struct aptmethod *method;
	const char *p;

	method = zNEW(struct aptmethod);
	if (FAILEDTOALLOC(method))
		return RET_ERROR_OOM;
	method->mstdin = -1;
	method->mstdout = -1;
	method->child = -1;
	method->status = ams_notstarted;
	p = uri;
	while (*p != '\0' && (*p == '_' || *p == '-' ||
		(*p>='a' && *p<='z') || (*p>='A' && *p<='Z') ||
		(*p>='0' && *p<='9'))) {
		p++;
	}
	if (*p == '\0') {
		fprintf(stderr, "No colon found in method-URI '%s'!\n", uri);
		free(method);
		return RET_ERROR;
	}
	if (*p != ':') {
		fprintf(stderr,
"Unexpected character '%c' in method-URI '%s'!\n", *p, uri);
		free(method);
		return RET_ERROR;
	}
	if (p == uri) {
		fprintf(stderr,
"Zero-length name in method-URI '%s'!\n", uri);
		free(method);
		return RET_ERROR;
	}

	method->name = strndup(uri, p-uri);
	if (FAILEDTOALLOC(method->name)) {
		free(method);
		return RET_ERROR_OOM;
	}
	method->baseuri = strdup(uri);
	if (FAILEDTOALLOC(method->baseuri)) {
		free(method->name);
		free(method);
		return RET_ERROR_OOM;
	}
	if (fallbackuri == NULL)
		method->fallbackbaseuri = NULL;
	else {
		method->fallbackbaseuri = strdup(fallbackuri);
		if (FAILEDTOALLOC(method->fallbackbaseuri)) {
			free(method->baseuri);
			free(method->name);
			free(method);
			return RET_ERROR_OOM;
		}
	}
#define CONF601 "601 Configuration"
#define CONFITEM "\nConfig-Item: "
	if (config->count == 0)
		method->config = strdup(CONF601 CONFITEM "Dir=/" "\n\n");
	else
		method->config = strlist_concat(config,
				CONF601 CONFITEM, CONFITEM, "\n\n");
	if (FAILEDTOALLOC(method->config)) {
		free(method->fallbackbaseuri);
		free(method->baseuri);
		free(method->name);
		free(method);
		return RET_ERROR_OOM;
	}
	method->next = run->methods;
	run->methods = method;
	*m = method;
	return RET_OK;
}