예제 #1
0
void print_argv() {
	char **v = cl_argv;
	while(*v) {
		printf(have_space(*v) ? "\"%s\"" : "%s", *v);
		if(*++v) putchar(' ');
	}
	putchar('\n');
}
예제 #2
0
파일: stack.c 프로젝트: hungvq00390/FStar
void push_frame(int sz_b) {
  sz_b = word_align(sz_b);
  if (top != NULL && have_space(sz_b+sizeof(void*))) { // can continue with current region
    //printf("push frame in page\n");
    *((void **)top->alloc_ptr) = top->frame_ptr;
    top->frame_ptr = top->alloc_ptr;
    top->alloc_ptr = (void *)((unsigned long)top->alloc_ptr + WORD_SZB);
  } else {
    //printf("push frame on new page\n");
    add_page(sz_b,0);
  }
}
예제 #3
0
파일: stack.c 프로젝트: hungvq00390/FStar
void *stack_alloc(int sz_b) {
  assert(top != NULL);
  sz_b = word_align(sz_b);
 retry: if (have_space(sz_b)) { // can continue with current region
    void *res = top->alloc_ptr;
    //printf("allocated %d bytes\n", sz_b);
    top->alloc_ptr = (void *)((unsigned long)top->alloc_ptr + sz_b);
    return res;
  } else {
    //printf("adding page on demand\n");
    add_page(sz_b,1);
    goto retry;
  }
}
예제 #4
0
void add_arg(const char *arg) {
	size_t len = strlen(arg) + 1;
	//if(have_space(arg)) len += 2;
	int need_quote = have_space(arg);
	//if(need_quote) len += 2;
	if(cc_command_line_length + len + need_quote ? 2 : 0 > cc_command_line_max_length) {
		cc_command_line_max_length += PATH_MAX;
		cc_command_line = realloc(cc_command_line, cc_command_line_max_length);
		if(!cc_command_line) fatal(ENOMEM);
	}
	cc_command_line[cc_command_line_length] = ' ';
	if(need_quote) cc_command_line[++cc_command_line_length] = '\"';
	memcpy(cc_command_line + cc_command_line_length + 1, arg, len);
	cc_command_line_length += len;
	if(need_quote) {
		cc_command_line[cc_command_line_length++] = '\"';
		cc_command_line[cc_command_line_length] = 0;
	}
}
예제 #5
0
파일: help.c 프로젝트: rezalas/riftshadow
void do_help(CHAR_DATA *ch, char *argument)
{
	int numresults=0;
	MYSQL *conn;
	MYSQL_RES *res_set = NULL, *res_set2 = NULL;
	MYSQL_ROW row;
	char query[MSL*2], buf[MSL];

	if(!str_cmp(argument,""))
		return do_help(ch, "topics");
	else
	{
		if((!is_alphanum(argument) && !have_space(argument)) || have_schar(argument))
			return do_help(ch, "topics");
	}

	conn = open_conn();
	if(!conn)
		return send_to_char("Error opening help database.\n\r",ch);

	if(is_number(argument))
		sprintf(query,"select * from helpfiles where id=%d", atoi(argument));
	else if(!is_number(argument))
		sprintf(query,"select * from helpfiles where title RLIKE '%s' ORDER BY id ASC", argument);

	mysql_query(conn,query);
	res_set = mysql_store_result(conn);
	numresults = mysql_affected_rows(conn);
	
	if(!numresults || (res_set == NULL && mysql_field_count(conn)>0))
		send_to_char("No matching helpfiles found.\n\r",ch);
	else if(numresults == 1)
	{
		row = mysql_fetch_row (res_set);
		if(!can_see_help(ch, row, TRUE))
			send_to_char("No matching helpfiles found.\n\r",ch);
		else
			show_helpfile(ch, row);
	}
	else
	{
		sprintf(query,"select * from helpfiles where title RLIKE '\\'%s\\'' OR title = '%s'", argument, argument);
		mysql_query(conn,query);
		res_set2 = mysql_store_result(conn);
		numresults = mysql_affected_rows(conn);
		if(numresults > 0)
		{
			row = mysql_fetch_row(res_set2);
			if(!can_see_help(ch, row, FALSE))
				send_to_char("No matching helpfiles found.\n\r", ch);
			else
			{
				show_helpfile(ch, row);
				mysql_free_result(res_set2);
			}
		}
		else
		{
			send_to_char("Multiple helpfiles matched your request:\n\r",ch);
			while((row = mysql_fetch_row (res_set)) != NULL)
        	{
	   			if(!can_see_help(ch,row, FALSE))
					continue;
	   			sprintf(buf,"%-5s %s\n\r", row[0], row[1]);
	   			send_to_char(buf,ch);
        	}
		}
	}
	mysql_free_result (res_set);
	do_disc(conn);
}