Exemple #1
0
void fileExecFile(Widget w, XEvent *event, String *params, 
		  Cardinal *num_params)
{
  int i, l;
  char *path;
  char **argv;
  FileWindowRec *fw;

  i = findWidget(w, &fw);
  if (i == -1 || !fw) {
/*
    error("Internal error:","widget not found in fileExecFile");
*/
    return;
  }

  l = strlen(fw->directory);
  path = (char *)alloca(l+strlen(fw->files[i]->name)+2);
  strcpy(path, fw->directory);
  if (path[l-1] != '/')
    path[l++] = '/';
  strcpy(path+l, fw->files[i]->name);
  argv = (char **) XtMalloc(2 * sizeof(char *));
  argv[0] = XtNewString(fw->files[i]->name);
  argv[1] = NULL;
  executeApplication(path, fw->directory, argv);

  freeArgv(argv);
}
Exemple #2
0
void ExecExternalApplication(Display *dpy, int x, int y, char *label, 
			     char *icon, char *cmd, char *drop, char *dir)
{	
	char path[1024];
	char *p;
	char **argv;

	if (dir)
	{
	    newFileWindow(dir,resources.initial_display_type,True,False);
	    return;
	}

	strcpy(path, cmd);
	p= path+strlen(path);
	while(*p--!='/');
	p++;
	p[0] = '\0';
	
	argv = (char **) XtMalloc(2 * sizeof(char *));
	argv[0] = XtNewString(cmd);
	argv[1] = NULL;
	
	executeApplication(cmd, path, argv);

	freeArgv(argv);

}
Exemple #3
0
void fileOpenCb(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
 FileWindowRec *fw;
 FileRec *file;
 int item;
 char path[MAXPATHLEN];
 String *argv, push_action;

 if (!(fw = findFileWidget(w, &item)))  return;
 zzz();
 file = fw->files[item];
 strcpy(path, fw->directory);
 if (path[strlen(path)-1] != '/')  strcat(path, "/");
 strcat(path, file->name);
 if (S_ISDIR(file->stats.st_mode))
 {
     contractPath(path);
     chFileDir(fw, path);
 }
 else if (file->stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
 {
     String arguments = XtNewString(file->name);
     String action = (String) XtMalloc((strlen(path) + 6) * sizeof(char));

     strcat(strcpy(action, "exec "), path);
     argv = makeArgv(action, 1, &arguments);
     executeApplication(user.shell, fw->directory, argv);
     XTFREE(action);
     freeArgv(argv);
 }
 else if (file->type)
 {
     if (*(push_action = file->type->push_action))
     {
	 if (!(strcmp(push_action, "EDIT")))
	     doEdit(fw->directory, file->name);
	 else if (!(strcmp(push_action, "VIEW")))
	     doView(fw->directory, file->name);
	 else if (!(strcmp(push_action, "LOAD")))
	 {
	     zzz();
	     newApplicationWindow(path, NULL);
	     wakeUp();
	 }
	 else
	 {
	     argv = (String *) XtMalloc(sizeof(String));
	     argv[0] = XtNewString(file->name);
	     performAction(fw->shell, file->type->icon_pm.bm, push_action, fw->directory, 1, argv);
	     XTFREE(argv);
	 }
     }
 }
 else doEdit(fw->directory, file->name);
 wakeUp();
}
int elektraSpecloadClose (Plugin * handle, Key * errorKey)
{
	Specload * specload = elektraPluginGetData (handle);

	if (specload != NULL)
	{
		elektraInvokeClose (specload->quickDump, errorKey);

		ksDel (specload->quickDumpConfig);
		elektraFree (specload->app);
		freeArgv (specload->argv);

		elektraFree (specload);
		elektraPluginSetData (handle, NULL);
	}

	return ELEKTRA_PLUGIN_STATUS_SUCCESS;
}
Exemple #5
0
int 
main(int argc, char *argv[], char *envp[])
{
  char *line;

  int returnValue;

	int i, fd;

	char *pathString = (char *)malloc(sizeof(char) * 256);
	char *cmd = (char *)malloc(sizeof(char) * 256);

  bzero(pathString, 256);
  bzero(cmd, 256);

  /* Manage Signals */
  signal(SIGINT, SIG_IGN);	
  signal(SIGQUIT,SIG_IGN);
//  signal(SIGCHLD,SIG_IGN);
  signal(SIGKILL,SIG_IGN);
  signal(SIGTERM,SIG_IGN);

	signal(SIGINT, handleSignal);

  /* Extract the PATH= var from envp */
	getPathString(envp, pathString);
  /* Insert each path to be searched into searchPath[][] */
  insertPathStringToSearch(searchPath, pathString);

  /* Print about Slash */
  clrScreen(argv, envp);
  printf("%s", aboutSlash);
  printf("PID=%d\n", getpid());

#if SLASH_DEBUG
  for(i=0; envp[i] != NULL; i++)
    printf("%s\n", envp[i]);
#endif

  /* Bind our completer + History Feature */
  initialize_readline();

  while(1)
  {
    line = readline ("\x1b[96m<$lash/>\x1b[00m "); /* Print in Red! */

    #if SLASH_DEBUG
      printf("Input: %s\n", line);
    #endif

    if(*line)
    {
      add_history (line);
      returnValue = execute_line (line);

      if(returnValue == CMD_EXIT)
        break;

      if(returnValue == CMD_UNKNOWN)
      {
        #if SLASH_DEBUG
          printf("CMD_UNKNOWN: %s\n", line);
        #endif
        /* Extract args to command into slashArgv[][] */
        nullifyArgv(slashArgv);
        fillArgv(line, slashArgv);
        bzero(cmd, 256);
				strncpy(cmd, slashArgv[0], strlen(slashArgv[0]));
				strncat(cmd, "\0", 1);

        #if SLASH_DEBUG
          printf("arg[0]: %s\n", slashArgv[0]);
          printf("cmd: %s\n", cmd);
        #endif

				if(index(cmd, '/') == NULL) 
        {
				  if(attachPath(cmd, searchPath) == 0) 
          {
					  callFork(cmd, slashArgv, envp);
					} 
          else 
					  printf("%s: command not found\n", cmd);
        } 
        else 
        {
				  if((fd = open(cmd, O_RDONLY)) > 0) 
          {
					  close(fd);
						callFork(cmd, slashArgv, envp);
					} 
          else 
					  printf("%s: command not found\n", cmd);
			  }
        freeArgv(slashArgv);
      }
    }

    if(line != NULL)
    free(line);
	  fflush(stdout);
  }

  free(cmd);
	free(pathString);
	for(i=0;i<50;i++)
		free(searchPath[i]);
	return 0;
}