コード例 #1
0
int main(int argc, char *argv[])
{
  int i;
  int (*op_func) (int, int);
  if (argc != 4) return 1;

  op_func = get_op_func(*argv[2]);
  if (op_func == 0) return 2;
  i = op_func(atoi(argv[1]), atoi(argv[3]));
  printf("%d\n", i);

  return 0;
}
コード例 #2
0
int main(int argc, char *argv[]) 
{
	if (argc != 4) {
		return 1; /* expects program name, value, operator, and another value. 1 = error */
	}

	op_func = get_op_func(*argv[2]); 

	if (op_func == 0) {
		return 2;
	}

	int i;
	i = op_func(atoi(argv[1]), atoi(argv[3]));
	printf("%d\n", i);
	return 0;
}
コード例 #3
0
ファイル: fileview.c プロジェクト: dimkr/emelfm
/* This gets called when an option from the popup menu (Copy/Move/Link) is
 * chosen
 */
static void
drag_op_cb(GtkWidget *widget, gpointer data)
{
  gchar *dest_dir, *file_list;
  gchar dest[PATH_MAX+NAME_MAX];
  gchar *s, *filename;
  int (*op_func)(gchar *, gchar *) = data;

  gboolean check = cfg.confirm_overwrite;
  gint result;

  dest_dir = gtk_object_get_data(GTK_OBJECT(widget), "dest_dir");
  file_list = gtk_object_get_data(GTK_OBJECT(widget), "file_list");

  /* file_list is a string of the format:
   * file:/path/to/one_file\r\nfile:/path/to/second_file\r\n 
   * and so on
   */
  while ((s = strstr(file_list, "\r\n")) != NULL)
  {
    *s = '\0';
    file_list += 5; /* Skip over 'file:' */

    filename = strrchr(file_list, '/'); /* extract the filename */
    g_snprintf(dest, sizeof(dest), "%s%s", dest_dir, filename+1);
    if (check && (access(dest, F_OK) == 0))
    {
      gtk_widget_set_sensitive(app.main_window, FALSE);
      result = op_with_ow_check(file_list, dest, op_func);
      gtk_widget_set_sensitive(app.main_window, TRUE);
      if (result == YES_TO_ALL)
        check = FALSE;
      else if (result == CANCEL)
        break;
    }
    else
      op_func(file_list, dest);

    file_list = s + 2; /* Skip over the '\r\n' */
  }
    
  gtk_widget_destroy(app.drag_op_menu);
  refresh_list(other_view);
  refresh_list(other_view);
}
コード例 #4
0
int main(int ac, char **av)
{
  int n;

  int (*op_func)(int a, int b);

  if (ac != 4)
    {
      return 1;
    }
  op_func = get_op_func(*av[2]);
  if (op_func == 0)
    {
      return 1;
    }
  n = op_func(atoi(av[1]), (atoi(av[3])));
  print_number(n);
  print_char('\n');
  return 0;
}
コード例 #5
0
ファイル: gsk-debug-alloc-tool.c プロジェクト: davebenson/gsk
int main(int argc, char **argv)
{
  const char *logfile = NULL;
  const char *op = NULL;
  GskDebugLog *log = NULL;
  guint i;
  void (*op_func) (GskDebugLog *) = NULL;
  GError *error = NULL;

  for (i = 1; i < (guint) argc; i++)
    {
      if (argv[i][0] == '-')
	{
	  usage ();
	}
      else if (logfile == NULL)
	logfile = argv[i];
      else if (op == NULL)
	{
	  op = argv[i];
	  if (strcmp (op, "usage-stats") == 0)
	    op_func = do_usage_stats;
          else
            g_error ("error: unknown operation %s", op);
	}
      else
	usage ();
    }
  if (op == NULL)
    usage ();

  log = gsk_debug_log_open (logfile, &error);
  if (log == NULL)
    g_error ("error opening debug log: %s", error->message);
  op_func (log);
  return 0;
}