FB::variant BracExtenssionProviderAPI::setExtensionPath(const FB::variant& msg) {
	m_extension_path = msg.cast<std::string>();
	size_t index = 0;

	#if defined _WIN32
		std::string env_var = "LOCALAPPDATA";
	#elif defined __APPLE__
		std::string env_var = "USER";
	#endif

	std::string signedvar = '%' + std::string(env_var) + '%';
	index = m_extension_path.find(signedvar, index);
	if (std::string::npos != index) {
		m_extension_path.replace(index, signedvar.length(), get_env(env_var.c_str()));
		log("Extension path is set to ('" + std::string(get_env(env_var.c_str())) + "'): " + m_extension_path);
	} else {	
		log("No environment variable was found: " + m_extension_path);
	}

#if defined __APPLE__
	std::string esc_ext_path = escape_path(m_extension_path);
	systemCall("chmod 700 " + esc_ext_path + "/bin/7za");
	systemCall("chmod 700 " + esc_ext_path + "/bin/clg-crop.app");
	systemCall("chmod 700 " + esc_ext_path + "/bin/clg-snapshot.app");
#endif

	return m_extension_path;
}
Пример #2
0
/**
 * Check credentials
 */
OPENVPN_EXPORT int
openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
{
  /* get username/password from envp string array */
  const char *username = get_env ("username", envp);
  const char *password = get_env ("password", envp);
  const char *ip = get_env ("untrusted_ip", envp);
  const char *port = get_env ("untrusted_port", envp);

  const int ulen = strlen(username);
  const int pwlen = strlen(password);
  if ( ulen > MAXWORDLEN || ulen == 0 || pwlen > MAXWORDLEN || pwlen == 0) {
	  return OPENVPN_PLUGIN_FUNC_ERROR;
  }

  /* check entered username/password against what we require */
  int ok = otp_verify(username, password);

  if (ok == 1) {
    LOG("OTP-AUTH: authentication succeeded for username '%s', remote %s:%s\n", username, ip, port);
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
  }
  else {
    LOG("OTP-AUTH: authentication failed for username '%s', remote %s:%s\n", username, ip, port);
    return OPENVPN_PLUGIN_FUNC_ERROR;
  }
}
Пример #3
0
OPENVPN_EXPORT int
openvpn_plugin_func_v1 (openvpn_plugin_handle_t handle, const int type, const char *argv[], const char *envp[])
{
  struct auth_pam_context *context = (struct auth_pam_context *) handle;

  if (type == OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY && context->foreground_fd >= 0)
    {
      /* get username/password from envp string array */
      const char *username = get_env ("username", envp);
      const char *password = get_env ("password", envp);
      const char *common_name = get_env ("common_name", envp) ? get_env ("common_name", envp) : "";

      if (username && strlen (username) > 0 && password)
	{
	  if (send_control (context->foreground_fd, COMMAND_VERIFY) == -1
	      || send_string (context->foreground_fd, username) == -1
	      || send_string (context->foreground_fd, password) == -1
             || send_string (context->foreground_fd, common_name) == -1)
	    {
	      fprintf (stderr, "AUTH-PAM: Error sending auth info to background process\n");
	    }
	  else
	    {
	      const int status = recv_control (context->foreground_fd);
	      if (status == RESPONSE_VERIFY_SUCCEEDED)
		return OPENVPN_PLUGIN_FUNC_SUCCESS;
	      if (status == -1)
		fprintf (stderr, "AUTH-PAM: Error receiving auth confirmation from background process\n");
	    }
	}
    }
  return OPENVPN_PLUGIN_FUNC_ERROR;
}
Пример #4
0
void printMemoryInfo(void)
{
    int line;
    unsigned long i;
    MemoryRange *mp = (MemoryRange*)(uint32_t)get_env(envMemoryMap);
	
    // Activate and clear page 1
    setActiveDisplayPage(1);
    clearScreenRows(0, 24);
    setCursorPosition( 0, 0, 1 );
	
    printf("BIOS reported memory ranges:\n");
    line = 1;
	
	int memoryMapCount = (int)get_env(envMemoryMapCnt);
    for (i=0; i<memoryMapCount; i++) {
        printf("Base 0x%08x%08x, ",
               (unsigned long)(mp->base >> 32),
               (unsigned long)(mp->base));
        printf("length 0x%08x%08x, type %d\n",
               (unsigned long)(mp->length >> 32),
               (unsigned long)(mp->length),
               mp->type);
        if (line++ > 20) {
            pause();
            line = 0;
        }
        mp++;
    }
    if (line > 0) {
        pause();
    }
    
    setActiveDisplayPage(0);
}
Пример #5
0
OPENVPN_EXPORT int
openvpn_plugin_func_v3 (const int version,
                        struct openvpn_plugin_args_func_in const *args,
                        struct openvpn_plugin_args_func_return *retptr)
{
  struct plugin_context *context = (struct plugin_context *) args->handle;

  printf("\nopenvpn_plugin_func_v3() :::::>> ");
  show (args->type, args->argv, args->envp);

  /* Dump some X509 information if we're in the TLS_VERIFY phase */
  if ((args->type == OPENVPN_PLUGIN_TLS_VERIFY) && args->current_cert ) {
    printf("---- X509 Subject information ----\n");
    printf("Certificate depth: %i\n", args->current_cert_depth);
    x509_print_info(args->current_cert);
    printf("----------------------------------\n");
  }

  /* check entered username/password against what we require */
  if (args->type == OPENVPN_PLUGIN_AUTH_USER_PASS_VERIFY)
    {
      /* get username/password from envp string array */
      const char *username = get_env ("username", args->envp);
      const char *password = get_env ("password", args->envp);

      if (username && !strcmp (username, context->username)
	  && password && !strcmp (password, context->password))
	return OPENVPN_PLUGIN_FUNC_SUCCESS;
      else
	return OPENVPN_PLUGIN_FUNC_ERROR;
    }
  else
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
}
Пример #6
0
void PNG_recycle(PNG* png)
{
  if (png == NULL) {
    return;
  }

  free(png->buffer);
  png->buffer = NULL;

  free_frame_info_array(png->frame_info_array, png->frame_count);
  png->frame_info_array = NULL;

  free(png->backup);
  png->backup = NULL;

  if (png->png_ptr != NULL && png->info_ptr != NULL) {
    png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);
  }
  png->png_ptr = NULL;
  png->info_ptr = NULL;

  if (png->patch_head_input_stream != NULL) {
    close_patch_head_input_stream(get_env(), png->patch_head_input_stream);
    destroy_patch_head_input_stream(get_env(), &png->patch_head_input_stream);
    png->patch_head_input_stream = NULL;
  }
}
Пример #7
0
bool PNG_complete(PNG* png)
{
  int i;

  if (!png->partially) {
    return true;
  }

  if (png->png_ptr == NULL || png->info_ptr == NULL || png->patch_head_input_stream == NULL) {
    LOGE(EMSG("Some stuff is NULL"));
    return false;
  }

  // Read left frames
  for (i = 1; i < png->frame_count; read_frame(png->png_ptr, png->info_ptr, png->frame_info_array + i++));

  // Generate pop
  generate_pop(png->frame_info_array, png->frame_count);

  // End read
  png_read_end(png->png_ptr, png->info_ptr);
  png_destroy_read_struct(&png->png_ptr, &png->info_ptr, NULL);

  // Close input stream
  close_patch_head_input_stream(get_env(), png->patch_head_input_stream);
  destroy_patch_head_input_stream(get_env(), &png->patch_head_input_stream);

  // Clean up
  png->partially = false;
  png->png_ptr = NULL;
  png->info_ptr = NULL;
  png->patch_head_input_stream = NULL;

  return true;
}
Пример #8
0
int		cd_tild(char **args, t_dlist *env, t_cmd *cmd, int i)
{
  char		*path;

  path = get_path_from_opt(args[1]);
  if (check_access(env, cmd, i) == -1)
    return (-1);
  chdir(get_my_home(env));
  if (strcmp(path, "\0") == 0)
    {
      modif_oldpwd(get_env("PWD", env), env);
      modif_pwd_from_home_to_path(args[1], env);
      return (0);
    }
  path = realloc_path(path, env);
  if (access(path, F_OK) == -1 || access(path, R_OK) == -1)
    {
      if (access(path, F_OK) == -1)
	fprintf(stderr, "42sh: cd: No such file or directory\n");
      else
	print_permission_denied(cmd, i);
      return (-1);
    }
  chdir(path);
  modif_oldpwd(get_env("PWD", env), env);
  modif_pwd_from_home_to_path(args[1], env);
  return (0);
}
Пример #9
0
static int
tls_final (struct plugin_context *context, struct plugin_per_client_context *pcc, const char *argv[], const char *envp[])
{
  if (context->test_packet_filter)
    {
      if (!pcc->generated_pf_file)
	{
	  const char *pff = get_env ("pf_file", envp);
	  const char *cn = get_env ("username", envp);
	  if (pff && cn)
	    {
	      char buf[256];
	      snprintf (buf, sizeof(buf), "( sleep %d ; echo PF %s/%s ; cp \"%s.pf\" \"%s\" ) &",
			context->test_packet_filter, cn, pff, cn, pff);
	      printf ("%s\n", buf);
	      system (buf);
	      pcc->generated_pf_file = true;
	      return OPENVPN_PLUGIN_FUNC_SUCCESS;
	    }
	  else
	    return OPENVPN_PLUGIN_FUNC_ERROR;
	}
      else
	return OPENVPN_PLUGIN_FUNC_ERROR;
    }
  else
    return OPENVPN_PLUGIN_FUNC_SUCCESS;
}
Пример #10
0
void* decode(JNIEnv* env, InputStream* stream, bool partially, int* format)
{
  unsigned char magic_numbers[2];
  PatchHeadInputStream* patch_head_input_stream;

  *format = get_format(env, stream);

  switch (*format) {
#ifdef IMAGE_SUPPORT_JPEG
    case IMAGE_FORMAT_JPEG:
      magic_numbers[0] = IMAGE_JPEG_MAGIC_NUMBER_0;
      magic_numbers[1] = IMAGE_JPEG_MAGIC_NUMBER_1;
      break;
#endif
#ifdef IMAGE_SUPPORT_PNG
    case IMAGE_FORMAT_PNG:
      magic_numbers[0] = IMAGE_PNG_MAGIC_NUMBER_0;
      magic_numbers[1] = IMAGE_PNG_MAGIC_NUMBER_1;
      break;
#endif
#ifdef IMAGE_SUPPORT_GIF
    case IMAGE_FORMAT_GIF:
      magic_numbers[0] = IMAGE_GIF_MAGIC_NUMBER_0;
      magic_numbers[1] = IMAGE_GIF_MAGIC_NUMBER_1;
      break;
#endif
    default:
      LOGE(EMSG("Can't detect format %d"), *format);
      destroy_input_stream(get_env(), &stream);
      return NULL;
  }

  patch_head_input_stream = create_patch_head_input_stream(stream, magic_numbers, 2);
  if (patch_head_input_stream == NULL){
    WTF_OM;
    destroy_input_stream(get_env(), &stream);
    return NULL;
  }

  switch (*format) {
#ifdef IMAGE_SUPPORT_JPEG
    case IMAGE_FORMAT_JPEG:
      return JPEG_decode(env, patch_head_input_stream, partially);
#endif
#ifdef IMAGE_SUPPORT_PNG
    case IMAGE_FORMAT_PNG:
      return PNG_decode(env, patch_head_input_stream, partially);
#endif
#ifdef IMAGE_SUPPORT_GIF
    case IMAGE_FORMAT_GIF:
      return GIF_decode(env, patch_head_input_stream, partially);
#endif
    default:
      LOGE(EMSG("Can't detect format %d"), *format);
      close_patch_head_input_stream(get_env(), patch_head_input_stream);
      destroy_patch_head_input_stream(get_env(), &patch_head_input_stream);
      return NULL;
  }
}
Пример #11
0
static void get_parameters(int argc, char** argv)
{
  progname = get_env(erl_block, "PROGNAME");
  rootdir = get_env(erl_block, "ROOTDIR");
  emu = get_env(erl_block, "EMU");
  if (!progname || !rootdir || !emu ) {
    ose_error("PROGNAME, ROOTDIR and EMU must be set", 0);
  }
}
Пример #12
0
void	prompt(t_env *env)
{
    char	*user;
    char	*host;

    if ((user = get_env(env, "USER")) == NULL)
        user = MYSH_USER_DEF;
    if ((host = get_env(env, "HOST")) == NULL)
        host = MYSH_HOST_DEF;
    my_printf("{{%s%s%s@%s%s%s}}", C_CYN, user, A_RST, C_BLU, host, A_RST);
    my_printf(" %s%s->%s ", C_GRN, A_BLD, A_RST);
}
Пример #13
0
static void		set_uniform(t_resources *res, t_mode mode)
{
	t_pt3f	*camera;

	camera = (t_pt3f*)get_env()->position->array;
	glUniformMatrix4fv(get_uniform_id(&res->gl_mvp_uni, mode),
			1, GL_FALSE, get_env()->mvp->array);
	glUniform3f(get_uniform_id(&res->gl_lightpos_uni, mode),
			LIGHT_POS_X, LIGHT_POS_Y, LIGHT_POS_Z);
	glUniform3f(get_uniform_id(&res->gl_camera_uni, mode),
			camera->x, camera->y, camera->z);
}
Пример #14
0
/**
 ** Locate the fisrt instance of _panic inside of _cpuid_set_info, and either remove it
 ** Or replace it so that the cpuid is set to a valid value.
 **/
static void patch_cpuid_set_info_all(void* kernelData)
{
	switch(get_env(envModel))
	{
		case CPUID_MODEL_ATOM:
			if(determineKernelArchitecture(kernelData) == KERNEL_32)
			{
				patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_PENRYN, CPUID_MODEL_PENRYN);
			}
			else 
			{
				patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_PENRYN, CPUID_MODEL_PENRYN);
			}
			
			break;
			
		default:
		{
			// AnV: Extra cpuid fix for spoofing Nehalem CPU for i5/i9
			switch(get_env(envFamily))
			{
				case 0x1E: /* Intel i5 */
				case 0x2C: /* Intel i9 */
					if(determineKernelArchitecture(kernelData) == KERNEL_32)
					{
						patch_cpuid_set_info_32(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
					}
					else 
					{
						patch_cpuid_set_info_64(kernelData, CPUFAMILY_INTEL_NEHALEM, CPUID_MODEL_NEHALEM);
					}
					
					break;
					
				default:
					if(determineKernelArchitecture(kernelData) == KERNEL_32)
					{
						patch_cpuid_set_info_32(kernelData, 0, 0);
					}
					else
					{
						patch_cpuid_set_info_64(kernelData, 0, 0);
					}					
					break;
			}
			break;			
		}
	}
}
Пример #15
0
long HFSReadFile(CICell ih, char * filePath, void *base, uint64_t offset,  uint64_t length)
{
    char entry[512];
    char devStr[12];
    long dirID, result, flags = 0;
	
    if (HFSInitPartition(ih) == -1) return -1;
    
    dirID = kHFSRootFolderID;
    // Skip a lead '\'.  Start in the system folder if there are two.
    if (filePath[0] == '/') {
        if (filePath[1] == '/') {
            if (gIsHFSPlus) dirID = SWAP_BE32(((long *)gHFSPlus->finderInfo)[5]);
            else dirID = SWAP_BE32(gHFSMDB->drFndrInfo[5]);
            if (dirID == 0) {
				return -1;
			}
            filePath++;
        }
        filePath++;
    }
	
    result = ResolvePathToCatalogEntry(filePath, &flags, entry, dirID, 0);
    if ((result == -1) || ((flags & kFileTypeMask) != kFileTypeFlat)) {
		return -1;
    }
	
#if UNUSED
    // Not yet for Intel. System.config/Default.table will fail this check.
    // Check file owner and permissions.
    if (flags & (kOwnerNotRoot | kPermGroupWrite | kPermOtherWrite)) return -1;
#endif
	
    result = ReadFile(entry, &length, base, offset);
    if (result == -1) {
		return -1;
    }
	
    getDeviceDescription(ih, devStr, sizeof(devStr));
	
	if (get_env(envHFSLoadVerbose)) {
		verbose("Read HFS%s file: [%s/%s] %d bytes.\n",
				(gIsHFSPlus ? "+" : ""), devStr, filePath, (uint32_t)length);
	} else if (get_env(envHFSLoadVerbose) == 0) {		
		safe_set_env(envHFSLoadVerbose, 1);
	}
    
    return length;
}
Пример #16
0
int		error_cdenv(char **env, char **cmd, int n)
{
	if ((n == 1 || (n == 2 && (ft_strcmp(cmd[1], "--") == 0)))\
			&& get_env(env, "HOME=") == NULL)
	{
		ft_putendl("cd: HOME not set");
		return (1);
	}
	else if ((ft_strcmp(cmd[1], "-") == 0) && get_env(env, "OLDPWD=") == NULL)
	{
		ft_putendl("cd: OLDPWD not set");
		return (1);
	}
	return (0);
}
Пример #17
0
int				ft_unsetenv(int ac, char **av, int i, int j)
{
	char		*tmp;
	char		**env;

	env = get_env();
	if (!ac)
	{
		ft_putendl_fd("unsetenv: Too few arguments.", 2);
		return (EXIT_FAILURE);
	}
	while (i < ac)
	{
		j = 0;
		while (env[j])
		{
			tmp = ft_strjoin(av[i], "=");
			if (ft_strnequ(tmp, env[j], ft_strlen(tmp)))
				env = ft_ctabdel(env, j);
			j++;
		}
		i++;
	}
	create_env(env);
	return (EXIT_SUCCESS);
}
Пример #18
0
static void load_default_env(void)
{
	int i;
	char *tmp;
	int mum = 1;
	char load_buf[20]={0};
	printk("[%s]load default env\n",MODULE_NAME);
	
	tmp = get_env(DATA_FREE_SIZE_TH_NAME);
	if(tmp == NULL){
		printk("[%s]can not find %s,set the default value\n",MODULE_NAME,DATA_FREE_SIZE_TH_NAME);
		sprintf(load_buf,"%d",DATA_FREE_SIZE_TH_DEFAULT);
		set_env(DATA_FREE_SIZE_TH_NAME,load_buf);
		return;
	}
	for(i=0;i<strlen(tmp);i++){
		if(tmp[i] == 'M' || tmp[i] == 'm'){
			mum = 1024*1024;
			break;
		}else if(tmp[i] == 'K' || tmp[i] == 'k'){
			mum = 1024;
			break;
		}else{
			load_buf[i] = tmp[i];
		}
	}
	data_free_size_th =(long long)simple_strtol(load_buf,NULL,10)*mum;
	
	printk("[%s]find %s = %llx\n",MODULE_NAME,DATA_FREE_SIZE_TH_NAME,data_free_size_th);
}
Пример #19
0
/*!

\brief Constructor.
\param[in] AppName String containing unit test name.
\param[in] argc Number of arguments in argv
\param[in] argv Array of char arrays containing the command line arguments.

*/
dmz::Test::Test (const String &AppName, int argc, char *argv[]) :
      obs (rt.get_context ()),
      config ("global"),
      log ("", rt.get_context ()),
      error (False) {

   const String LogLevelEnvStr (get_env ("DMZ_TEST_LOG_LEVEL"));
   LogLevelEnum level (LogLevelWarn);
   if (LogLevelEnvStr) { level = string_to_log_level (LogLevelEnvStr); }
   obs.set_level (level);

   log.out
      << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << endl
      << "Running " << AppName << " unit test." << endl
      << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-" << endl;

   CommandLine cl (argc, argv);
   CommandLineConfig clconfig;

   if (!clconfig.process_command_line (cl, config)) {

      log.error << "Unable to process command line: " << clconfig.get_error () << endl;
      error = True;
   }
}
Пример #20
0
void
make_tex_tfm (string name) {
  string s;
  int r= 0;
  if (get_setting ("MAKETFM") == "MakeTeXTFM") {
    s= "MakeTeXTFM " * name;
    if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n";
    r= system (s);
  }
  if (get_setting ("MAKETFM") == "mktextfm") {
    url tfm_dir ("$TEXMACS_HOME_PATH/fonts/tfm");
    s= "mktextfm " *
      string ("--destdir ") * as_string (tfm_dir) * " " *
      name;
    if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n";
    r= system (s);
    string superfluous= name * ".600pk";
    if (ends (name, ".tfm")) superfluous= name (0, N(name)-4) * ".600pk";
    remove (tfm_dir * superfluous);
  }
  if (get_setting ("MAKETFM") == "maketfm"){
    if (name(N(name) - 4, N(name)) == ".tfm")
      name = name (0, N(name) - 4);
    s = "maketfm --dest-dir \"" * get_env("$TEXMACS_HOME_PATH")
      * "\\fonts\\tfm\" " * name;
    if (DEBUG_VERBOSE) debug_fonts << "Executing " << s << "\n";
    r= system (s);
  }
  if (r) cout << "TeXmacs] system command failed: " << s << "\n";
}
Пример #21
0
void umount_cmd(int term, char **args, int argc)
{
	char *current_dir = NULL;

	if(argc != 1)
	{
		term_color_print(term, "\nInvalid parameters.\n", 12);
		term_color_print(term, "Usage: umount path\n", 7);
		return;
	}

	current_dir = get_env("CURRENT_PATH", term);
	
	if(strprefix(args[0], current_dir))
	{
		term_color_print(term, "Cannot umount dir, because it's a prefix of the current path.\n", 12);
		return;
	}

	if(umount(args[0]))
	{
		term_color_print(term, mapioerr(ioerror()), 12);
		term_color_print(term, "\n", 12);
	}
}
Пример #22
0
/*
 * Terminate destination --- called by jpeg_finish_compress
 */
METHODDEF(void) ios_term_destination(j_compress_ptr cinfo) {


    struct jpeg_compress_struct * cs;
    enc_client_data_ptr cdata;
    enc_error_mgr_ptr err_mgr;

    jbyteArray java_buffer;
    JOCTET *native_buffer;
    JNIEnv *env;

    cs = (struct jpeg_compress_struct *) cinfo;
    cdata = (enc_client_data_ptr) cs->client_data;
    err_mgr = (enc_error_mgr_ptr) cs->err;

    env = get_env();
    java_buffer = (*env)->NewByteArray(env, MAX_BUFFER);
    native_buffer = (JOCTET *)(*env)->GetPrimitiveArrayCritical(env, java_buffer, NULL);
    memcpy(native_buffer, cdata->jpeg_buffer, MAX_BUFFER);
    (*env)->ReleasePrimitiveArrayCritical(env, java_buffer, native_buffer, 0);
    (*env)->CallVoidMethod(env, cdata->ios, IOSwriteID, java_buffer, 0, MAX_BUFFER - cs->dest->free_in_buffer);

    // checking for an exception in the java method
    if ((*env)->ExceptionOccurred(env)) {
        err_mgr->base.error_exit((j_common_ptr) cinfo);
    }

    cs->dest->next_output_byte = NULL;
    cs->dest->free_in_buffer = 0;
}
Пример #23
0
// ----------------------------------------------------------------------------
// the callback used to format data (into text, json, html, etc.) for clients
// ----------------------------------------------------------------------------
// HTTP/1.1 200 OK
// Content-type:text/plain
// Transfer-Encoding: chunked
// 
// 3c;     
// KEY:time VAL:Mon, 12 Mar 2012 13:11:49 GMT|KEY:00 VAL:14.03
// 3c;     
// KEY:time VAL:Mon, 12 Mar 2012 13:11:49 GMT|KEY:00 VAL:40.75
// 3c;     
// KEY:time VAL:Mon, 12 Mar 2012 13:11:49 GMT|KEY:00 VAL:45.02
// 0   
//
static int push_fn(char *argv[], xbuf_t *reply)
{
   reply->len = 0; // empty buffer
   xbuf_xcat(reply, "        \r\n" // room for chunck size: "1a;     "
             "KEY:time VAL:%s|", (char*)get_env(argv, SERVER_DATE));
             
   // fill the 2D HTML <table> cells with our 1D array
   // (we randomly skip some cells to avoid updating all of them)
   {
      int i = 0, r = 0, c = 0;
      while(i < CELLS)
      {
          if(!(sw_rand(&rnd) & 3)) // skip some cells
             xbuf_xcat(reply, "KEY:%c%c VAL:%.02f|",
                              '0' + r, '0' + c, s_data[i++]);

          if(c + 1 < COLS) c++; 
          else
          {
             c = 0;
             if(r + 1 < ROWS) r++; else r = 0;
          }
      }
   }   
   reply->ptr[--reply->len] = 0; // remove the ending '|'
   
   // now we know it, setup the chunk size
   char *p = reply->ptr;
   int i = s_snprintf(p, 8, "%x;", reply->len - (sizeof("        \r\n") - 2));
   p[i] = ' '; // useful for tracing, when we puts(reply->ptr); later
   
   xbuf_ncat(reply, "\r\n", sizeof("\r\n") - 1); // close this chunk
   return 1;   
}
Пример #24
0
string
get_locale_language () {
#if defined(_WIN32) || defined(__WIN32__)
  return windows_locale_to_language (setlocale (LC_ALL, ""));
#else
  string env_lan= get_env ("LC_ALL");
  if (env_lan != "") return locale_to_language (env_lan);
  env_lan= get_env ("LC_MESSAGES");
  if (env_lan != "") return locale_to_language (env_lan);
  env_lan= get_env ("LANG");
  if (env_lan != "") return locale_to_language (env_lan);
  env_lan= get_env ("GDM_LANG");
  if (env_lan != "") return locale_to_language (env_lan);
  return "english";
#endif
}
Пример #25
0
url
get_texmacs_home_path () {
  url path= get_env ("TEXMACS_HOME_PATH");
  if (path == "")
    path= url_system ("$HOME/.TeXmacs");
  return path;
}
Пример #26
0
/*
 * getenv_int:
 */
static char *getenv_int(const char *name) {
#ifdef __OSE__
   return get_env(get_bid(current_process()),name);
#else
   return getenv(name);
#endif
}
Пример #27
0
int			deal_with_command(t_lst *node, char **arg)
{
	char			**path;
	char			*right_path;
	char			**env;

	env = get_env(node);
	path = (char **)malloc(sizeof(char *) * 7);
	if (!path)
		return (-1);
	path = split_path(node);
	if (path && *arg && env)
	{
		right_path = check_path(path, *arg);
		if (right_path)
		{
			exec_right_path(node, arg, env, right_path);
			return (-1);
		}
	}
	if (*arg && env)
	{
		right_path = "";
		check_command(node, arg, right_path, env);
		ft_strdel(arg);
	}
	return (-1);
}
Пример #28
0
int			main(int argc, char **argv, char **env)
{
	int		fd;

	get_env(env, 's');
	sh_increase_shlvl();
	fd = 0;
	if (argc == 2)
		fd = open(argv[1], O_RDONLY);
	else if (argc > 2)
		ft_putendl("Sorry, too many files to handle. Only one at a time");
	else
	{
		gestion_signal(0);
		ft_putendl("Welcome in this basic shell.");
		sh_help();
	}
	if (fd >= 0)
	{
		sh_boucle_lecture(fd);
		close(fd);
	}
	else
		ft_putendl("An error occured: Could not open the file");
	return (0);
}
Пример #29
0
Файл: cd.c Проект: NegMozzie/42
int					cd(t_shell *shell, t_tree *tree)
{
	char			*pwd;
	char			*path;
	char			*home;

	if (cd_needed(shell, tree, &pwd, &home) == EXIT_FAILURE)
		return (EXIT_FAILURE);
	cd_get_path(tree->argv, &path, pwd, home);
	if (!path)
	{
		if (!(path = get_env(shell->env, "OLDPWD")))
		{
			ft_putmsg(CD_OLDPWD, NULL);
			return (EXIT_FAILURE);
		}
		ft_putendl(path);
	}
	if (chdir(path) == -1)
		return (cd_error(&path, tree->argv[1]));
	else
		end_cd(shell, &path, &pwd);
	ft_del(&path, &pwd, &home);
	return (EXIT_SUCCESS);
}
Пример #30
0
Файл: cd.c Проект: ElKite/42
static	void	build_cd_bis(char **s, char **env)
{
	char *tmp;

	if (ft_tablen(s) == 2)
	{
		if (s[1][0] == '~')
		{
			tmp = ft_strsub(s[1], 1, ft_strlen(s[1]));
			s[1] = ft_strjoin(get_env("HOME", env), tmp);
			free(tmp);
		}
		if (s[1][0] == '-')
			s[1] = get_env("OLDPWD", env);
	}
}