Пример #1
0
int Computed_field_register_types_compose(
	struct Computed_field_package *computed_field_package,
	struct Cmiss_region *root_region)
/*******************************************************************************
LAST MODIFIED : 24 August 2006

DESCRIPTION :
==============================================================================*/
{
	int return_code;
	Computed_field_compose_package
		*computed_field_compose_package =
		new Computed_field_compose_package;

	ENTER(Computed_field_register_types_compose);
	if (computed_field_package && root_region)
	{
		computed_field_compose_package->root_region = root_region;
		return_code = Computed_field_package_add_type(computed_field_package,
			computed_field_compose_type_string,
			define_Computed_field_type_compose,
			computed_field_compose_package);
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_register_types_compose.  Invalid argument(s)");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_register_types_compose */
Пример #2
0
Файл: cmd4.c Проект: jcubic/ToME
/*
 * Recall the most recent message
 */
void do_cmd_message_one(void)
{
	cptr msg = format("> %s", message_str(0));

	/* Recall one message XXX XXX XXX */
	display_message(0, 0, strlen(msg), message_color(0), msg);
}
Пример #3
0
Файл: morph.c Проект: Arnukk/TDS
static int do_init(void)
{
    int i, openerr;
    char *env;
    char searchdir[256], fname[256];

    openerr = 0;

    /* Find base directory for database.  If set, use WNSEARCHDIR.
       If not set, check for WNHOME/dict, otherwise use DEFAULTPATH. */

    if ((env = getenv("WNSEARCHDIR")) != NULL)
	strcpy(searchdir, env);
    else if ((env = getenv("WNHOME")) != NULL)
	sprintf(searchdir, "%s%s", env, DICTDIR);
    else
	strcpy(searchdir, DEFAULTPATH);

    for (i = 1; i <= NUMPARTS; i++) {
	sprintf(fname, EXCFILE, searchdir, partnames[i]);
	if ((exc_fps[i] = fopen(fname, "r")) == NULL) {
	    sprintf(msgbuf,
		    "WordNet library error: Can't open exception file(%s)\n\n",
		    fname);
	    display_message(msgbuf);
	    openerr = -1;
	}
    }
    return(openerr);
}
int Computed_field_register_types_format_output(
	struct Computed_field_package *computed_field_package)
/*******************************************************************************
LAST MODIFIED : 25 August 2006

DESCRIPTION :
==============================================================================*/
{
	int return_code;

	ENTER(Computed_field_register_types_format_output);
	if (computed_field_package)
	{
		return_code = Computed_field_package_add_type(computed_field_package,
			computed_field_format_output_type_string,
			define_Computed_field_type_format_output,
			Computed_field_package_get_simple_package(computed_field_package));
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_register_types_format_output.  Invalid argument(s)");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_register_types_format_output */
Пример #5
0
/*************************************************************************
 *
 *N  get_selected_features
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *    This function gets the selection set for a given theme of the
 *    specified view, either by querying the table, or by reading a
 *    previously saved selection set file.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *     view     <input>==(view_type *) view structure.
 *     themenum <input>==(int) theme number.
 *     library  <input>==(library-type) VPF library structure.
 *     return  <output>==(set_type) set of selected features.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   May 1991                           DOS Turbo C
 *E
 *************************************************************************/
set_type get_selected_features( view_type *view, int themenum,
				library_type library )
{
   set_type selset;
   vpf_table_type ft;
   register int i;

   /* Read a selection set, if present */
   if (strcmp(view->name,"") != 0) {
      selset = read_selected_features( view, themenum );
      if (selset.size > 0) return selset;
   }

   /* No selection set... */

   /* Find the feature class for the theme */
   for (i=0;i<library.nfc;i++)
      if (strcasecmp(library.fc[i].name,view->theme[themenum].fc)==0) break;
   if (i>=library.nfc) {
      display_message("Invalid theme in view");
      return selset;
   }

   /* Query the feature table */
   ft = vpf_open_table( library.fc[i].table, disk, "rb", NULL );
   selset = query_table( view->theme[themenum].expression, ft );
   vpf_close_table( &ft );

   /* Save the selection set so we don't have to query again */
   if (strcmp(view->name,"") != 0) {
      save_selected_features( view, themenum, selset );
   }

   return selset;
}
Пример #6
0
unsigned int playlist_loadlist_mainload(struct playlist_side_info *psi,char *listname,unsigned int loadtype,char *filtermask)
{
 struct listhandler_s *listhand;
 struct playlist_entry_info *laste;
 char loaddir[MAX_PATHNAMELEN];

 display_clear_timed_message();

 display_message(0,0,"Loading list (press ESC to stop) ...");

 laste=psi->lastentry;

 if(loadtype&PLL_STDIN){
  load_m3u(psi,stdin,mpxplay_playlist_startdir(),filtermask);
 }else{
  listhand=select_listhandler_by_ext(listname);
  if(listhand){
   pds_getpath_from_fullname(loaddir,listname);
   listhand->loadlist(psi,listname,loaddir,filtermask);
  }
 }

 if(psi->lastentry>=psi->firstentry)
  playlist_enable_side(psi);
 else
  playlist_disable_side_full(psi);

 clear_message();

 if(psi->lastentry>laste)
  return 1;
 return 0;
}
Пример #7
0
/*
 * Draw the skill tree
 */
void print_skills(s32b **table, s32b max, s32b sel, s32b start)
{
	s32b i, j;
	s32b wid, hgt;
	cptr keys;

	Term_clear();
	Term_get_size(&wid, &hgt);

	c_prt(TERM_WHITE, format("%s Skills Screen", game_module), 0, 28);
	keys = format("#BEnter#W to develop a branch, #Bup#W/#Bdown#W to move, #Bright#W/#Bleft#W to modify, #B?#W for help");
	display_message(0, 1, strlen(keys), TERM_WHITE, keys);
	c_prt((p_ptr->skill_points) ? TERM_L_BLUE : TERM_L_RED,
	      format("Skill points left: %d", p_ptr->skill_points), 2, 0);
	print_desc_aux(s_info[table[sel][0]].desc, 3, 0);

	for (j = start; j < start + (hgt - 7); j++)
	{
		byte color = TERM_WHITE;
		char deb = ' ', end = ' ';

		if (j >= max) break;

		i = table[j][0];

		if (get_skill(i) == 0)
		{
			if (s_info[i].mod == 0) color = TERM_L_DARK;
			else color = TERM_ORANGE;
		}
		else if (get_skill_raw(i) == SKILL_MAX) color = TERM_L_BLUE;
		if (s_info[i].hidden) color = TERM_L_RED;
		if (j == sel)
		{
			color = TERM_L_GREEN;
			deb = '[';
			end = ']';
		}
		if (!has_child(i))
		{
			c_prt(color, format("%c.%c%s", deb, end, s_info[i].name),
			      j + 7 - start, table[j][1] * 4);
		}
		else if (s_info[i].dev)
		{
			c_prt(color, format("%c-%c%s", deb, end, s_info[i].name),
			      j + 7 - start, table[j][1] * 4);
		}
		else
		{
			c_prt(color, format("%c+%c%s", deb, end, s_info[i].name),
				j + 7 - start, table[j][1] * 4);
		}
		c_prt(color,
			format("%c%02ld.%03ld [%01d.%03d]", (get_skill_raw(i) < 0) ? '-' : ' ',
				abs(get_skill_raw(i)) / SKILL_STEP, abs(get_skill_raw(i)) % SKILL_STEP,
				s_info[i].mod / 1000, s_info[i].mod % 1000),
			j + 7 - start, 60);
	}
}
Пример #8
0
int display_usertype(char *buf) {
	char *orig_buf=buf;
	uint32_t size = *((uint32_t*)buf);
	size = ntohl(size);
	buf+=4;
	if(strcmp(buf, "NetworkId")==0 || strcmp(buf, "IdentityId")==0 || strcmp(buf, "BufferId")==0 || strcmp(buf, "MsgId")==0) {
		printf("%s(", buf);
		buf+=strlen(buf)+1;
		buf+=display_int(buf, 0);
		printf(")");
	} else if(strcmp(buf, "Identity")==0) {
		buf+=strlen(buf)+1;
		buf+=display_map(buf);
	} else if(strcmp(buf, "BufferInfo")==0) {
		buf+=strlen(buf)+1;
		buf+=display_bufferinfo(buf);
	} else if(strcmp(buf, "Message")==0) {
		buf+=strlen(buf)+1;
		buf+=display_message(buf);
	} else if(strcmp(buf, "Network::Server")==0) {
		buf+=strlen(buf)+1;
		buf+=display_map(buf);
	} else {
		printf(" Usertype('%s') \n", buf);
		printf("Unsupported.\n");
		exit(0);
	}
	return buf-orig_buf;
}
Пример #9
0
int Option_table_add_set_Cmiss_region_path(struct Option_table *option_table,
	const char *entry_string, struct Cmiss_region *root_region, char **path_address)
/*******************************************************************************
LAST MODIFIED : 13 March 2003

DESCRIPTION :
Adds an entry to the <option_table> with name <entry_name> that returns a
region path in <path_address> relative to the <root_region>.
==============================================================================*/
{
	int return_code = 0;

	ENTER(Option_table_add_set_Cmiss_region_path);
	if (option_table && entry_string && root_region && path_address)
	{
		return_code = Option_table_add_entry(option_table, entry_string,
			(void *)path_address, (void *)root_region,
			set_Cmiss_region_path);
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Option_table_add_set_Cmiss_region_path.  Invalid argument(s)");
	}
	LEAVE;

	return (return_code);
} /* Option_table_add_set_Cmiss_region_path */
Пример #10
0
int Option_table_add_region_path_and_or_field_name_entry(
	struct Option_table *option_table, char *token,
	struct Cmiss_region_path_and_name *region_path_and_name,
	struct Cmiss_region *root_region)
{
	int return_code;

	ENTER(Option_table_add_region_path_and_or_field_name_entry);
	if (option_table && region_path_and_name && root_region)
	{
		return_code = Option_table_add_entry(option_table, token,
			(void *)region_path_and_name, (void *)root_region,
			set_region_path_and_or_field_name);
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Option_table_add_region_path_and_or_field_name_entry.  "
			"Invalid argument(s)");
		return_code=0;
	}
	LEAVE;

	return (return_code);
} /* Option_table_add_region_path_and_or_field_name_entry */
int Computed_field_register_types_gradient_magnitude_recursive_gaussian_image_filter(
	struct Computed_field_package *computed_field_package)
/*******************************************************************************
LAST MODIFIED : 18 October 2006

DESCRIPTION :
==============================================================================*/
{
	int return_code;

	ENTER(Computed_field_register_types_gradient_magnitude_recursive_gaussian_image_filter);
	if (computed_field_package)
	{
		return_code = Computed_field_package_add_type(computed_field_package,
			computed_field_gradient_magnitude_recursive_gaussian_image_filter_type_string,
			define_Computed_field_type_gradient_magnitude_recursive_gaussian_image_filter,
			Computed_field_package_get_simple_package(computed_field_package));
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_register_types_gradient_magnitude_recursive_gaussian_image_filter.  Invalid argument(s)");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_register_types_gradient_magnitude_recursive_gaussian_image_filter */
Пример #12
0
int poll_mouse()
{
   static int _x = -1, _y = -1;
   int ret;
   int x, y;
   __dpmi_regs reg;

   if (!mouse_state)
      return FALSE;

   reg.x.ax = 3;
   __dpmi_int(0x33, &reg);

   m_b = reg.x.bx;
   x = reg.x.cx / 8;
   y = reg.x.dx / 8;

   ret = ((x != _x) || (y != _y) || (m_b));

   if (recording_macro()) {
      if (ret) {
	 strcpy(message, "Can't record mouse actions in a macro");
	 display_message(0);
      }
      m_b = 0;
      _x = x;
      _y = y;
      return FALSE;
   }

   m_x = _x = x;
   m_y = _y = y;
   return ret;
}
Пример #13
0
int Computed_field_get_type_if(struct Computed_field *field,
	struct Computed_field **source_field_one,
	struct Computed_field **source_field_two,
	struct Computed_field **source_field_three)
/*******************************************************************************
LAST MODIFIED : 27 July 2007

DESCRIPTION :
If the field is of type COMPUTED_FIELD_IF, the 
<source_field_one>, <source_field_two> and <source_field_three> used by it
are returned.
==============================================================================*/
{
	int return_code;

	ENTER(Computed_field_get_type_if);
	if (field&&(dynamic_cast<Computed_field_if*>(field->core)))
	{
		*source_field_one = field->source_fields[0];
		*source_field_two = field->source_fields[1];
		*source_field_three = field->source_fields[2];
		return_code=1;
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_get_type_if.  Invalid argument(s)");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_get_type_if */
int Computed_field_register_types_canny_edge_detection_image_filter(
	struct Computed_field_package *computed_field_package)
/*******************************************************************************
LAST MODIFIED : 30 August 2006

DESCRIPTION :
==============================================================================*/
{
	int return_code;

	ENTER(Computed_field_register_types_canny_edge_detection_image_filter);
	if (computed_field_package)
	{
		return_code = Computed_field_package_add_type(computed_field_package,
			computed_field_canny_edge_detection_image_filter_type_string,
			define_Computed_field_type_canny_edge_detection_image_filter,
			Computed_field_package_get_simple_package(computed_field_package));
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_register_types_canny_edge_detection_image_filter.  Invalid argument(s)");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_register_types_canny_edge_detection_image_filter */
Пример #15
0
static void Element_point_tool_reset(void *element_point_tool_void)
/*******************************************************************************
LAST MODIFIED : 25 February 2008

DESCRIPTION :
Resets current edit. Called on button release or when tool deactivated.
==============================================================================*/
{
	struct Element_point_tool *element_point_tool;

	ENTER(Element_point_tool_reset);
	element_point_tool = (struct Element_point_tool *)element_point_tool_void;
	if (element_point_tool != 0)
	{
		REACCESS(Element_point_ranges)(
			&(element_point_tool->last_picked_element_point),
			(struct Element_point_ranges *)NULL);
		REACCESS(Interaction_volume)(
			&(element_point_tool->last_interaction_volume),
			(struct Interaction_volume *)NULL);
	}
	else
	{
		display_message(ERROR_MESSAGE,"Node_tool_reset.  Invalid argument(s)");
	}
	LEAVE;
} /* Element_point_tool_reset */
Пример #16
0
PROTOTYPE_MANAGER_COPY_WITH_IDENTIFIER_FUNCTION(Cmiss_graphics_font,name)
{
	char *name;
	int return_code;

	ENTER(MANAGER_COPY_WITH_IDENTIFIER(Cmiss_graphics_font,name));
	/* check arguments */
	if (source&&destination)
	{
		if (source->name)
		{
			if (ALLOCATE(name,char,strlen(source->name)+1))
			{
				strcpy(name,source->name);
				return_code=1;
			}
			else
			{
				display_message(ERROR_MESSAGE,
"MANAGER_COPY_WITH_IDENTIFIER(Cmiss_graphics_font,name).  Insufficient memory");
				return_code=0;
			}
		}
		else
		{
Пример #17
0
int Computed_field_register_types_fibres(
	struct Computed_field_package *computed_field_package)
/*******************************************************************************
LAST MODIFIED : 24 August 2006

DESCRIPTION :
==============================================================================*/
{
	int return_code;
	Computed_field_fibres_package
		*computed_field_fibres_package =
		new Computed_field_fibres_package;

	ENTER(Computed_field_register_types_fibres);
	if (computed_field_package)
	{
		return_code = Computed_field_package_add_type(computed_field_package,
			computed_field_fibre_axes_type_string,
			define_Computed_field_type_fibre_axes,
			computed_field_fibres_package);
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Computed_field_register_types_fibres.  Invalid argument(s)");
		return_code=0;
	}
	LEAVE;

	return (return_code);
} /* Computed_field_register_types_fibres */
Пример #18
0
double line_segment_distance(double k,double *p1,double *p2,double *p,double q1,
	double q2)
/*******************************************************************************
LAST MODIFIED : 30 August 1996

DESCRIPTION :
Calculates distance potential at a point p from a line segment p1-p2 of charge
(q1,q2)
==============================================================================*/
{
	double a = 0.0,a1,b[3],dist,r[3],return_code,v[3];
	int i;

	ENTER(line_segment_distance);
	/* default return value */
	return_code=0.0;
	/* checking arguments */
	if (p1&&p2&&p)
	{
		for (i=0;i<3;i++)
		{
			b[i]=p[i]-p1[i];
			v[i]=p2[i]-p1[i];
		}
		if (0!=(a1=dot_product3(v,v)))
		{
			a=dot_product3(b,v)/a1;
		}
		if ((a>=0.0)&&(a<=1.0))
		{
			/* point does not extend further than line segment */
			for(i=0;i<3;i++)
			{
				r[i]=b[i]-a*v[i];
			}
			if ((dist=norm3(r)) != 0)
			{
				return_code=k/(dist*dist)*(q1+a*(q2-q1));
			}
			else
			{
				return_code=TEXTURE_LINE_INFINITY;
			}
		}
		else
		{
			return_code=0.0;
		}
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"line_segment_distance.  Invalid argument(s)");
		return_code=0.0;
	}
	LEAVE;

	return (return_code);
} /* line_segment_distance */
Пример #19
0
void TMesh::end_progress()
{
 if (quiet) return;
 if (display_message != NULL) 
  display_message("\n", DISPMSG_ACTION_PUTNEWLINE);
 else
  printf("\n");
}
Пример #20
0
/**
 * Flush the output before displaying for emphasis
 */
void bell_message(game_event_type unused, game_event_data *data, void *user)
{
    /* Flush the output */
    Term_fresh();

    display_message(unused, data, user);
    player->upkeep->redraw |= PR_MESSAGE;
}
Пример #21
0
static int Console_callback(Fdio_id fdio, void *console_void)
/*******************************************************************************
LAST MODIFIED : 27 June 2002

DESCRIPTION :
This function is called to process stdin from a console.
==============================================================================*/
{
#define ESC_KEYCODE '\033'
#define KILL_KEYCODE '\025'
#define MAX_CONSOLE_BUFFER (1000)
	char buffer[MAX_CONSOLE_BUFFER];
	int length, prompt_length, return_code;
	struct Console *console;
#if defined (UNIX)
	int i;
#endif /* defined (UNIX) */

	ENTER(Console_callback);

	USE_PARAMETER(fdio);

	if (NULL != (console=(struct Console *)console_void))
	{
		length = read(console->fd, buffer, MAX_CONSOLE_BUFFER);
		if (length)
		{
			/* Look for control codes */
			buffer[length - 1] = 0;
			return_code=Execute_command_execute_string(console->execute_command,
				buffer);
			if (console->command_prompt)
			{
				prompt_length = strlen(console->command_prompt);
#if defined (UNIX)
				for (i = 0 ; i < prompt_length ; i++)
				{
					/* Put the prompt out to the terminal as if it had been typed in */
					ioctl(console->fd, TIOCSTI, console->command_prompt + i);
				}
#else
				printf("%s", console->command_prompt);
#endif
			}
		}
		return_code = 1;
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"Console_callback.  Missing console");
		return_code = 0;
	}
	LEAVE;

	return (return_code);
} /* Console_callback */
Пример #22
0
static void not_a_vpf_table( char *path )
{
   char *buf,*filename,*tempstr,ch;

   buf = (char *)vpfmalloc(255);
   filename = (char *)vpfmalloc(255);

   /* Not a VPF table - try to determine what type of file it is */
   if (strstr(path,"\\asi") ||
       strstr(path,"\\lsi") ||
       strstr(path,"\\nsi") ||
       strstr(path,"\\csi") ||
       strstr(path,"\\tsi")) {
      sprintf(filename,"%s is a spatial index file.",path);
      displaymessage(filename,
	   "It is not a VPF table and cannot be viewed directly",
	   NULL);
   } else if (strstr(path,".ati") ||
	      strstr(path,".lti") ||
	      strstr(path,".pti") ||
	      strstr(path,".tti")) {
      sprintf(filename,"%s is a thematic index file.",path);
      displaymessage(filename,
	       "It is not a VPF table and cannot be viewed directly",
	       NULL);
   } else if (path[strlen(path)-1] == 'x') {
      /* Need to determine what file it is the index for */
      sprintf(buf,"%s is a variable-length index file",path);
      strcpy(filename,path);
      for (ch='a';ch <= 'z';ch++) {
	 if (ch=='x') continue;
	 filename[strlen(path)-1] = ch;
	 if (access(filename,0) == 0) {
	    tempstr = strdup(filename);
	    sprintf(filename,"for %s.",tempstr);
	    free(tempstr);
	    break;
	 }
      }
      if (strcmp(path,filename)==0) {
	 displaymessage(buf,
	       "It is not a VPF table and cannot be viewed directly.",
	       NULL);
      } else {
	    displaymessage(buf, filename,
	       "It is not a VPF table and cannot be viewed directly.",
	       NULL);
      }
   } else {
      /* Not a VPF type of file */
      sprintf(filename,"%s: Not a VPF table",path);
      display_message(filename);
   }

   free(filename);
   free(buf);
}
Пример #23
0
struct Interactive_tool *CREATE(Interactive_tool)(const char *name,const char *display_name,
	const char *tool_type_name,
	Interactive_event_handler *interactive_event_handler,
	Interactive_tool_bring_up_dialog_function *bring_up_dialog_function,
	Interactive_tool_reset_function *reset_function,
	Interactive_tool_destroy_tool_data_function *destroy_tool_data_function,
	Interactive_tool_copy_function *copy_function,
	void *tool_data)
/*******************************************************************************
LAST MODIFIED : 25 February 2008

DESCRIPTION :
Creates an Interactive_tool with the given <name> and <icon>. If an
<interactive_event_handler> is supplied it is called to pass on any input
events to the interactive_tool, with the <tool_data> passed as the third
parameter.  The <tool_type_name> is used to identify what object type the tool
is and each type of tool should pass a pointer to a static string naming that
type.
==============================================================================*/
{
	struct Interactive_tool *interactive_tool;

	ENTER(CREATE(Interactive_tool));
	if (name&&display_name)
	{
		if (ALLOCATE(interactive_tool,struct Interactive_tool,1)&&
			(interactive_tool->name=duplicate_string(name))&&
			(interactive_tool->display_name=duplicate_string(display_name)))
		{
			/* We don't duplicate this string as it is the pointer to the
				string which identifies its type */
			interactive_tool->tool_type_name=tool_type_name;
			interactive_tool->bring_up_dialog_function=bring_up_dialog_function;
			interactive_tool->reset_function=reset_function;
			interactive_tool->interactive_event_handler=interactive_event_handler;
			interactive_tool->destroy_tool_data_function=destroy_tool_data_function;
			interactive_tool->tool_data=tool_data;
			interactive_tool->copy_function=copy_function;
			interactive_tool->manager = (struct MANAGER(Interactive_tool) *)NULL;
			interactive_tool->manager_change_status = MANAGER_CHANGE_NONE(Interactive_tool);
			interactive_tool->access_count=0;
		}
		else
		{
			display_message(ERROR_MESSAGE,
				"CREATE(Interactive_tool).  Not enough memory");
			if (interactive_tool)
			{
				if (interactive_tool->name)
				{
					DEALLOCATE(interactive_tool->name);
				}
				DEALLOCATE(interactive_tool);
			}
		}
	}
Пример #24
0
int
main (int argc, char *argv[])
{
    Display *display;
    settings_t settings;

    set_defaults(&settings);
    parse_args(argc, argv, &settings);

    display = XOpenDisplay(settings.display_name);
    if (display) {
        XCloseDisplay(display);
        display_message(&settings, "yes");
        exit(EXIT_SUCCESS);
    } else {
        display_message(&settings, "no");
        exit(EXIT_FAILURE);
    }
}
Пример #25
0
void game (void)
{
  int lives = MAX_LIVES;
  int score = 0;
  long int level_score;
  int level = START_LEVEL;
  int result;

  do {
    result = play_level (level, &level_score, lives, score);
    /* The level has been played, now we must check to see what happened, display an appropriate
       message to the terminal if necessary, add up points, etc */
    
    switch (result)
      {	
      case MSG_WINLEVEL:
	score+= level_score;
	level++;
	display_message (result, lives, level, score);
	break;
      case MSG_WINGAME:
	score+= level_score;
	level++; /* This is for the log_score function */
	game_win ();
	
	lives = 0; /* This lets us get out of this function */
	
	/* Display ending message, then go back to menu */
	ansi_PutString (1, 25, "Done.");
	wait_for_select ();
	break;
      case MSG_QUIT: return;
      default: /* We know the users aircraft has crashed in some way, so deduct one life and display a message */
	lives--;
	display_message (result, lives, level, score);
	break;
      }
  } while (lives > 0);

#ifndef __ANDROID__
  log_score (score, level); /* This records the score of anyone who finishes or runs out of lives */
#endif // __ANDROID__
}
Пример #26
0
/*
 * Brings the kernel a swift halt displaying a 
 * message AND CPU registers as an added bonus
 * @param format    The format of the message to display
 */
void panic_cpu(struct regs *r, const char *format, ...)
{
    release_all_locks();
    va_list argp;
    va_start(argp, format);
    display_message(format, argp);
    va_end(argp);
    display_registers(r);
    shut_it_down_charlie_brown();
}
	 int process_command(enum Message_type message_type,const char *format,...)
	 {
			int return_code;
			va_list ap;
			va_start(ap, format);
			vsprintf(message_string,format,ap);
			return_code = display_message(message_type, message_string, "");
			va_end(ap);
			return (return_code);
	 }
Пример #28
0
/*
Global functions
----------------
*/
struct Console *CREATE(Console)(struct Execute_command *execute_command,
	struct Event_dispatcher *event_dispatcher, int file_descriptor)
/*******************************************************************************
LAST MODIFIED : 27 June 2002

DESCRIPTION:
Create the structures and retrieve the command window from the uil file.
==============================================================================*/
{
	struct Console *console;

	ENTER(CREATE(console));
	/* check arguments, file_descriptor can be 0 */
	if (execute_command&&event_dispatcher)
	{
		if (ALLOCATE(console,struct Console,1))
		{
			console->command_prompt = (char *)NULL;
			console->execute_command=execute_command;
			console->event_dispatcher = event_dispatcher;
			console->fd = file_descriptor;
			console->console_fdio =
				Event_dispatcher_create_Fdio(event_dispatcher, file_descriptor);

			if (!console->console_fdio)
			{
				display_message(ERROR_MESSAGE,
					"CREATE(Console).  Unable to register callback for console.");
				DEALLOCATE(console);
				console=(struct Console *)NULL;
			}

			Fdio_set_read_callback(console->console_fdio, Console_callback,
				(void*)console);
		}
		else
		{
			display_message(ERROR_MESSAGE,
				"CREATE(Console).  Insufficient memory for Console structure");
			console=(struct Console *)NULL;
		}
	}
/***************************************************************************//**
 * Command modifier function which converts field into type 'determinant'
 * (if it is not already) and allows its contents to be modified.
 */
int define_Computed_field_type_determinant(struct Parse_state *state,
	void *field_modify_void, void *computed_field_matrix_operators_package_void)
{
	int return_code;

	ENTER(define_Computed_field_type_determinant);
	USE_PARAMETER(computed_field_matrix_operators_package_void);
	Computed_field_modify_data *field_modify =
		reinterpret_cast<Computed_field_modify_data*>(field_modify_void);
	if (state && field_modify)
	{
		return_code = 1;
		cmzn_field_id source_field = 0;
		if (NULL != field_modify->get_field() &&
			(computed_field_determinant_type_string ==
			 Computed_field_get_type_string(field_modify->get_field())))
		{
			source_field = cmzn_field_get_source_field(field_modify->get_field(), 1);
		}
		Option_table *option_table = CREATE(Option_table)();
		Option_table_add_help(option_table,
			"Creates a field returning the scalar real determinant of a square matrix. "
			"Only supports 1, 4 (2x2) and 9 (3x3) component source fields.");
		struct Set_Computed_field_conditional_data set_source_field_data =
		{
			Computed_field_is_square_matrix,
			/*user_data*/0,
			field_modify->get_field_manager()
		};
		Option_table_add_entry(option_table, "field", &source_field,
			&set_source_field_data, set_Computed_field_conditional);
		return_code = Option_table_multi_parse(option_table, state);
		if (return_code)
		{
			return_code = field_modify->update_field_and_deaccess(
				cmzn_fieldmodule_create_field_determinant(field_modify->get_field_module(),
					source_field));
		}
		DESTROY(Option_table)(&option_table);
		if (source_field)
		{
			cmzn_field_destroy(&source_field);
		}
	}
	else
	{
		display_message(ERROR_MESSAGE,
			"define_Computed_field_type_determinant.  Invalid argument(s)");
		return_code=0;
	}
	LEAVE;

	return (return_code);
}
Пример #30
0
int quit(editor_t *ed)
  {
  if (ed->dirty)
    {
    display_message(ed, "Close without saving changes (y/n)? ");
    if (!ask(ed))
      return 0;
    }

  return 1;
  }