client/ibchat_client.c
static int expand_root_dir() {
	/* expand the root dir */
	wordexp_t expanded;
	if(wordexp(ROOT_DIR, &expanded, WRDE_UNDEF) != 0) {
		fprintf(stderr, "failed to expand root dir\n");
		return 1;
	}

	if(expanded.we_wordc != 1) {
		fprintf(stderr, "invalid root dir\n");
		return 1;
	}

	ROOT_DIR = malloc(strlen(expanded.we_wordv[0]) + 2);
	if(ROOT_DIR == NULL) {
		fprintf(stderr, "failed to allocate memory for root dir\n");	

		return 1;
	}

	strcpy(ROOT_DIR, expanded.we_wordv[0]);
	ROOT_DIR[strlen(expanded.we_wordv[0]) + 0] = '/';
	ROOT_DIR[strlen(expanded.we_wordv[0]) + 1] = '\0';

	wordfree(&expanded);

	return 0;
}
/* expands the root directory into a full path */
expands the root directory into a full path
expands the root directory into a full path
static int expand_root_dir() {
	wordexp_t expanded;
	if(wordexp(ROOT_DIR, &expanded, WRDE_UNDEF) != 0) {
		fprintf(stderr, "failed to expand root dir\n");
		return 1;
	}
	if(expanded.we_wordc != 1) {
		fprintf(stderr, "invalid root dir\n");
		return 1;
	}
	ROOT_DIR = malloc(strlen(expanded.we_wordv[0]) + 2);
	if(ROOT_DIR == NULL) {
		fprintf(stderr, "failed to allocate memory for root dir\n");	
		return 1;
	}
	strcpy(ROOT_DIR, expanded.we_wordv[0]);
	ROOT_DIR[strlen(expanded.we_wordv[0]) + 0] = '/';
	ROOT_DIR[strlen(expanded.we_wordv[0]) + 1] = '\0';
	wordfree(&expanded);
	return 0;
}
static int expand_root_dir ( ) { wordexp_t expanded ; if ( wordexp ( ROOT_DIR , & expanded , WRDE_UNDEF ) != 0 ) { fprintf ( stderr , " \n " ) ; return 1 ; } if ( expanded . we_wordc != 1 ) { fprintf ( stderr , " \n " ) ; return 1 ; } ROOT_DIR = malloc ( strlen ( expanded . we_wordv [ 0 ] ) + 2 ) ; if ( ROOT_DIR == NULL ) { fprintf ( stderr , " \n " ) ; return 1 ; } strcpy ( ROOT_DIR , expanded . we_wordv [ 0 ] ) ; ROOT_DIR [ strlen ( expanded . we_wordv [ 0 ] ) + 0 ] = ' ' ; ROOT_DIR [ strlen ( expanded . we_wordv [ 0 ] ) + 1 ] = ' \0 ' ; wordfree ( & expanded ) ; return 0 ; }
expands the root directory into a full path
expands the root directory into a full path
/* expand the root dir */