Exemplo n.º 1
0
Arquivo: lpcap.c Projeto: c0i/Dorothy
/*
** String capture: add result to buffer 'b' (instead of pushing
** it into the stack)
*/
static void stringcap (luaL_Buffer *b, CapState *cs) {
  StrAux cps[MAXSTRCAPS];
  int n;
  size_t len, i;
  const char *fmt;  /* format string */
  fmt = lua_tolstring(cs->L, updatecache(cs, cs->cap->idx), &len);
  n = getstrcaps(cs, cps, 0) - 1;  /* collect nested captures */
  for (i = 0; i < len; i++) {  /* traverse them */
    if (fmt[i] != '%')  /* not an escape? */
      luaL_addchar(b, fmt[i]);  /* add it to buffer */
    else if (fmt[++i] < '0' || fmt[i] > '9')  /* not followed by a digit? */
      luaL_addchar(b, fmt[i]);  /* add to buffer */
    else {
      int l = fmt[i] - '0';  /* capture index */
      if (l > n)
        luaL_error(cs->L, "invalid capture index (%d)", l);
      else if (cps[l].isstring)
        luaL_addlstring(b, cps[l].u.s.s, cps[l].u.s.e - cps[l].u.s.s);
      else {
        Capture *curr = cs->cap;
        cs->cap = cps[l].u.cp;  /* go back to evaluate that nested capture */
        if (!addonestring(b, cs, "capture"))
          luaL_error(cs->L, "no values in capture index %d", l);
        cs->cap = curr;  /* continue from where it stopped */
      }
    }
  }
}
Exemplo n.º 2
0
Arquivo: lpcap.c Projeto: c0i/Dorothy
/*
** Table-query capture
*/
static int querycap (CapState *cs) {
  int idx = cs->cap->idx;
  pushonenestedvalue(cs);  /* get nested capture */
  lua_gettable(cs->L, updatecache(cs, idx));  /* query cap. value at table */
  if (!lua_isnil(cs->L, -1))
    return 1;
  else {  /* no value */
    lua_pop(cs->L, 1);  /* remove nil */
    return 0;
  }
}
Exemplo n.º 3
0
static void updatecache(int generation){
  char *vstpath=getenv("VST_PATH");
  struct dirent **namelist;
  int numdirentries;
  int lokke;
  int havecalledupdate=0;

  if(vstpath==NULL){
    goto end;
  }

  numdirentries=scandir(vstpath, &namelist, myselect, alphasort);
  if(numdirentries<=0){
    goto end;
  }


  for(lokke=0;lokke<numdirentries;lokke++){
    if(havecalledupdate==0 && CACHE_checkPluginUpdate(namelist[lokke]->d_name)==1){
      int numplugins;
      havecalledupdate=1;
      if(!fork()){
	if(generation>5) sleep(40);
	else sleep(generation*3+10);
	updatecache(generation+1);
	goto end;
      }
      if(generation==0){
	fprintf(stderr,"\n\n----> VSTSERVER/updatecache: Please wait. Updating cache.\n");
	fprintf(stderr,"         If nothing happens for 40 seconds, or the server is trying to start the same plugin over and over again;\n");
	fprintf(stderr,"         press ctrl-c, and start vstserver once more.\n\n");
      }
      VSTLIB_deleteCacheList(VSTLIB_newCacheList(&numplugins));
    }
    free(namelist[lokke]);
  }

  free(namelist);

 end:
  if(havecalledupdate==0 && generation>0){
    sleep(10);
    system("killall -9 wine-pthread");
    printf("\n\n----> VSTSERVER/updatecache: Cache updated.\n\n");
  }
  exit(0);
}
Exemplo n.º 4
0
Arquivo: lpcap.c Projeto: c0i/Dorothy
/*
** Fold capture
*/
static int foldcap (CapState *cs) {
  int n;
  lua_State *L = cs->L;
  int idx = cs->cap->idx;
  if (isfullcap(cs->cap++) ||  /* no nested captures? */
      isclosecap(cs->cap) ||  /* no nested captures (large subject)? */
      (n = pushcapture(cs)) == 0)  /* nested captures with no values? */
    return luaL_error(L, "no initial value for fold capture");
  if (n > 1)
    lua_pop(L, n - 1);  /* leave only one result for accumulator */
  while (!isclosecap(cs->cap)) {
    lua_pushvalue(L, updatecache(cs, idx));  /* get folding function */
    lua_insert(L, -2);  /* put it before accumulator */
    n = pushcapture(cs);  /* get next capture's values */
    lua_call(L, n + 1, 1);  /* call folding function */
  }
  cs->cap++;  /* skip close entry */
  return 1;  /* only accumulator left on the stack */
}
Exemplo n.º 5
0
int
main(int argc, char *argv[]) {
	Bool fast = False;
	int i;

    if(strcmp(argv[0], "dmenu_run") == 0) {  /* called as `dmenu_run' */
        dmenurun = True;
        updatecache();
    }

	for(i = 1; i < argc; i++)
		/* these options take no arguments */
		if(!strcmp(argv[i], "-v")) {      /* prints version information */
			puts("dmenu-"VERSION", © 2006-2014 dmenu engineers, see LICENSE for details");
			exit(EXIT_SUCCESS);
		}
		else if(!strcmp(argv[i], "-b"))   /* appears at the bottom of the screen */
			topbar = False;
		else if(!strcmp(argv[i], "-f"))   /* grabs keyboard before reading stdin */
			fast = True;
		else if(!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
			fstrncmp = strncasecmp;
			fstrstr = cistrstr;
		}
		else if(i+1 == argc)
			usage();
		/* these options take one argument */
		else if(!strcmp(argv[i], "-l"))   /* number of lines in vertical list */
			lines = atoi(argv[++i]);
		else if(!strcmp(argv[i], "-m"))
			mon = atoi(argv[++i]);
		else if(!strcmp(argv[i], "-p"))   /* adds prompt to left of input field */
			prompt = argv[++i];
		else if(!strcmp(argv[i], "-fn"))  /* font or font set */
			font = argv[++i];
		else if(!strcmp(argv[i], "-nb"))  /* normal background color */
			normbgcolor = argv[++i];
		else if(!strcmp(argv[i], "-nf"))  /* normal foreground color */
			normfgcolor = argv[++i];
		else if(!strcmp(argv[i], "-sb"))  /* selected background color */
			selbgcolor = argv[++i];
		else if(!strcmp(argv[i], "-sf"))  /* selected foreground color */
			selfgcolor = argv[++i];
		else
			usage();

	dc = initdc();
	initfont(dc, font);

	if(fast) {
		grabkeyboard();
		readstdin();
	}
	else {
		readstdin();
		grabkeyboard();
	}
	setup();
	run();

	return 1; /* unreachable */
}
	virtual void addToCache(const URI &origNamedUri, const RemoteFileId &toFetch) {
		boost::unique_lock<boost::shared_mutex> updatecache(mMut);
		mLookupCache.insert(NameMap::value_type(origNamedUri, toFetch));
	}
Exemplo n.º 7
0
int main(int argc,char **argv){
  bool realtime=true;
  char socketfilename[500];
  sprintf(socketfilename,"%s/.vstserver/sockets/s_",getenv("HOME"));


  if(argc>1){
    if(strcmp(argv[1],"-NR") && strcmp(argv[1],"--nonrealtime")){
      printf("Usage: %s [-NR or --nonrealtime]\n",argv[0]);
      return 0;
    }
    realtime=false;
  }

  if(VSTSERVER_makeDirectories()==false){
    fprintf(stderr,"\n\nVSTSERVER/main: Could not create directories in your homedirectory.\n");
    fprintf(stderr,"Check diskspace and filepermissions and try again.\n\n");
    return 1;
  }

  input=C_newInput(socketfilename,0);

  if(input==NULL){
    fprintf(stderr,"\n\nVSTSERVER/main: Could not create main socket.\n\n");
    fprintf(stderr,"Server is allready running or there are left\n");
    fprintf(stderr,"files in .vstserver/sockets/. Just delete them manually.\n");
    fprintf(stderr,"Or, there is something seriously wrong. (hope not)\n\n");
    return 2;
  }

  signal(SIGINT,finish);

  /* Nah. This operation can _theoretically_ screw things up. But thats hopefully not very likely. */
  VSTSERVER_deleteLocks();

  printf("\n\nVSTSERVER/main: Vstserver %d.%d.%d started. Waiting for requests.\n",VERSION_MAJOR,VERSION_MINOR,VERSION_MINOR_MINOR);


  if(!fork()){
    updatecache(0);
  }


  for(;;){
    struct VSTS_serverRequest sr;
    char temp[1024];

    for(;;){
      int size;
      while(C_acceptIncomingConnection(input)==false);

      if(
	 (size=C_receive(input,&sr,sizeof(struct VSTS_serverRequest)))
	 != sizeof(struct VSTS_serverRequest)
	 )
	{
	  if(size!=-1){
	    fprintf(stderr,"VSTSERVER/main: Wrong type of request to vstserver. Size: %d\n",size);
	  }else{
	    fprintf(stderr,"VSTSERVER/main: Request failed.\n");
	  }
	}else{
	  break;
	}
    }

    switch(sr.reqtype){
    case VSTP_new:
      if(
	 sr.version_major!=VERSION_MAJOR
	 || sr.version_minor!=VERSION_MINOR
	 )
	{
	  fprintf(
		  stderr,
		  "Cant start \"%s\". Client was compiled V%d.%d.%d of vstlib, which wont work with this version of the vstserver.\n",
		  sr.pluginname,
		  sr.version_major,
		  sr.version_minor,
		  sr.version_minor_minor
		  );
	}else{
	  sprintf(
		  temp,
		  "wine vstservant.so %d %d %d %s &",
		  sr.client_control_id,
		  sr.client_process_id,
		  (realtime==true && sr.realtime==true)?1:0,
		  sr.pluginname
		  );
	  printf("VSTSERVER/main: Going to try to start vst plugin \"%s\".\n",sr.pluginname);
	  system(temp);
	}
      break;

    default:
      fprintf(stderr,"VSTSERVER/main: Illegal request %d.\n",sr.reqtype);
      break;
    }
  }


  return 0;
}