Example #1
0
void hPRIVMSG(struct entity *from, char *target, char *msg) {
	struct user *u = (struct user *)from;

	if (!verify_user(u))
		return;
	if (u->server == me)
		return;

	if (*target == '#')
		hook_call("onchanmsg", pack_args(arg_user(u), arg_chan(get_channel_by_name(target)), arg_str(msg)));
	else
		hook_call("onprivmsg", pack_args(arg_user(u), arg_user(get_user_by_numeric(str2unum(target))), arg_str(msg)));
}
Example #2
0
void playback_pause (void)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    if (! current_decoder || ! current_decoder->pause)
        return;

    paused = ! paused;
    current_decoder->pause (& playback_api, paused);

    if (paused)
        hook_call ("playback pause", NULL);
    else
        hook_call ("playback unpause", NULL);
}
Example #3
0
void audgui_infowin_show (gint playlist, gint entry)
{
    gchar * filename = aud_playlist_entry_get_filename (playlist, entry);
    g_return_if_fail (filename != NULL);

    PluginHandle * decoder = aud_playlist_entry_get_decoder (playlist, entry,
     FALSE);
    if (decoder == NULL)
        goto FREE;

    if (aud_custom_infowin (filename, decoder))
        goto FREE;

    Tuple * tuple = aud_playlist_entry_get_tuple (playlist, entry, FALSE);

    if (tuple == NULL)
    {
        gchar * message = g_strdup_printf (_("No info available for %s.\n"),
         filename);
        hook_call ("interface show error", message);
        g_free (message);
        goto FREE;
    }

    infowin_show (playlist, entry, filename, tuple, decoder,
     aud_file_can_write_tuple (filename, decoder));
    tuple_free (tuple);

FREE:
    g_free (filename);
}
Example #4
0
static gboolean send_clear (void * unused)
{
    G_LOCK (mutex);
    clear_source = 0;
    G_UNLOCK (mutex);

    hook_call ("visualization clear", NULL);
    return FALSE;
}
Example #5
0
void hNOTICE(struct entity *from, char *target, char *msg) {
	struct user *u = (struct user *)from;

	if (!verify_user(u))
		return;
	if (u->server == me)
		return;
	if (*target != '#')
		hook_call("onprivnotc", pack_args(arg_user(u), arg_user(get_user_by_numeric(str2unum(target))), arg_str(msg)));
}
Example #6
0
bool_t handle_window_close (void)
{
    bool_t handled = FALSE;
    hook_call ("window close", & handled);

    if (! handled)
        aud_drct_quit ();

    return TRUE;
}
Example #7
0
static gboolean window_delete()
{
    gboolean handle = FALSE;

    hook_call("window close", &handle);

    if (handle)
        return TRUE;

    aud_drct_quit ();
    return TRUE;
}
Example #8
0
void hPART(struct user *user, char *channels, char *reason) {
	struct manyargs chlist;
	struct channel *c;
	int i;
	VERIFY_USER(user);

	split(&chlist, channels, ',');
	for (i = 0; i < chlist.c; i++) {
		c = get_channel_by_name(chlist.v[i]);
		VERIFY_CHANNEL(c);
		hook_call("onpart", pack_args(arg_user(user), arg_chan(c), arg_str(reason ? reason : "")));
		chanusers_leave(user, c);
	}
}
Example #9
0
static bool_t end_cb (void * unused)
{
    g_return_val_if_fail (playing, FALSE);

    hook_call ("playback end", NULL);

    if (playback_error)
        failed_entries ++;
    else
        failed_entries = 0;

    playback_cleanup ();

    int playlist = playlist_get_playing ();
    bool_t play;

    if (get_bool (NULL, "no_playlist_advance"))
        play = get_bool (NULL, "repeat") && ! failed_entries;
    else if (! (play = playlist_next_song (playlist, get_bool (NULL, "repeat"))))
        playlist_set_position (playlist, -1);
    else if (failed_entries >= 10)
        play = FALSE;

    if (get_bool (NULL, "stop_after_current_song"))
        play = FALSE;

    if (play)
        playback_start (playlist, playlist_get_position (playlist), 0, FALSE);
    else
    {
        complete_stop ();
        hook_call ("playlist end reached", NULL);
    }

    return FALSE;
}
Example #10
0
static bool_t event_execute (Event * event)
{
    pthread_mutex_lock (& mutex);

    g_source_remove (event->source);
    events = g_list_remove (events, event);

    pthread_mutex_unlock (& mutex);

    hook_call (event->name, event->data);

    g_free (event->name);
    if (event->destroy)
        event->destroy (event->data);

    g_slice_free (Event, event);
    return FALSE;
}
Example #11
0
void playback_seek (int time)
{
    g_return_if_fail (playing);
    wait_until_ready ();

    if (! current_decoder || ! current_decoder->mseek || current_length < 1)
        return;

    current_decoder->mseek (& playback_api, time_offset + CLAMP (time, 0,
     current_length));

    /* If the plugin is using our output system, don't call "playback seek"
     * immediately but wait for output_set_time() to be called.  This ensures
     * that a "playback seek" handler can call playback_get_time() and get the
     * new time. */
    if (! output_is_open ())
        hook_call ("playback seek", NULL);
}
Example #12
0
static void playback_start (int playlist, int entry, int seek_time, bool_t pause)
{
    g_return_if_fail (! playing);

    current_filename = playlist_entry_get_filename (playlist, entry);
    g_return_if_fail (current_filename);

    playing = TRUE;
    playback_error = FALSE;
    ready_flag = FALSE;

    current_entry = -1;
    current_title = NULL;
    current_length = 0;

    initial_seek = seek_time;
    paused = pause;

    hook_associate ("playlist update", update_cb, NULL);
    pthread_create (& playback_thread_handle, NULL, playback_thread, NULL);

    hook_call ("playback begin", NULL);
}
Example #13
0
bool_t iface_plugin_set_current (PluginHandle * plugin)
{
    hook_call ("config save", NULL); /* tell interface to save layout */

    if (current_plugin != NULL)
    {
        AUDDBG ("Unloading plugin widgets.\n");
        general_cleanup ();

        AUDDBG ("Unloading visualizers.\n");
        vis_cleanup ();

        AUDDBG ("Unloading %s.\n", plugin_get_name (current_plugin));
        interface_unload ();

        current_plugin = NULL;
    }

    if (plugin != NULL)
    {
        AUDDBG ("Loading %s.\n", plugin_get_name (plugin));

        if (! interface_load (plugin))
            return FALSE;

        current_plugin = plugin;

        AUDDBG ("Loading visualizers.\n");
        vis_init ();

        AUDDBG ("Loading plugin widgets.\n");
        general_init ();
    }

    return TRUE;
}
Example #14
0
void hook_call_v(const WHook *hk)
{
    hook_call(hk, NULL, marshall_v, marshall_extl_v);
}
Example #15
0
void hQUIT(struct user *from, char *reason) {
	VERIFY_USER(from);
	hook_call("onquit", pack_args(arg_user(from), arg_str(reason ? reason : "")));
	del_user(from);
}
Example #16
0
static void complete_stop (void)
{
    output_drain ();
    hook_call ("playback stop", NULL);
    set_bool (NULL, "stop_after_current_song", FALSE);
}
Example #17
0
/**
 * Check content of file in non-regexp mode
 *
 * @param __name - name of file to check
 * @param __full_name - full name of file
 * @param __options - finding options
 * @param __res_wnd - window with search results
 * @return zero if file in unwanted, non-zero otherwise
 */
static BOOL
check_simple_content (const wchar_t *__name, const wchar_t *__full_name,
                      const action_find_options_t *__options,
                      action_find_res_wnd_t *__res_wnd)
{
  int res;
  BOOL matched = FALSE;
  vfs_file_t file;
  char *buf;
  char read_buf[BUF_SIZE];
  size_t content_len, content_hash;
  size_t i, n, h, d;
  size_t buf_len;

#ifdef __FILE_OFFSET64
  file = vfs_open (__full_name, O_LAGEFILE, 0);
#else
  file = vfs_open (__full_name, 0, 0);
#endif

  if (!file)
    {
      /* Error opening file */
      return FALSE;
    }

  content_len = strlen (__options->mb_content);

  buf = malloc (content_len + BUF_SIZE);

  /* Calculate hash for content to search */
  content_hash = 0;
  for (i = 0; i < content_len; ++i)
    {
      content_hash += (unsigned char)__options->mb_content[i];
    }

  /* Read initial buffer */
  res = vfs_read (file, buf, content_len);
  if (res == content_len)
    {
      bool case_insens;
      case_insens = !TEST_FLAG (__options->flags,
                                AFF_CONTENT_CASE_SENSITIVE);

      /* If initial buffer less than content length */
      /* we can't operate */

      buf_len = content_len;
      buf[buf_len] = 0;

      /* Calculate hash of initial buffer */
      h = 0;
      for (i = 0; i < buf_len; ++i)
        {
          if (case_insens)
            {
              buf[i] = tolower (buf[i]);
            }
          h += (unsigned char)buf[i];
        }

      for (;;)
        {
          n = buf_len - content_len;
          for (i = 0; i <= n; ++i)
            {
              /* IF hashes are equal, we can't guarantee strings are equal */
              /* We should ensure in it */
              if (h == content_hash)
                {
                  if (!strncmp (buf + i, __options->mb_content, content_len) )
                    {
                      matched = TRUE;
                      break;
                    }
                }
              else
                {
                  h -= (unsigned char)buf[i];
                  h += (unsigned char)buf[i + content_len];
                }
            }

          if (matched)
            {
              /* If file contains needed content, */
              /* we can break this stupid cycle */
              break;
            }

          hook_call (L"switch-task-hook", NULL);

          if (ACTION_PERFORMED (__res_wnd))
            {
              break;
            }

          /* Read next buffer */
          res = vfs_read (file, read_buf, BUF_SIZE);

          /* There is no new buffer to use */
          if (res <= 0)
            {
              break;
            }

          read_buf[res] = 0;

          if (case_insens)
            {
              lowercase_buffer (read_buf, res);
            }

          /* Shift overviewed buffer */
          d = buf_len - content_len + 1;
          for (i = 0; i < buf_len - d; ++i)
            {
              buf[i] = buf[i + d];
            }

          /* Append new data */
          memcpy (buf + i, read_buf, res + 1);

          h += (unsigned char)buf[content_len - 1];
          buf_len += res - d;
        }
    }

  vfs_close (file);
  free (buf);

  return matched;
}
Example #18
0
/* handle keys */
gboolean handle_keyevent (EVENT event)
{
    gint current_volume, old_volume;
    static gint volume_static = 0;
    gboolean play, mute;

    /* playing or not */
    play = aud_drct_get_playing ();

    /* get current volume */
    aud_drct_get_volume_main (&current_volume);
    old_volume = current_volume;
    if (current_volume)
    {
        /* volume is not mute */
        mute = FALSE;
    } else {
        /* volume is mute */
        mute = TRUE;
    }

    /* mute the playback */
    if (event == EVENT_MUTE)
    {
        if (!mute)
        {
            volume_static = current_volume;
            aud_drct_set_volume_main (0);
            mute = TRUE;
        } else {
            aud_drct_set_volume_main (volume_static);
            mute = FALSE;
        }
        return TRUE;
    }

    /* decreace volume */
    if (event == EVENT_VOL_DOWN)
    {
        if (mute)
        {
            current_volume = old_volume;
            old_volume = 0;
            mute = FALSE;
        }

        if ((current_volume -= plugin_cfg.vol_decrement) < 0)
        {
            current_volume = 0;
        }

        if (current_volume != old_volume)
        {
            aud_drct_set_volume_main (current_volume);
        }

        old_volume = current_volume;
        return TRUE;
    }

    /* increase volume */
    if (event == EVENT_VOL_UP)
    {
        if (mute)
        {
            current_volume = old_volume;
            old_volume = 0;
            mute = FALSE;
        }

        if ((current_volume += plugin_cfg.vol_increment) > 100)
        {
            current_volume = 100;
        }

        if (current_volume != old_volume)
        {
            aud_drct_set_volume_main (current_volume);
        }

        old_volume = current_volume;
        return TRUE;
    }

    /* play */
    if (event == EVENT_PLAY)
    {
        aud_drct_play ();
        return TRUE;
    }

    /* pause */
    if (event == EVENT_PAUSE)
    {
        if (!play) aud_drct_play ();
        else aud_drct_pause ();

        return TRUE;
    }

    /* stop */
    if (event == EVENT_STOP)
    {
        aud_drct_stop ();
        return TRUE;
    }

    /* prev track */
    if (event == EVENT_PREV_TRACK)
    {
        aud_drct_pl_prev ();
        return TRUE;
    }

    /* next track */
    if (event == EVENT_NEXT_TRACK)
    {
        aud_drct_pl_next ();
        return TRUE;
    }

    /* forward */
    if (event == EVENT_FORWARD)
    {
        aud_drct_seek (aud_drct_get_time () + 5000);
        return TRUE;
    }

    /* backward */
    if (event == EVENT_BACKWARD)
    {
        gint time = aud_drct_get_time ();
        if (time > 5000) time -= 5000; /* Jump 5s back */
            else time = 0;
        aud_drct_seek (time);
        return TRUE;
    }

    /* Open Jump-To-File dialog */
    if (event == EVENT_JUMP_TO_FILE)
    {
        aud_interface_show_jump_to_track ();
        return TRUE;
    }

    /* Toggle Windows */
    if (event == EVENT_TOGGLE_WIN)
    {
        aud_interface_show (! (aud_interface_is_shown () && aud_interface_is_focused ()));
        return TRUE;
    }

    /* Show OSD through AOSD plugin*/
    if (event == EVENT_SHOW_AOSD)
    {
        hook_call("aosd toggle", NULL);
        return TRUE;
    }

    if (event == EVENT_TOGGLE_REPEAT)
    {
        aud_set_bool (NULL, "repeat", ! aud_get_bool (NULL, "repeat"));
        return TRUE;
    }

    if (event == EVENT_TOGGLE_SHUFFLE)
    {
        aud_set_bool (NULL, "shuffle", ! aud_get_bool (NULL, "shuffle"));
        return TRUE;
    }

    if (event == EVENT_TOGGLE_STOP)
    {
        aud_set_bool (NULL, "stop_after_current_song", ! aud_get_bool (NULL, "stop_after_current_song"));
        return TRUE;
    }

    if (event == EVENT_RAISE)
    {
        aud_interface_show (TRUE);
        return TRUE;
    }

    return FALSE;
}
Example #19
0
void del_server(struct server *server) {
	hook_call("onserverdel", pack_args(arg_ptr(server)));
	jtableP_iterate(&server->users, del_user_iter, NULL);
	jtableL_remove(&serverlist, server->numeric);
	free(server);
}
Example #20
0
static gboolean lirc_input_callback (GIOChannel * source, GIOCondition condition, void * data)
{
    char *code;
    char *c;
    gint playlist_time, playlist_pos, output_time, v;
    int ret;
    char *ptr;
    gint balance;
#if 0
    gboolean show_pl;
#endif
    int n;
    gchar *utf8_title_markup;

    while ((ret = lirc_nextcode (&code)) == 0 && code != NULL)
    {
        while ((ret = lirc_code2char (config, code, &c)) == 0 && c != NULL)
        {
            if (strcasecmp ("PLAY", c) == 0)
                aud_drct_play ();
            else if (strcasecmp ("STOP", c) == 0)
                aud_drct_stop ();
            else if (strcasecmp ("PAUSE", c) == 0)
                aud_drct_pause ();
            else if (strcasecmp ("PLAYPAUSE", c) == 0)
                aud_drct_play_pause ();
            else if (strncasecmp ("NEXT", c, 4) == 0)
            {
                ptr = c + 4;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);

                if (n <= 0)
                    n = 1;
                for (; n > 0; n--)
                {
                    aud_drct_pl_next ();
                }
            }
            else if (strncasecmp ("PREV", c, 4) == 0)
            {
                ptr = c + 4;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);

                if (n <= 0)
                    n = 1;
                for (; n > 0; n--)
                {
                    aud_drct_pl_prev ();
                }
            }
            else if (strcasecmp ("SHUFFLE", c) == 0)
                aud_set_bool (NULL, "shuffle", ! aud_get_bool (NULL, "shuffle"));
            else if (strcasecmp ("REPEAT", c) == 0)
                aud_set_bool (NULL, "repeat", ! aud_get_bool (NULL, "repeat"));
            else if (strncasecmp ("FWD", c, 3) == 0)
            {
                ptr = c + 3;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr) * 1000;

                if (n <= 0)
                    n = 5000;
                output_time = aud_drct_get_time ();

                int playlist = aud_playlist_get_active ();
                playlist_pos = aud_playlist_get_position (playlist);
                playlist_time =
                    aud_playlist_entry_get_length (playlist, playlist_pos,
                                                   FALSE);
                if (playlist_time - output_time < n)
                    output_time = playlist_time - n;
                aud_drct_seek (output_time + n);
            }
            else if (strncasecmp ("BWD", c, 3) == 0)
            {
                ptr = c + 3;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr) * 1000;

                if (n <= 0)
                    n = 5000;
                output_time = aud_drct_get_time ();
                if (output_time < n)
                    output_time = n;
                aud_drct_seek (output_time - n);
            }
            else if (strncasecmp ("VOL_UP", c, 6) == 0)
            {
                ptr = c + 6;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);
                if (n <= 0)
                    n = 5;

                aud_drct_get_volume_main (&v);
                if (v > (100 - n))
                    v = 100 - n;
                aud_drct_set_volume_main (v + n);
            }
            else if (strncasecmp ("VOL_DOWN", c, 8) == 0)
            {
                ptr = c + 8;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);
                if (n <= 0)
                    n = 5;

                aud_drct_get_volume_main (&v);
                if (v < n)
                    v = n;
                aud_drct_set_volume_main (v - n);
            }
            else if (strcasecmp ("QUIT", c) == 0)
            {
                aud_drct_quit ();
            }
            else if (strcasecmp ("MUTE", c) == 0)
            {
                if (mute == 0)
                {
                    mute = 1;
                    /* store the master volume so
                       we can restore it on unmute. */
                    aud_drct_get_volume_main (&mute_vol);
                    aud_drct_set_volume_main (0);
                }
                else
                {
                    mute = 0;
                    aud_drct_set_volume_main (mute_vol);
                }
            }
            else if (strncasecmp ("BAL_LEFT", c, 8) == 0)
            {
                ptr = c + 8;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);
                if (n <= 0)
                    n = 5;

                aud_drct_get_volume_balance (&balance);
                balance -= n;
                if (balance < -100)
                    balance = -100;
                aud_drct_set_volume_balance (balance);
            }
            else if (strncasecmp ("BAL_RIGHT", c, 9) == 0)
            {
                ptr = c + 9;
                while (isspace (*ptr))
                    ptr++;
                n = atoi (ptr);
                if (n <= 0)
                    n = 5;

                aud_drct_get_volume_balance (&balance);
                balance += n;
                if (balance > 100)
                    balance = 100;
                aud_drct_set_volume_balance (balance);
            }
            else if (strcasecmp ("BAL_CENTER", c) == 0)
            {
                balance = 0;
                aud_drct_set_volume_balance (balance);
            }
            else if (strcasecmp ("LIST", c) == 0)
            {
#if 0
                show_pl = aud_drct_pl_win_is_visible ();
                show_pl = (show_pl) ? 0 : 1;
                aud_drct_pl_win_toggle (show_pl);
#endif
            }
            else if (strcasecmp ("PLAYLIST_CLEAR", c) == 0)
            {
                aud_drct_stop ();
                int playlist = aud_playlist_get_active ();
                aud_playlist_entry_delete (playlist, 0,
                                           aud_playlist_entry_count
                                           (playlist));
            }
            else if (strncasecmp ("PLAYLIST_ADD ", c, 13) == 0)
            {
                aud_drct_pl_add (c + 13, -1);
            }
            else if ((strlen (c) == 1) && ((*c >= '0') || (*c <= '9')))
            {
                if (track_no_pos < 63)
                {
                    if (tid)
                        g_source_remove (tid);
                    track_no[track_no_pos++] = *c;
                    track_no[track_no_pos] = 0;
                    tid = g_timeout_add (1500, jump_to, NULL);
                    utf8_title_markup = g_markup_printf_escaped ("%s", track_no);
                    hook_call ("aosd toggle", utf8_title_markup);
                }
            }
            else
            {
                fprintf (stderr, _("%s: unknown command \"%s\"\n"),
                         plugin_name, c);
            }
        }
        free (code);
        if (ret == -1)
            break;
    }
    if (ret == -1)
    {
        /* something went badly wrong */
        fprintf (stderr, _("%s: disconnected from LIRC\n"), plugin_name);
        cleanup ();
        if (aud_get_bool ("lirc", "enable_reconnect"))
        {
            int reconnect_timeout = aud_get_int ("lirc", "reconnect_timeout");
            fprintf (stderr,
                     _("%s: will try reconnect every %d seconds...\n"),
                     plugin_name, reconnect_timeout);
            g_timeout_add (1000 * reconnect_timeout, reconnect_lirc, NULL);
        }
    }

    return TRUE;
}
Example #21
0
/**
 * Check content of file in regexp mode
 *
 * @param __name - name of file to check
 * @param __full_name - full name of file
 * @param __options - finding options
 * @param __res_wnd - window with search results
 * @return zero if file in unwanted, non-zero otherwise
 */
static BOOL
check_regexp_content (const wchar_t *__name, const wchar_t *__full_name,
                      const action_find_options_t *__options,
                      action_find_res_wnd_t *__res_wnd)
{
  vfs_file_t file;
  char buf[RE_BUF_SIZE];
  char *pchar;
  int res, i;
  BOOL matched = FALSE, finito = FALSE;

#ifdef __FILE_OFFSET64
  file = vfs_open (__full_name, O_LAGEFILE, 0);
#else
  file = vfs_open (__full_name, 0, 0);
#endif

  if (file == NULL)
    {
      /* Error opening file */
      return FALSE;
    }

  for (;;)
    {
      /* Read next buffer from file */
      res = vfs_read (file, buf, RE_BUF_SIZE - 1);

      if (res <= 0)
        {
          /* Assume file is over and we should stop greping */
          break;
        }

      buf[res] = 0;
      pchar = buf;
      i = 0;

      for (;;)
        {
          /*
           * TODO: Or we should split read buffer onto separate strings?
           */

          if (regexp_match (__options->re_content, pchar))
            {
              matched = TRUE;
              break;
            }

          /* Read buffer could contain zero characters */
          /* We should overview all parts of buffer */
          /* (between all pairs of zero characters ) */
          for (; i < res; ++i)
            {
              if (buf[i] == 0)
                {
                  break;
                }
            }

          if (i >= res)
            {
              /* Buffer is over */
              break;
            }

          ++i;
          pchar = buf + i;

          hook_call (L"switch-task-hook", NULL);

          if (ACTION_PERFORMED (__res_wnd))
            {
              finito = TRUE;
              break;
            }
        }

      if (finito)
        {
          break;
        }
    }

  vfs_close (file);

  return matched;
}
Example #22
0
/**
 * Recursive iteration for file finding
 *
 * @param __dir - directory to search file in
 * @param __rel_dir - relative director name to search file in
 * @param __options - finding options
 * @param __res_wnd - window with results
 * @return zero on success, non-zero otherwise
 */
static int
find_iteration (const wchar_t *__dir, const wchar_t *__rel_dir,
                const action_find_options_t *__options,
                action_find_res_wnd_t *__res_wnd)
{
  int i, j, count;
  vfs_dirent_t **eps = NULL;
  size_t fn_len;
  wchar_t *format, *full_name;
  vfs_stat_t stat;
  vfs_stat_proc stat_proc;
  deque_t *dirs;
  wchar_t **dir_data;

  __res_wnd->dir_opened = FALSE;

  /* Get listing of directory */

  /*
   * TODO: Add separately displaying of directories and files
   */

  count = vfs_scandir (__dir, &eps, 0, vfs_alphasort);

  if (count < 0)
    {
      /* Error getting listing */
      return ACTION_ERR;
    }

  if (TEST_FLAG(__options->flags, AFF_FIND_RECURSIVELY))
    {
      dirs = deque_create ();
    }

  /* Get function for stat'ing */
  if (TEST_FLAG(__options->flags, AFF_FOLLOW_SYMLINKS))
    {
      stat_proc = vfs_stat;
    }
  else
    {
      stat_proc = vfs_lstat;
    }

  /* Allocate memory for full file name */
  fn_len = wcslen (__dir) + MAX_FILENAME_LEN + 1;
  full_name = malloc ((fn_len + 1) * sizeof (wchar_t));

  /* Get format mask for correct directory drilling */
  if (__dir[wcslen (__dir) - 1] == '/')
    {
      format = L"%ls%ls";
    }
  else
    {
      format = L"%ls/%ls";
    }

  for (i = 0; i < count; ++i)
    {
      if (IS_PSEUDODIR (eps[i]->name))
        {
          vfs_free_dirent (eps[i]);
          continue;
        }

      set_searching_status (__res_wnd, L"Searching in", __rel_dir);

      /* Get full file name */
      swprintf (full_name, fn_len, format, __dir, eps[i]->name);

      /* Stat current node of FS */
      if (!stat_proc (full_name, &stat) == VFS_OK)
        {
          /* Error getting status of file */
          vfs_free_dirent (eps[i]);
          continue;
        }

      if (S_ISREG (stat.st_mode))
        {
          if (check_regular_file (eps[i]->name, full_name,
                                  __options, __res_wnd))
            {
              append_result (__rel_dir, eps[i]->name, stat, __res_wnd);
              ++__res_wnd->found_files;
            }
        }
      else if (S_ISDIR (stat.st_mode))
        {
          /* Of user wants directories to be found... */
          if (TEST_FLAG(__options->flags, AFF_FIND_DIRECTORIES))
            {
              if (check_directory (eps[i]->name, full_name,
                                   __options, __res_wnd))
                {
                  append_result (__rel_dir, eps[i]->name, stat, __res_wnd);
                  ++__res_wnd->found_dirs;
                }
            }

          if (TEST_FLAG(__options->flags, AFF_FIND_RECURSIVELY))
            {
              dir_data = malloc (2 * sizeof (wchar_t));
              dir_data[0] = wcsdup (eps[i]->name);
              dir_data[1] = wcsdup (full_name);
              deque_push_back (dirs, (void*)dir_data);
            }
        }
      else
        {
          if (check_special_file (eps[i]->name, full_name,
                                  __options, __res_wnd))
            {
              append_result (__rel_dir, eps[i]->name, stat, __res_wnd);
              ++__res_wnd->found_files;
            }
        }

      vfs_free_dirent (eps[i]);

      hook_call (L"switch-task-hook", NULL);

      if (ACTION_PERFORMED (__res_wnd))
        {
          /* Free remain dirents */
          for (j = i + 1; j < count; ++j)
            {
              vfs_free_dirent (eps[j]);
            }
          break;
        }
    }

  SAFE_FREE (eps);
  free (full_name);

  if (TEST_FLAG(__options->flags, AFF_FIND_RECURSIVELY) &&
      !ACTION_PERFORMED (__res_wnd))
    {
      void *data;
      wchar_t *rel_name;

      if (__rel_dir[wcslen (__rel_dir) - 1] == '/')
        {
          format = L"%ls%ls";
        }
      else
        {
          format = L"%ls/%ls";
        }

      fn_len = wcslen (__dir) + MAX_FILENAME_LEN + 1;
      rel_name = malloc ((fn_len + 1) * sizeof (wchar_t));

      deque_foreach (dirs, data);
        /* Drill relative file name */

        dir_data = data;
        if (!ACTION_PERFORMED (__res_wnd))
          {
            swprintf (rel_name, fn_len, format, __rel_dir, dir_data[0]);
            find_iteration (dir_data[1], rel_name, __options, __res_wnd);
          }
        free (dir_data);
      deque_foreach_done
    }
Example #23
0
void hook_call_o(const WHook *hk, Obj *o)
{
    hook_call(hk, o, marshall_o, marshall_extl_o);
}
Example #24
0
void hook_call_p(const WHook *hk, void *p, WHookMarshallExtl *em)
{
    hook_call(hk, p, marshall_p, em);
}
Example #25
0
void drct_quit (void)
{
    hook_call ("quit", NULL);
}
Example #26
0
void hEOB_ACK(struct server *from) {
	if (from == me)
		me->protocol[0] = 'P';
	else if (from == uplink)
		hook_call("onregistered", pack_empty());
}