Example #1
0
/*============================
	EVALUATE COMMAND
============================*/
char evaluate_command(char cmd)
{
	switch (cmd)
	{
		case 'i':
		case 'I':
			add_song_to_MusicLibrary();
			break;
		case 'p':
		case 'P':
			print_MusicLibrary();
			break;
		case 'd':
		case 'D':
			delete_command();
			break;
		case 'l':
		case 'L':
			look_up_command();
			break;
		case 'q':
		case 'Q':
			store_MusicLibrary();
			fclose(m_fp);
			printf("quitting\n");
			return 'q';
		default:
			break;
	}
	return 'a';
}
Example #2
0
static void
haiku_child_detach (char *args, int from_tty)
{
	int detached = 1;
	status_t result;

	TRACE(("haiku_child_detach(`%s', %d)\n", args, from_tty));

	result = remove_team_debugger(sTeamDebugInfo.team);
	if (result != B_OK) {
		error("Failed to detach process %ld: %s\n", sTeamDebugInfo.team,
			strerror(result));
	}

	delete_command (NULL, 0);

	if (from_tty) {
		char *exec_file = get_exec_file (0);
		if (exec_file == 0)
			exec_file = "";
		printf_unfiltered ("Detaching from program: %s, Pid %ld\n", exec_file,
			sTeamDebugInfo.team);
		gdb_flush (gdb_stdout);
	}

	haiku_cleanup_team_debug_info();

	inferior_ptid = null_ptid;
	unpush_target (sHaikuTarget);
}
Example #3
0
int main(void)
{
	command_st *lighton_cmd = create_lighton_command();
	command_st *lightoff_cmd = create_lightoff_command();
	remote_control_st *remote_control = create_remote_control();

	remote_control->set_command(remote_control, 0, *lighton_cmd, *lightoff_cmd);

	print_remote_control(remote_control);

	remote_control->on_button_pushed(remote_control, 0);
	remote_control->off_button_pushed(remote_control, 0);

	delete_command(lighton_cmd);
	delete_command(lightoff_cmd);
	delete_remote_control(remote_control);
}
Example #4
0
int delete_message(message* p)
{
	if(p==NULL) return 0;
	delete_command(p->commands);
	delete_notification(p->notifications);
	delete_request(p->requests);
	free(p);
	return 1;
}
Example #5
0
int delete_command(command* p)
{
	if(p==NULL) return 0;
	delete_command(p->next);
	delete_cmd_msg(p->command_message);
	delete_fault_msg(p->fault_message);
	free(p->interface_name);
	free(p->interface_id);
	free(p);
	return 1;
}
Example #6
0
int		main(int argc, char **argv)
{
	t_command 	*command;

	if (!(command = set_command(argc, argv)))
		exit(EXIT_FAILURE);
	if ((read_args(command->paths, command)) == -1)
	{
		delete_command(command);
		exit(EXIT_FAILURE);
	}
} 
Example #7
0
void		del_command_list(t_client *cl)
{
  t_command	*tmp;

  tmp = cl->cmds;
  while (tmp)
    {
      if (strcmp("ok\n", tmp->command) == 0)
	{
	  delete_command(tmp, &cl->cmds);
	  add_client_response(&cl, "ko\n");
	}
      tmp = tmp->next;
    }
}
Example #8
0
int		read_args(t_file *paths, t_command *command)
{
	int		newline;

	if (paths == NULL)
	{
		read_directory(".", command, 0, 0);
		return (1);
	}
	if ((newline = read_args_files(paths, command)) == -1)
		return (-1);
	if (read_arg_dir(paths, command, newline > 0 ? 1 : 0) == -1)
		return (-1);
	delete_command(command);
	return (1);
}
Example #9
0
int delete_interface(interface* p)
{
	if(p==NULL) return 0;
	delete_interface(p->next);
	delete_qualifier(p->qualifiers);
	delete_variable(p->variables);
	delete_command(p->commands);
	delete_notification(p->notifications);
	delete_request(p->requests);
	free(p->name);
	free(p->extends);
	free(p->id);
	free(p->description);
	free(p);
	return 1;
}
Example #10
0
void		do_voir(t_serv *serveur, t_client *client, int cs)
{
  t_view	view;

  printf(LOOK, B, serveur->team[client[cs].team].name, client[cs].id_drone, D);
  memset(view.buffer, 0, BUFF_SIZE);
  strcat(view.buffer, "{");
  if (client[cs].drone->direction == NORTH)
    north_view(serveur, client, cs, &view);
  else if (client[cs].drone->direction == EAST)
    east_view(serveur, client, cs, &view);
  else if (client[cs].drone->direction == SOUTH)
    south_view(serveur, client, cs, &view);
  else if (client[cs].drone->direction == WEST)
    west_view(serveur, client, cs, &view);
  strcat(view.buffer, "}\n");
  xsend(cs, view.buffer, strlen(view.buffer), 0);
  delete_command(client, cs);
  parse_command(serveur, client, cs);
}
void BE_hook_kill(BE_hook * hook) {
  if (!hook) return;

  BE_hook_disable(hook);
  
  if (hook->event->type == BE_EVENT_B) {
    //remove breakpoint
    //TODO What happens if there is more than one event for this breakpoint??
    
    //interrupt and delete breakpoint
    execute_command("interrupt",0);
    wait_for_inferior(); 
    normal_stop();

    char arg[15];
    sprintf(arg, "%d", hook->event->edata.b.bp_id);
    delete_command(arg,0);

    //continue
    continue_command_JG();
  }
}
Example #12
0
int		do_connection(t_serv *serveur, t_client *client, int cs, int i)
{
  if (serveur->team[i].nb_clients - 1 >= 0)
    {
      client[cs].team = i;
      connect_to_drone(serveur, client, cs, i);
      client[cs].timelife = 1000000 *
	(client[cs].drone->nourriture * 126 / serveur->speed);
      client[cs].timelaps = 0;
      client[cs].flag = 0;
      xgettimeofday(&client[cs].life);
      delete_command(client, cs);
      memset(client[cs].buffer, 0, BUFF_SIZE);
      sprintf(client[cs].buffer, "%d\n%d %d\n",
	      --serveur->team[client[cs].team].nb_clients,
	      serveur->world_x, serveur->world_y);
      xsend(cs, client[cs].buffer, strlen(client[cs].buffer), 0);
      if (serveur->graphic_flag)
	send_pnw(serveur, client, cs);
      return (1);
    }
  xsend(cs, KO, strlen(KO), 0);
  return (-1);
}
Example #13
0
void zedit_parse(struct descriptor_data *d, char *arg)
{
  int pos, i = 0;

  switch (OLC_MODE(d)) {
/*-------------------------------------------------------------------*/
  case ZEDIT_CONFIRM_SAVESTRING:
    switch (*arg) {
    case 'y':
    case 'Y':
      /*
       * Save the zone in memory, hiding invisible people.
       */
      SEND_TO_Q("Saving zone info in memory.\r\n", d);
      zedit_save_internally(d);
      sprintf(buf, "OLC: %s edits zone info for room %d.", GET_NAME(d->character), OLC_NUM(d));
      mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE);
      /* FALL THROUGH */
    case 'n':
    case 'N':
      cleanup_olc(d, CLEANUP_ALL);
      break;
    default:
      SEND_TO_Q("Invalid choice!\r\n", d);
      SEND_TO_Q("Do you wish to save the zone info? : ", d);
      break;
    }
    break;
   /* End of ZEDIT_CONFIRM_SAVESTRING */

/*-------------------------------------------------------------------*/
  case ZEDIT_MAIN_MENU:
    switch (*arg) {
    case 'q':
    case 'Q':
      if (OLC_ZONE(d)->age || OLC_ZONE(d)->number) {
	SEND_TO_Q("Do you wish to save the changes to the zone info? (y//n) : ", d);
	OLC_MODE(d) = ZEDIT_CONFIRM_SAVESTRING;
      } else {
	SEND_TO_Q("No changes made.\r\n", d);
	cleanup_olc(d, CLEANUP_ALL);
      }
      break;
    case 'n':
    case 'N':
      /*
       * New entry.
       */
      SEND_TO_Q("What number in the list should the new command be? : ", d);
      OLC_MODE(d) = ZEDIT_NEW_ENTRY;
      break;
    case 'e':
    case 'E':
      /*
       * Change an entry.
       */
      SEND_TO_Q("Which command do you wish to change? : ", d);
      OLC_MODE(d) = ZEDIT_CHANGE_ENTRY;
      break;
    case 'd':
    case 'D':
      /*
       * Delete an entry.
       */
      SEND_TO_Q("Which command do you wish to delete? : ", d);
      OLC_MODE(d) = ZEDIT_DELETE_ENTRY;
      break;
    case 'z':
    case 'Z':
      /*
       * Edit zone name.
       */
      SEND_TO_Q("Enter new zone name : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_NAME;
      break;
    case 't':
    case 'T':
      /*
       * Edit top of zone.
       */
      if (GET_LEVEL(d->character) < LVL_IMPL)
	zedit_disp_menu(d);
      else {
	SEND_TO_Q("Enter new top of zone : ", d);
	OLC_MODE(d) = ZEDIT_ZONE_TOP;
      }
      break;
    case 'l':
    case 'L':
      /*
       * Edit zone lifespan.
       */
      SEND_TO_Q("Enter new zone lifespan : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_LIFE;
      break;
    case 'r':
    case 'R':
      /*
       * Edit zone reset mode.
       */
      SEND_TO_Q("\r\n"
		"0) Never reset\r\n"
		"1) Reset only when no players in zone\r\n"
		"2) Normal reset\r\n"
		"Enter new zone reset type : ", d);
      OLC_MODE(d) = ZEDIT_ZONE_RESET;
      break;
    default:
      zedit_disp_menu(d);
      break;
    }
    break;
    /* End of ZEDIT_MAIN_MENU */

/*-------------------------------------------------------------------*/
  case ZEDIT_NEW_ENTRY:
    /*
     * Get the line number and insert the new line.
     */
    pos = atoi(arg);
    if (isdigit(*arg) && new_command(OLC_ZONE(d), pos)) {
      if (start_change_command(d, pos)) {
	zedit_disp_comtype(d);
	OLC_ZONE(d)->age = 1;
      }
    } else
      zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_DELETE_ENTRY:
    /*
     * Get the line number and delete the line.
     */
    pos = atoi(arg);
    if (isdigit(*arg)) {
      delete_command(OLC_ZONE(d), pos);
      OLC_ZONE(d)->age = 1;
    }
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_CHANGE_ENTRY:
    /*
     * Parse the input for which line to edit, and goto next quiz.
     */
    pos = atoi(arg);
    if (isdigit(*arg) && start_change_command(d, pos)) {
      zedit_disp_comtype(d);
      OLC_ZONE(d)->age = 1;
    } else
      zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_COMMAND_TYPE:
    /*
     * Parse the input for which type of command this is, and goto next
     * quiz.
     */
    OLC_CMD(d).command = toupper(*arg);
    if (!OLC_CMD(d).command || (strchr("MOPEDGR", OLC_CMD(d).command) == NULL)) {
      SEND_TO_Q("Invalid choice, try again : ", d);
    } else {
      if (OLC_VAL(d)) {	/* If there was a previous command. */
	SEND_TO_Q("Is this command dependent on the success of the previous one? (y//n)\r\n", d);
	OLC_MODE(d) = ZEDIT_IF_FLAG;
      } else {	/* 'if-flag' not appropriate. */
	OLC_CMD(d).if_flag = 0;
	zedit_disp_arg1(d);
      }
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_IF_FLAG:
    /*
     * Parse the input for the if flag, and goto next quiz.
     */
    switch (*arg) {
    case 'y':
    case 'Y':
      OLC_CMD(d).if_flag = 1;
      break;
    case 'n':
    case 'N':
      OLC_CMD(d).if_flag = 0;
      break;
    default:
      SEND_TO_Q("Try again : ", d);
      return;
    }
    zedit_disp_arg1(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG1:
    /*
     * Parse the input for arg1, and goto next quiz.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
      if ((pos = real_mobile(atoi(arg))) >= 0) {
	OLC_CMD(d).arg1 = pos;
	zedit_disp_arg2(d);
      } else
	SEND_TO_Q("That mobile does not exist, try again : ", d);
      break;
    case 'O':
    case 'P':
    case 'E':
    case 'G':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg1 = pos;
	zedit_disp_arg2(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    case 'D':
    case 'R':
    default:
      /*
       * We should never get here.
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG1: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG2:
    /*
     * Parse the input for arg2, and goto next quiz.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
    case 'O':
      OLC_CMD(d).arg2 = atoi(arg);
      OLC_CMD(d).arg3 = real_room(OLC_NUM(d));
      zedit_disp_arg4(d);
      break;
    case 'G':
      OLC_CMD(d).arg2 = atoi(arg);
      zedit_disp_arg4(d);
      break;
    case 'P':
    case 'E':
      OLC_CMD(d).arg2 = atoi(arg);
      zedit_disp_arg3(d);
      break;
    case 'D':
      pos = atoi(arg);
      /*
       * Count directions.
       */
      if (pos < 0 || pos > NUM_OF_DIRS)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg2 = pos;
	zedit_disp_arg3(d);
      }
      break;
    case 'R':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg2 = pos;
	zedit_disp_menu(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    default:
      /*
       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG2: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ARG3:
    /*
     * Parse the input for arg3, and goto arg4's menu.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'E':
      pos = atoi(arg);
      /*
       * Count number of wear positions.  We could use NUM_WEARS, this is
       * more reliable.
       */
      while (*equipment_types[i] != '\n')
	i++;
      if (pos < 0 || pos > i)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      }
      break;
    case 'P':
      if ((pos = real_object(atoi(arg))) >= 0) {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      } else
	SEND_TO_Q("That object does not exist, try again : ", d);
      break;
    case 'D':
      pos = atoi(arg);
      if (pos < 0 || pos > 2)
	SEND_TO_Q("Try again : ", d);
      else {
	OLC_CMD(d).arg3 = pos;
        zedit_disp_arg4(d);
      }
      break;
    case 'M':
    case 'O':
    case 'G':
    case 'R':
    default:
      /*
       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;

  case ZEDIT_ARG4:
    /*
     * Parse the input for arg4, and go back to main menu.
     */
    if (!isdigit(*arg)) {
      SEND_TO_Q("Must be a numeric value, try again : ", d);
      return;
    }
    switch (OLC_CMD(d).command) {
    case 'M':
    case 'O':
    case 'G':
    case 'E':
      pos = atoi(arg);
      if (pos < 0 || pos > 100)
        SEND_TO_Q("Try again : ", d);
      else {
        OLC_CMD(d).arg4 = pos;
        zedit_disp_menu(d);
      }
      break;

    case 'P':
    case 'D':
        OLC_CMD(d).arg3 = 100;
      break;

    default:
      /*

       * We should never get here, but just in case...
       */
      cleanup_olc(d, CLEANUP_ALL);
      mudlog("SYSERR: OLC: zedit_parse(): case ARG3: Ack!", BRF, LVL_BUILDER, TRUE);
      SEND_TO_Q("Oops...\r\n", d);
      break;
    }
    break;


/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_NAME:
    /*
     * Add new name and return to main menu.
     */
    if (genolc_checkstring(d, arg)) {
      if (OLC_ZONE(d)->name)
        free(OLC_ZONE(d)->name);
      else
        log("SYSERR: OLC: ZEDIT_ZONE_NAME: no name to free!");
      OLC_ZONE(d)->name = str_dup(arg);
      OLC_ZONE(d)->number = 1;
    }
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_RESET:
    /*
     * Parse and add new reset_mode and return to main menu.
     */
    pos = atoi(arg);
    if (!isdigit(*arg) || pos < 0 || pos > 2)
      SEND_TO_Q("Try again (0-2) : ", d);
    else {
      OLC_ZONE(d)->reset_mode = pos;
      OLC_ZONE(d)->number = 1;
      zedit_disp_menu(d);
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_LIFE:
    /*
     * Parse and add new lifespan and return to main menu.
     */
    pos = atoi(arg);
    if (!isdigit(*arg) || pos < 0 || pos > 240)
      SEND_TO_Q("Try again (0-240) : ", d);
    else {
      OLC_ZONE(d)->lifespan = pos;
      OLC_ZONE(d)->number = 1;
      zedit_disp_menu(d);
    }
    break;

/*-------------------------------------------------------------------*/
  case ZEDIT_ZONE_TOP:
    /*
     * Parse and add new top room in zone and return to main menu.
     */
    if (OLC_ZNUM(d) == top_of_zone_table)
      OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, 32000);
    else
      OLC_ZONE(d)->top = LIMIT(atoi(arg), OLC_ZNUM(d) * 100, zone_table[OLC_ZNUM(d) + 1].number * 100);
    zedit_disp_menu(d);
    break;

/*-------------------------------------------------------------------*/
  default:
    /*
     * We should never get here, but just in case...
     */
    cleanup_olc(d, CLEANUP_ALL);
    mudlog("SYSERR: OLC: zedit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE);
    SEND_TO_Q("Oops...\r\n", d);
    break;
  }
}
Example #14
0
int delete_object(obj_rnum rnum)
{
  obj_rnum i;
  zone_rnum zrnum;
  struct obj_data *obj, *tmp, *next_tmp;
  int shop, j, zone, cmd_no;

  if (rnum == NOTHING || rnum > top_of_objt)
    return NOTHING;
  
  obj = &obj_proto[rnum];

  zrnum = real_zone_by_thing(GET_OBJ_VNUM(obj));

  /* This is something you might want to read about in the logs. */
  log("GenOLC: delete_object: Deleting object #%d (%s).", GET_OBJ_VNUM(obj), obj->short_description);

  for (tmp = object_list; tmp; tmp = next_tmp) {
    next_tmp = tmp->next;
    if (tmp->item_number != obj->item_number)
      continue;

    /* extract_obj() will just axe contents. */
    if (tmp->contains) {
      struct obj_data *this_content, *next_content;
      for (this_content = tmp->contains; this_content; this_content = next_content) {
        next_content = this_content->next_content;
        if (IN_ROOM(tmp)) {
          /* Transfer stuff from object to room. */
          obj_from_obj(this_content);
          obj_to_room(this_content, IN_ROOM(tmp));
        } else if (tmp->worn_by || tmp->carried_by) {
          /* Transfer stuff from object to person inventory. */
          obj_from_char(this_content);
          obj_to_char(this_content, tmp->carried_by);
        } else if (tmp->in_obj) {
          /* Transfer stuff from object to containing object. */
          obj_from_obj(this_content);
          obj_to_obj(this_content, tmp->in_obj);
        }
      }
    }
    /* Remove from object_list, etc. - handles weightchanges, and similar. */
    extract_obj(tmp);
  }

  /* Make sure all are removed. */
  assert(obj_index[rnum].number == 0);

  /* Adjust rnums of all other objects. */
  for (tmp = object_list; tmp; tmp = tmp->next) {
    GET_OBJ_RNUM(tmp) -= (GET_OBJ_RNUM(tmp) > rnum);
  }

  for (i = rnum; i < top_of_objt; i++) {
    obj_index[i] = obj_index[i + 1];
    obj_proto[i] = obj_proto[i + 1];
    obj_proto[i].item_number = i;
  }

  top_of_objt--;
  RECREATE(obj_index, struct index_data, top_of_objt + 1);
  RECREATE(obj_proto, struct obj_data, top_of_objt + 1);

  /* Renumber notice boards. */
  for (j = 0; j < NUM_OF_BOARDS; j++)
    BOARD_RNUM(j) -= (BOARD_RNUM(j) > rnum);

  /* Renumber shop produce. */
  for (shop = 0; shop <= top_shop; shop++)
    for (j = 0; SHOP_PRODUCT(shop, j) != NOTHING; j++)
      SHOP_PRODUCT(shop, j) -= (SHOP_PRODUCT(shop, j) > rnum);

  /* Renumber zone table. */
  for (zone = 0; zone <= top_of_zone_table; zone++) {
    for (cmd_no = 0; ZCMD(zone, cmd_no).command != 'S'; cmd_no++) {
      switch (ZCMD(zone, cmd_no).command) {
      case 'P':
        if (ZCMD(zone, cmd_no).arg3 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg3 -= (ZCMD(zone, cmd_no).arg3 > rnum);
	break;
      case 'O':
      case 'G':
      case 'E':
        if (ZCMD(zone, cmd_no).arg1 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg1 -= (ZCMD(zone, cmd_no).arg1 > rnum);
	break;
      case 'R':
        if (ZCMD(zone, cmd_no).arg2 == rnum) {
          delete_command(&zone_table[zone], cmd_no);
        } else
          ZCMD(zone, cmd_no).arg2 -= (ZCMD(zone, cmd_no).arg2 > rnum);
	break;
      }
    }
  }

  save_objects(zrnum);

  return rnum;
}
Example #15
0
/*
 * cmyth_proginfo_delete_recording(cmyth_conn_t control,
 *                                 cmyth_proginfo_t prog)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Make a request on the control connection 'control' to delete the
 * program 'prog' from the MythTV back end.
 *
 * Return Value:
 *
 * Success: 0
 *
 * Failure: -(ERRNO)
 */
int
cmyth_proginfo_delete_recording(cmyth_conn_t control, cmyth_proginfo_t prog)
{
    return delete_command(control, prog, "DELETE_RECORDING");
}
Example #16
0
int guts(int accept_fd, int listen_fd) {
  
  char buffer[RECV_WINDOW] = "";   // recv buffer
  int msgbuflen = MSG_SIZE;
  char status_msg[MSG_SIZE];
  char *msg; // Incoming message.
  char *send_msg; // Outgoing message.
  char *tmp_msg;
  void *msg_cursor;
  struct response_struct response;   
  int msglen = 0; // length of the assembled message that we receive.
  int recvlen = 0; // how many bytes recv call returns.
  int responselen = 0;   
  int offset;
  int retval;
  char* token_vector[MAX_ARGS] = {'\0'};
  int token_count = 0;

  // Re-register the sigterm handler to our cleanup function.
  signal(SIGTERM, sigterm_handler_child);
  close(listen_fd); // Close this resource from our parent. We don't need it any more.

  while (1) {

    msglen = 0;
    msgbuflen = MSG_SIZE;
    msg = malloc(sizeof(char) * msgbuflen);
    msg_cursor = (void*)msg;
    bzero(msg, msgbuflen);


    // Wait for some data
    while (((recvlen = recv(accept_fd, (void*)buffer, RECV_WINDOW, MSG_PEEK)) == -1) && (errno == EAGAIN));
    if (recvlen == 0) {
      fprintf(stderr, "Client closed the connection.\n");
      close(accept_fd);
      cleanup_and_exit(0);
    };

    // Receive data from our buffered stream until we would block.
    while ((recvlen = recv(accept_fd, (void*)buffer, RECV_WINDOW, 0)) != -1) {
      if (recvlen == 0) {
        fprintf(stderr, "Client closed the connection.\n");
        close(accept_fd);
        cleanup_and_exit(0);
      };

      if (recvlen == -1) {
        fprintf(stderr, "Got error %d from recv.\n", errno);
        close(accept_fd);
        cleanup_and_exit(-1);
      };

      // Extend our message buffer if need be.
      if ((msglen += recvlen) > (msgbuflen)) {
        msgbuflen += msgbuflen;
        offset = msg_cursor - (void*)msg;
        tmp_msg = malloc(sizeof(char) * msgbuflen);
        bzero(tmp_msg, msgbuflen);
        memcpy(tmp_msg, msg, offset);
        msg_cursor = tmp_msg + offset;
        free(msg);
        msg = tmp_msg;
        fprintf(stderr, "msgbuflen expanded to %d\n", msgbuflen);
      }

      memcpy(msg_cursor, (void*)buffer, recvlen);
      msg_cursor += recvlen;
      if (memchr((void*)buffer, '\n', recvlen)) break; // Got a terminator character. Go process our message.

    } 

    tmp_msg = msg;
    strsep(&tmp_msg, "\r\n");

    token_count = tokenize_command(msg, token_vector);

    switch (extract_command(token_vector, token_count))  {

      case 0: // quit
        cleanup_and_exit();
        break;

      case 1: // create
        response = create_command(token_vector, token_count);
        break;

      case 2: // read
        response = read_command(token_vector, token_count);
        break;

      case 3: // delete
        response = delete_command(token_vector, token_count);
        break;

      case 4: // subkeys
        response = keys_command(token_vector, token_count);
        break;

      default:
        if ((response.msg = malloc(sizeof(char) * MSG_SIZE)) == NULL) {
          perror(NULL);
          cleanup_and_exit; 
        }
        bzero(response.msg, MSG_SIZE);
        sprintf(response.msg, "Unknown command.");
        response.status = 1;      
    }

    responselen = prepare_send_msg(response, &send_msg);

    if((send(accept_fd, (void*)send_msg, responselen, 0) == -1)) perror("Send failed");
    free(msg);
    free(response.msg);
    free(send_msg);

  };

  return(0);
}
/*============================================================*/
void BE_hook_array_handle(int breaked, char * filename, int line, int bp_id)
{  
  //check event_t
  int i = 0;
  for (i=0; i<the_context.hook_array.count;i++) {
    BE_hook * curr = BE_hook_array_get(i);  
    clock_t t = clock();
    if (curr->enabled) {
      switch (curr->event->type) {
      case BE_EVENT_T:
	if (t >= curr->event->edata.t.start + curr->event->edata.t.delay) {

	  //stop if not stopped
	  if (!the_context.stopped) {
	    //Abstract this away
	    execute_command("interrupt",0);
	    wait_for_inferior(); 
	    normal_stop();

	    BE_get_file_and_line(get_selected_frame(NULL), &filename, &line); //put these in the BEC

	    the_context.stopped = true;
	    //continue_command_JG();
	  }    

	  
	  BE_hook_handle(curr);
	  
	  if (curr->event->repeat) {
	    curr->event->edata.t.start = t;
	  } else {
	    curr->enabled = false;
	  }
	  
	}
	break;
      case BE_EVENT_B:
	break;
      }
    }
  }

  //check event_b
  for (i=0; i<the_context.hook_array.count;i++) {
    BE_hook * curr = BE_hook_array_get(i);  
    if (curr->enabled) {
      switch (curr->event->type) {
      case BE_EVENT_T:
	break;
      case BE_EVENT_B:
	if (breaked) {
	  if (bp_id == curr->event->edata.b.bp_id)
	  {
	    printf("At the breakpoint for this event!\n");
	    BE_hook_handle(curr);
	    printf("Event handled\n");
	    if (!curr->event->repeat) {
	      char arg[15];
	      sprintf(arg, "%d", curr->event->edata.b.bp_id);
	      delete_command(arg,0);

	      curr->enabled = 0;
	    }
	    
	  }
	}
      }
      
    }
  }  
}
Example #18
0
// show previously created window
int gtk_debugger_enter(int context)
{
#ifndef NO_GDB
	gint type, id, mode;

	if (!dbg_on) gdbtk_show_insight();
#endif

	// debugger is open
	dbg_on = !0;

    // show breakpoint source (modal)
    switch(context)
    {
    case DBG_TRACE:
        break;
    case DBG_BREAK:
        break;
    }

    // display debugger windows (if not)
	gtk_debugger_display();
	gtk_debugger_refresh();

	// enable the debugger if GDB disabled it
	if (!options3.dbg_dock && !GTK_WIDGET_SENSITIVE(dbgw.regs))
		gtk_debugger_enable();

	// handle automatic debugging requests
#ifndef NO_GDB
	if (symfile)
	{
		// get context
		ti68k_bkpt_get_cause(&type, &mode, &id);

		if(type == BK_TYPE_PGMENTRY)
		{
			uint16_t handle, offset;
			uint32_t pc;

			ti68k_bkpt_get_pgmentry_offset(id, &handle, &offset);
			ti68k_bkpt_del_pgmentry(handle);
			if(options3.dbg_dock || GTK_WIDGET_VISIBLE(dbgw.bkpts))
				dbgbkpts_refresh_window();

			delete_command(NULL, 0);
			symbol_file_clear(0);
			gdbtk_clear_file ();
			ti68k_register_get_pc(&pc);
			pc -= offset-2;
			gdb_add_symbol_file(symfile, pc);
			g_free (symfile);
			symfile = NULL;
			exec_build_section_table();

			ti68k_unprotect_64KB_range(pc);

			gdb_hbreak("__main");
		}
	}
#endif

	return 0;
}
Example #19
0
/*
 * Main program
 */
int main(int argc, char **argv) {
    int sock_fd, serv_len, n;
    struct sockaddr_in serv_addr;
    struct hostent *serv;

    struct {
        char message[BUFFER];
        int uuid;
    } msg_in, msg_out;

    /* Generate a random UUID */
    srand(time(NULL));
    uuid = rand();

    clearScreen();

    char *input;
    command *cmd;
    size_t buffer = BUFFER;
    while (TRUE) {
        /* Display prompt */
        printPrompt();

        /* malloc input to memory */
        input = (char *)malloc(sizeof(char) * BUFFER);

        /* Clear msg_in and msg_out */
        bzero((char *)msg_in.message, sizeof(msg_in.message));
        bzero((char *)msg_out.message, sizeof(msg_out.message));
        msg_in.uuid = -1;
        msg_out.uuid = uuid;

        /* Get input */
        getline(&input, &buffer, stdin);
        input[strcspn(input, "\n")] = '\0'; //Remove trailing '\n'

        /* Create command */
        cmd = new_command(input);

        /* Output redirection */
        int file_out, con_out;
        if (cmd->output_file) {
            file_out = open(cmd->output_file, O_WRONLY | O_CREAT | O_TRUNC, 0644);
            if (file_out < 0) {
                perror("open");
                break;
            }
            con_out = dup(STDOUT_FILENO);
            dup2(file_out, STDOUT_FILENO);
            close(file_out);
        }

        /* Execute user command if possible */
        switch (check_command(cmd->name)) {
            case HELP: //help
                printHelp();
                break;
            case FMOUNT: //fmount
                if (serv_uuid != -1) {
                    printf("[ERROR] You are already connected to a server\n");
                    break;
                }
                if (cmd->argc != 2) {
                    printf("[ERROR] Usage: fmount <server>\n");
                    break;
                }

                printf("Connecting to `%s`... ", cmd->argv[1]);
                fflush(stdout); //Safety precaution

                /* Parse server */
                serv = gethostbyname(cmd->argv[1]);

                /* Open UDP socket */
                sock_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
                if (sock_fd < 0) {
                    perror("socket");
                    break;
                }

                /* Write zero's to serv_addr */
                bzero((char *)&serv_addr, sizeof(serv_addr));

                /* Set up server */
                serv_addr.sin_family = AF_INET;
                bcopy(serv->h_addr, (char *)&serv_addr.sin_addr, serv->h_length);
                serv_addr.sin_port = htons(PORT);
                serv_len = sizeof(serv_addr);

                /* Send CONNECT command to server */
                sprintf(msg_out.message, "CONNECT");
                n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                if (n < 0) {
                    perror("sendto");
                    break;
                }

                /* Get response from server */
                n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                if (n < 0) {
                    perror("recvfrom");
                    break;
                }

                if (strcmp(msg_in.message, "CONNECT") != 0) {
                    printf("[ERROR] Invalid response from server\n");
                    break;
                }

                /* Save server UUID */
                serv_uuid = msg_in.uuid;

                /* Clear msg_in and msg_out */
                bzero((char *)&msg_out.message, sizeof(msg_out.message));
                bzero((char *)&msg_in.message, sizeof(msg_in.message));
                msg_out.uuid = uuid;
                msg_in.uuid = -1;

                /* Get SECTOR 0 from server */
                sprintf(msg_out.message, "GETSECTOR 0");
                n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                if (n < 0) {
                    perror("sendto");
                    break;
                }

                /* Get response from server */
                n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                if (n < 0) {
                    perror("recvfrom");
                    break;
                }

                /* Load bytes into Fat12Boot */
                load_boot((unsigned char *)msg_in.message);

                /* malloc Fat12Entry */
                entry = (Fat12Entry *)malloc(sizeof(Fat12Entry) * boot.MAX_ROOT_DIRS);

                /* Request all ROOT_DIRECTORY sector entries */
                for (int i = 0; i < 14; i++) {
                    /* Clear msg_in and msg_out */
                    bzero((char *)&msg_out.message, sizeof(msg_out.message));
                    bzero((char *)&msg_in.message, sizeof(msg_in.message));
                    msg_out.uuid = uuid;
                    msg_in.uuid = -1;

                    /* Get ROOT DIRECTORY sector from server */
                    sprintf(msg_out.message, "GETSECTOR %d", ((boot.NUM_OF_FATS * boot.SECTORS_PER_FAT) + 1) + i);
                    n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                    if (n < 0) {
                        perror("sendto");
                        break;
                    }

                    /* Get response from server */
                    n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                    if (n < 0) {
                        perror("recvfrom");
                        break;
                    }

                    /* Load bytes into Fat12Entry */
                    load_entry(16 * i, (unsigned char *)msg_in.message);
                }

                printf("Connected!\n");
                break;

            case FUMOUNT: //fumount
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to any server\n");
                    break;
                }
                if (cmd->argc != 1) {
                    printf("[ERROR] Usage: fumount\n");
                    break;
                }

                sprintf(msg_out.message, "DISCONNECT");
                n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                if (n < 0) {
                    perror("sendto");
                    break;
                }

                /* Close and write zero's to server */
                close(sock_fd);
                bzero((char *)&serv_addr, sizeof(serv_addr));
                serv_uuid = -1;
                break;

            case STRUCTURE: //structure
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to any server\n");
                    break;
                }
                if (cmd->argc > 2) {
                    printf("[ERROR] Usage: structure [-l]\n");
                    break;
                } else if (cmd->argc == 2) {
                    if (strcmp(cmd->argv[1], "-l") != 0) {
                        printf("[ERROR] Usage: structure [-l]\n");
                        break;
                    }
                }

                printf("        number of FAT:                      %d\n", boot.NUM_OF_FATS);
                printf("        number of sectors used by FAT:      %d\n", boot.SECTORS_PER_FAT);
                printf("        number of sectors per cluster:      %d\n", boot.SECTORS_PER_CLUSTER);
                printf("        number of ROOT Entries:             %d\n", boot.MAX_ROOT_DIRS);
                printf("        number of bytes per sector          %d\n", boot.BYTES_PER_SECTOR);
                if (cmd->argc == 2) {
                    printf("        ---Sector #---      ---Sector Types---\n");
                    printf("             0                    BOOT\n");
                    for (int i = 0; i < boot.NUM_OF_FATS; i++)
                        printf("          %02d -- %02d                FAT%d\n", (boot.SECTORS_PER_FAT * i) + 1, boot.SECTORS_PER_FAT * (i + 1), i);

                    printf("          %02d -- %02d                ROOT DIRECTORY\n", boot.SECTORS_PER_FAT * boot.NUM_OF_FATS, (boot.MAX_ROOT_DIRS / 16) + (boot.SECTORS_PER_FAT * boot.NUM_OF_FATS));
                }
                break;

            case TRAVERSE: //traverse
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to any server\n");
                    break;
                }
                if (cmd->argc > 2) {
                    printf("[ERROR] Usage: traverse [-l]\n");
                    break;
                } else if (cmd->argc == 2) {
                    if (strcmp(cmd->argv[1], "-l") != 0) {
                        printf("[ERROR] Usage: traverse [-l]\n");
                        break;
                    }
                }

                if (cmd->argc == 2) {
                    printf("    *****************************\n");
                    printf("    ** FILE ATTRIBUTE NOTATION **\n");
                    printf("    **                         **\n");
                    printf("    ** R ------ READ ONLY FILE **\n");
                    printf("    ** S ------ SYSTEM FILE    **\n");
                    printf("    ** H ------ HIDDEN FILE    **\n");
                    printf("    ** A ------ ARCHIVE FILE   **\n");
                    printf("    *****************************\n");
                    printf("\n");

                    for (int i = 0; i < boot.MAX_ROOT_DIRS; i++) {
                        if (entry[i].FILENAME[0] != 0x00 && entry[i].START_CLUSTER != 0) {
                            char attr[6] = {'-', '-', '-', '-', '-'};
                            unsigned char a = entry[i].ATTRIBUTES[0];
                            if (a == 0x01)
                                attr[0] = 'R';
                            if (a == 0x02)
                                attr[1] = 'H';
                            if (a == 0x04)
                                attr[2] = 'S';
                            if (a == 0x20)
                                attr[5] = 'A';
                            if (a == 0x10) {
                                for (int j = 0; j < 6; j++)
                                    attr[j] = '-';
                            }

                            if (entry[i].ATTRIBUTES[0] == 0x10) {
                                printf("%.6s    %d %d       < DIR >      /%.8s                 %d\n", attr, entry[i].CREATION_DATE, entry[i].CREATION_TIME, entry[i].FILENAME, entry[i].START_CLUSTER);
                                printf("%.6s    %d %d       < DIR >      /%.8s/.                 %d\n", attr, entry[i].CREATION_DATE, entry[i].CREATION_TIME, entry[i].FILENAME, entry[i].START_CLUSTER);
                                printf("%.6s    %d %d       < DIR >      /%.8s/..                 %d\n", attr, entry[i].CREATION_DATE, entry[i].CREATION_TIME, entry[i].FILENAME, 0);
                            } else {
                                printf("%.6s    %d %d       %lu      /%.8s.%.3s                 %d\n", attr, entry[i].CREATION_DATE, entry[i].CREATION_TIME, entry[i].FILE_SIZE, entry[i].FILENAME, entry[i].EXT, entry[i].START_CLUSTER);
                            }
                        }
                    }
                } else {
                    for (int i = 0; i < boot.MAX_ROOT_DIRS; i++) {
                        if (entry[i].FILENAME[0] != 0x00 && entry[i].START_CLUSTER != 0) {
                            if (entry[i].ATTRIBUTES[0] == 0x10) {
                                printf("/%.8s                       < DIR >\n", entry[i].FILENAME);
                                printf("/%.8s/.                     < DIR >\n", entry[i].FILENAME);
                                printf("/%.8s/..                    < DIR >\n", entry[i].FILENAME);
                            } else {
                                printf("/%.8s.%.3s\n", entry[i].FILENAME, entry[i].EXT);
                            }
                        }
                    }
                }
                break;

            case SHOWFAT: //showfat
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to any server\n");
                    break;
                }
                if (cmd->argc != 1) {
                    printf("[ERROR] Usage: showfat\n");
                    break;
                }

                int sectors = (boot.NUM_OF_FATS * boot.SECTORS_PER_FAT);
                int count = 0;
                printf("        0    1    2    3    4    5    6    7    8    9    a    b    c    d    e    f\n");

                /* Send GETSECTOR command to server */
                for (int i = 1; i <= sectors; i++) {
                    sprintf(msg_out.message, "GETSECTOR %d", i);
                    n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                    if (n < 0) {
                        perror("sendto");
                        break;
                    }

                    /* Get response from server */
                    n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                    if (n < 0) {
                        perror("sendto");
                        break;
                    }

                    /* Check server UUID */
                    if (serv_uuid != msg_in.uuid) {
                        printf("[ERROR] Invalid server UUID - Connection rejected\n");
                        break;
                    }

                    for (int j = 0; j < boot.BYTES_PER_SECTOR; j++) {
                        if (count % 16 == 0 || count == 0) {
                            printf("\n");
                            printf("%4x", count);
                        }
                        printf("%5x", (unsigned char)msg_in.message[j]);
                        count++;
                    }
                }
                printf("\n");
                break;

            case SHOWSECTOR: //showsector
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to any server\n");
                    break;
                }
                if (cmd->argc != 2) {
                    printf("[ERROR] Usage: showsector <sector>\n");
                    break;
                }

                /* Parse sector */
                int sector = atoi(cmd->argv[1]);

                /* Send GETSECTOR command to server */
                sprintf(msg_out.message, "GETSECTOR %d", sector);
                n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                if (n < 0) {
                    perror("sendto");
                    break;
                }

                /* Get response from server */
                n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                if (n < 0) {
                    perror("recvfrom");
                    break;
                }

                /* Check for valid server UUID */
                if (serv_uuid != msg_in.uuid) {
                    printf("[ERROR] Invalid server UUID - Connection rejected\n");
                    break;
                }

                /* Read response */
                printf("        0    1    2    3    4    5    6    7    8    9    a    b    c    d    e    f\n");
                for (int i = 0; i < boot.BYTES_PER_SECTOR; i++) {
                    if (i % 16 == 0 || i == 0) {
                        printf("\n");
                        printf("%4x", i);
                    }
                    printf("%5x", (unsigned char)msg_in.message[i]);
                }
                printf("\n");
                break;

            case SHOWFILE: //showfile
                if (serv_uuid == -1) {
                    printf("[ERROR] You are not connected to a server\n");
                    break;
                }
                if (cmd->argc != 2) {
                    printf("[ERROR] Usage: showfile <filename>\n");
                    break;
                }

                char filename[12] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , '\0'};

                int index = 0, k;
                for (k = 0; k < strlen(cmd->argv[1]) && k < 9; k++) {
                    if (cmd->argv[1][k] == '.') {
                        k++;
                        break;
                    }
                    filename[index] = cmd->argv[1][k];
                    index++;
                }

                index = 8;
                for (int j = k; j < strlen(cmd->argv[1]) && j < 12; j++) {
                    if (cmd->argv[1][j] == '\n' || cmd->argv[1][j] == '\0') {
                        break;
                    }
                    filename[index] = cmd->argv[1][j];
                    index++;
                }

                for (int i = 0; i < boot.MAX_ROOT_DIRS; i++) {
                    if (entry[i].FILENAME != 0x00 && entry[i].START_CLUSTER != 0) {
                        if (compare_char(filename, (char *)entry[i].FILENAME)) {
                            int sector = ((boot.MAX_ROOT_DIRS / 16) + (boot.SECTORS_PER_FAT * boot.NUM_OF_FATS) - 1) + entry[i].START_CLUSTER;
                            int size = (entry[i].FILE_SIZE / 512) + 1;
                            int count = 0;

                            printf("        0    1    2    3    4    5    6    7    8    9    a    b    c    d    e    f\n");
                            for (int p = sector; p <= sector + size + 1; p++) {
                                sprintf(msg_out.message, "GETSECTOR %d", p);
                                n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                                if (n < 0) {
                                    perror("sendto");
                                    break;
                                }

                                n = recvfrom(sock_fd, &msg_in, sizeof(msg_in), 0, (struct sockaddr *)&serv_addr, (socklen_t *)&serv_len);
                                if (n < 0) {
                                    perror("recvfrom");
                                    break;
                                }

                                if (serv_uuid != msg_in.uuid) {
                                    printf("[ERROR] Invalid server UUID - Connection reject\n");
                                    break;
                                }

                                for (int j = 0; j < boot.BYTES_PER_SECTOR; j++) {
                                    if (j % 16 == 0 || j == 0) {
                                        printf("\n");
                                        printf("%4x", count++);
                                    }
                                    printf("%5x", (unsigned char)msg_in.message[j]);
                                }
                            }
                            printf("\n");
                        }
                    }
                }
                break;

            case EXIT: //exit
                free(input);
                delete_command(cmd);

                if (serv_uuid != -1) {
                    /* Send DISCONNECT command to server */
                    sprintf(msg_out.message, "DISCONNECT");
                    n = sendto(sock_fd, &msg_out, sizeof(msg_out), 0, (struct sockaddr *)&serv_addr, (socklen_t)serv_len);
                    if (n < 0) {
                        perror("sendto");
                        exit(EXIT_FAILURE);
                    }

                    close(sock_fd);
                    bzero((char *)&serv_addr, sizeof(serv_addr));
                    serv_uuid = -1;
                }
                exit(EXIT_SUCCESS);

            case INVALID_CMD: //Invalid command (default)
                printf("[ERROR] %s: Command not found\n", cmd->name);
                break;
        }

        fflush(stdout); //Safety precaution

        /* Restore output */
        if (cmd->output_file) {
            dup2(con_out, STDOUT_FILENO);
            close(con_out);
        }

        /* Free memory */
        free(input);
        delete_command(cmd);
    }
}
Example #20
0
/*
 * cmyth_proginfo_forget_recording(cmyth_conn_t control,
 *                                 cmyth_proginfo_t prog)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Make a request on the control connection 'control' to tell the
 * MythTV back end to forget the program 'prog'.
 *
 * Return Value:
 *
 * Success: 0
 *
 * Failure: -(ERRNO)
 */
int
cmyth_proginfo_forget_recording(cmyth_conn_t control, cmyth_proginfo_t prog)
{
    return delete_command(control, prog, "FORGET_RECORDING");
}
Example #21
0
/*
 * cmyth_proginfo_stop_recording(cmyth_conn_t control,
 *                               cmyth_proginfo_t prog)
 *
 * Scope: PUBLIC
 *
 * Description
 *
 * Make a request on the control connection 'control' to ask the
 * MythTV back end to stop recording the program described in 'prog'.
 *
 * Return Value:
 *
 * Success: 0
 *
 * Failure: -(ERRNO)
 */
int
cmyth_proginfo_stop_recording(cmyth_conn_t control, cmyth_proginfo_t prog)
{
    return delete_command(control, prog, "STOP_RECORDING");
}