pike.git / NT / tools / sprshd

version» Context lines:

pike.git/NT/tools/sprshd:76:   #ifdef WINE   void my_proxy(Stdio.File from, Stdio.File to)   {    while(string s=from->read(128,1))    if(to->write(s)!=strlen(s))    return;      }   #endif    + string opt_path(string p1, string p2) + { +  return ( ( ((p1||"") + ";" + (p2||"")) / ";" ) - ({""}) ) * ";"; + } +    void handle_incoming_connection(object(Stdio.File) io)   {    object p; -  mapping env=getenv(); +  mapping env=copy_value(getenv());    sscanf(io->read(4),"%4c",int args);    string *cmd=allocate(args);    for(int e=0;e<args;e++)    {    sscanf(io->read(4),"%4c",int len);    cmd[e]=io->read(len);    }       object pi=Stdio.File();   #ifdef NO_IPC
pike.git/NT/tools/sprshd:101:   #else    object p2=pi->pipe(Stdio.PROP_IPC);   #endif    string dir=cmd[0];    cmd=cmd[1..];       write("Doing %s in %s\n",cmd*" ",dir);       while(sscanf(cmd[0],"%s=%s",string key, string val))    { +  // Magic +  if(!env[key]) +  { +  if(env[lower_case(key)]) +  key=lower_case(key); +  else if(env[upper_case(key)]) +  key=upper_case(key); +  else +  { +  foreach(indices(env), string x) +  { +  if(lower_case(x) == lower_case(key)) +  { +  key=x; +  break; +  } +  } +  } +  } +  if(val[0]==';') +  { +  env[key]=opt_path(env[key], val); +  } +  else if(val[-1]==';') +  { +  env[key]=opt_path(val, env[key]); +  } +  else +  {    env[key]=val; -  +  }    cmd=cmd[1..];    }       switch(lower_case(cmd[0]))    {    case "mkdir":    {    string dir=combine_path(combine_path(getcwd(),dir),cmd[1]);    int ret;    if(Stdio.file_size(dir)!=-2)
pike.git/NT/tools/sprshd:160:    to,    dir, combine_path(getcwd(),dir));    io->write(sprintf("%4c%s",strlen(x),x));    }    io->write(sprintf("%4c",0));    io->write(sprintf("%4c",!ret));    break;    }    case "getenv":    { -  string s=(env[cmd[1]] || "")+"\n"; +  string s; +  if(sizeof(cmd)<2) +  { +  s=""; +  foreach(indices(env), string x) +  s+=sprintf("%s=%s\n",x,env[x]); +  }else{ +  s=(env[cmd[1]] || "")+"\n"; +  }    io->write(sprintf("%4c%s",strlen(s),s));    io->write(sprintf("%4c",0));    io->write(sprintf("%4c",0));    break;    }       default:   #ifdef WINE    {    werror("Proxying.....\n");
pike.git/NT/tools/sprshd:234:      void handle_connections(string *hosts)   {    while(1)    {    if(object io=accept())    {    sscanf(io->query_address(),"%s ",string ip);    if(search(hosts, ip)==-1)    { +  werror("Connection from %s denied!!\n",ip);    destruct(io);    continue;    }    thread_create(handle_incoming_connection,io);    }else{    werror("Accept failed "+errno()+"\n");    }    }   }