示例#1
0
void load_presets(void)
{
	FILE *f=fopen("powder.def", "rb");
	unsigned char sig[4], tmp;
	if (!f)
		return;
	fread(sig, 1, 4, f);
	if (sig[0]!=0x50 || sig[1]!=0x44 || sig[2]!=0x65 || sig[3]!=0x66)
	{
		if (sig[0]==0x4D && sig[1]==0x6F && sig[2]==0x46 && sig[3]==0x6F)
		{
			if (fseek(f, -3, SEEK_END))
			{
				remove("powder.def");
				return;
			}
			if (fread(sig, 1, 3, f) != 3)
			{
				remove("powder.def");
				goto fail;
			}
			last_major = sig[0];
			last_minor = sig[1];
			update_flag = sig[2];
		}
		fclose(f);
		remove("powder.def");
		return;
	}
	if (load_string(f, svf_user, 63))
		goto fail;
	//if (load_string(f, svf_pass, 63))
	//goto fail;
	if (load_string(f, svf_user_id, 63))
		goto fail;
	if (load_string(f, svf_session_id, 63))
		goto fail;
	svf_login = !!svf_user[0];
	if (fread(&tmp, 1, 1, f) != 1)
		goto fail;
	sdl_scale = (tmp == 2) ? 2 : 1;
	if (fread(&tmp, 1, 1, f) != 1)
		goto fail;
	cmode = tmp%CM_COUNT;
	if (fread(&tmp, 1, 1, f) != 1)
		goto fail;
	svf_admin = tmp;
	if (fread(&tmp, 1, 1, f) != 1)
		goto fail;
	svf_mod = tmp;
	if (load_string(f, http_proxy_string, 255))
		goto fail;
	if (fread(sig, 1, 3, f) != 3)
		goto fail;
	last_major = sig[0];
	last_minor = sig[1];
	update_flag = sig[2];
fail:
	fclose(f);
}
示例#2
0
文件: setupc.c 项目: 131/gsview
int copyfile(char *dname, char *sname)
{
FILE *dfile, *sfile;
char *buffer;
char mess[MAXSTR];
int count;
#define COPY_BUF_SIZE 16384
    sfile = fopen(sname, "rb");
    if (sfile == (FILE *)NULL) {
	load_string(IDS_CANTOPENREAD, mess, sizeof(mess));
	sprintf(error_message, mess, sname);
	return 1;
    }
    dfile = fopen(dname, "wb");
    if (dfile == (FILE *)NULL) {
	load_string(IDS_CANTOPENWRITE, mess, sizeof(mess));
	sprintf(error_message, mess, dname);
	fclose(sfile);
	return 1;
    }
    if ( (buffer = (char *)malloc(COPY_BUF_SIZE)) == (char *)NULL ) {
	fclose(sfile);
	fclose(dfile);
	load_string(IDS_CANTALLOCBUF, error_message, sizeof(error_message));
	return 1;
    }

    while ( (count = fread(buffer, 1, COPY_BUF_SIZE, sfile)) != 0 )
	fwrite(buffer, 1, count, dfile);

    free(buffer);
    fclose(dfile);
    fclose(sfile);
    return 0;
}
示例#3
0
int main (void) {
	PageManager* pm = new_page_manager(".");
	printf("I Made my pm\n");
	printf("My index path is: %s\n", pm->index_path);
	RawPage* new_page = new_data_page(pm);
	printf("new page fd is %d at memory addr %p\n", new_page->fd, new_page->page);
	// Save some strings
	PageRef* str_1 = save_string(new_page, "Hello There");
	PageRef* str_2 = save_string(new_page, "I am a second string");
	printf("Before unload page\n");
	unload_page(new_page);
	printf("After unloda page\n");
	// load some strings
	load_string(pm, str_1);
	load_string(pm, str_2);

	//make our tree page
	RawPage* t_page = new_tree_page(pm);
	TreeNode* test_node = malloc(sizeof(TreeNode));
	memset(test_node, 0, sizeof(TreeNode));
	test_node->size = 0;
	test_node->order = 2;
	test_node->num_leaves = 0;
	test_node->parent.page_type = 0xDE110;
	test_node->parent.page_num = 31337;
	test_node->parent.node_offset = 31337;
	PageRef* node1 = save_node(t_page, test_node);
	unload_page(t_page);
	load_node(pm, node1);

}
示例#4
0
文件: r_shift.cpp 项目: azeem/chavs
void C_THISCLASS::load_config(unsigned char *data, int len)
{
	int pos=0;
  if (data[pos] == 1)
  {
    pos++;
    load_string(effect_exp[0],data,pos,len);
    load_string(effect_exp[1],data,pos,len);
    load_string(effect_exp[2],data,pos,len);
  }
  else
  {
    char buf[769];
    if (len-pos >= 768)
    {
      memcpy(buf,data+pos,768);
      pos+=768;
      buf[768]=0;
      effect_exp[2].assign(buf+512);
      buf[512]=0;
      effect_exp[1].assign(buf+256);
      buf[256]=0;
      effect_exp[0].assign(buf);
    }
  }
	if (len-pos >= 4) { blend=GET_INT(); pos+=4; }
	if (len-pos >= 4) { subpixel=GET_INT(); pos+=4; }

}
static DWORD driveui_msgbox (HWND parent, UINT messageId, DWORD flags)
{
  WCHAR* caption = load_string (IDS_WINECFG_TITLE);
  WCHAR* text = load_string (messageId);
  DWORD result = MessageBoxW (parent, text, caption, flags);
  HeapFree (GetProcessHeap(), 0, caption);
  HeapFree (GetProcessHeap(), 0, text);
  return result;
}
示例#6
0
文件: setupc.c 项目: 131/gsview
int
unzip_to_dir(char *filename, char *destination)
{
    /* start unzip session */  
    char fullname[256];
    FILE *f;
    int file_exists = 0;
    char cwd[256];
    int len;
    int rc;

    /* prompt for disk to be installed */
    strcpy(fullname, sourcedir);
    strcat(fullname, filename);
    while (!file_exists) {
	gs_addmess("Unzipping ");
	gs_addmess(fullname);
	gs_addmess("\n");
        if ( (f = fopen(fullname, "r")) == (FILE *)NULL ) {
	    char buf[256], mess[256];
	    gs_addmess_update();
	    load_string(IDS_INSERTDISK, mess, sizeof(mess));
	    sprintf(buf, mess, fullname);
	    strcpy(get_string_answer, fullname);
	    if (dialog(IDD_FILE, InputDlgProc) != DID_OK) {
		load_string(IDS_ZIPNOTFOUND, error_message, sizeof(error_message));
		return 1;
	    }
	    strcpy(fullname, get_string_answer);
	}
	else {
	    file_exists = TRUE;
	    fclose(f);
	}
    }

    getcwd(cwd, sizeof(cwd));
    gs_chdir(destination);
    strcpy(unzipprefix, destination);
    len = strlen(unzipprefix);
    if (len && (unzipprefix[len-1] == '\\'))
	unzipprefix[len-1] = '\0';
    rc = unzip(fullname);
    gs_chdir(cwd);

    if (!rc) {
        if (cancelling) {
	    load_string(IDS_UNZIPCANCELLED, error_message, sizeof(error_message));
	    return -1;
	}
    }
    return rc;
}
示例#7
0
文件: setup.c 项目: malikcjm/mc-nt
void panel_load_setup (WPanel *panel, char *section)
{
    int i;
    char buffer [40];
    
    panel->reverse = load_int (section, "reverse", 0);
    panel->case_sensitive = load_int (section, "case_sensitive", OS_SORT_CASE_SENSITIVE_DEFAULT);
    
    /* Load sort order */
    load_string (section, "sort_order", "name", buffer, sizeof (buffer));
    panel->sort_type = (sortfn *) sort_name;
    for (i = 0; sort_names [i].key; i++)
	if (strcasecmp (sort_names [i].key, buffer) == 0){
	    panel->sort_type = sort_names [i].sort_type;
	    break;
	}

    /* Load the listing mode */
    load_string (section, PORT_LIST_MODE_NAME, PORT_LIST_MODE_DEFAULT, buffer, sizeof (buffer));
    panel->list_type = list_full;
    for (i = 0; list_types [i].key; i++)
	if (strcasecmp (list_types [i].key, buffer) == 0){
	    panel->list_type = list_types [i].list_type;
	    break;
	}
#ifndef PORT_HAS_ICON_VIEW
    if (panel->list_type == list_icons)
        panel->list_type = list_full;
#endif
    /* User formats */
    if (panel->user_format){
	free (panel->user_format);
	panel->user_format = 0;
    }
    panel->user_format = strdup (get_profile_string (section, "user_format",
						     DEFAULT_USER_FORMAT,
						     profile_name));
    for (i = 0; i < LIST_TYPES; i++){
        if (panel->user_status_format [i])
	    free (panel->user_status_format [i]);
	sprintf (buffer, "user_status%d", i);
	panel->user_status_format [i] =
	    strdup (get_profile_string (section, buffer,
			DEFAULT_USER_FORMAT, profile_name));
    }
    
    panel->user_mini_status =
	load_int (section, "user_mini_status", 0);

}
示例#8
0
int OSC_Base::parseData(osc_message* message) {
  int offset = message->header.offset_to_data<<2;
  const char* buffer = message->header.path;
  
  message->data_count = message->typetag_length-1;
  message->data = (data_holder_type*)local_rx_malloc(sizeof(data_holder_type)*message->data_count);
  
  // make sure the holder is null
  memset(message->data, 0x00, sizeof(data_holder_type)*message->data_count);
  
  for (int i = 0; i < message->data_count; i++) {
    switch(message->typetag[i+1]) {
    case 'c': message->data[i].type = TYPE_CHARACTER;  offset += load_32bit(&buffer[offset], &message->data[i]); break;
    case 'f': message->data[i].type = TYPE_FLOAT;      offset += load_32bit(&buffer[offset], &message->data[i]); break;
    case 'i': message->data[i].type = TYPE_INTEGER;    offset += load_32bit(&buffer[offset], &message->data[i]); break;
    case 'r': message->data[i].type = TYPE_COLOR;      offset += load_32bit(&buffer[offset], &message->data[i]); break;
    case 't': message->data[i].type = TYPE_TIMETAG;    offset += load_64bit(&buffer[offset], &message->data[i]); break;
    case 'h': message->data[i].type = TYPE_LONG;       offset += load_64bit(&buffer[offset], &message->data[i]); break;
    case 'd': message->data[i].type = TYPE_DOUBLE;     offset += load_64bit(&buffer[offset], &message->data[i]); break;
    case 'F': message->data[i].type = TYPE_FALSE;      message->data[i].value_uint32 = 0; break; 
    case 'N': message->data[i].type = TYPE_NONE;       message->data[i].value_uint32 = 0; break;
    case 'I': message->data[i].type = TYPE_IMPULSE;    message->data[i].value_uint32 = 1; break;
    case 'T': message->data[i].type = TYPE_TRUE;       message->data[i].value_uint32 = 1; break;
    case 's': message->data[i].type = TYPE_STRING;     offset += load_string(&buffer[offset], &message->data[i]); break;
    case 'b': message->data[i].type = TYPE_BLOB;       offset += load_blob(&buffer[offset], &message->data[i]); break;
    case 'B': message->data[i].type = TYPE_ADVBLOB;    offset += load_blob(&buffer[offset], &message->data[i]); break;
    }
  }
}
示例#9
0
void 
gs_fix_bbox (url eps, int x1, int y1, int x2, int y2) {
// used to restore appropriate bounding box of an eps file in case epswrite 
// spuriously changes it (see gs_to_eps)
  string outbuf, buf;
  int inx1, iny1, inx2, iny2;
  bool err = load_string (eps, buf, false);
  if (!err) {
    if (DEBUG_CONVERT) debug_convert<< "fix_bbox input bbox : ";
    if ( !ps_read_bbox (buf, inx1, iny1, inx2, iny2 ) ) 
      return; //bbox not found... should not occur
    if (inx1!=x1 || iny1!=y1 || inx2!=x2 || iny2!=y2) {
      int pos= search_forwards ("%%BoundingBox:", buf);
      pos += 14;
      outbuf << buf(0, pos)
        << " " << as_string(x1) << " " << as_string(y1) 
        << " " << as_string(x2) << " " << as_string(y2) << "\n";
      skip_line (buf, pos);
      if (read (buf, pos, "%%HiResBoundingBox:")) skip_line (buf, pos);
      outbuf << buf(pos, N(buf));
      save_string (eps, outbuf, true);
      if (DEBUG_CONVERT) 
        debug_convert<< "restored bbox : " << ps_read_bbox (outbuf, x1, y1, x2, y2 )<<LF;
    }  
    set_imgbox_cache(eps->t, x2-x1, y2-y1, x1, y1);
  } 
}
示例#10
0
void init_strings() {
	for (int i = 0; i < OPCODES; ++i)  {		// For each opcode
		load_string(opcodes[i].name);		// copy the string into the input buffer
		ops[i].key = string();			// Then initialize the ops table
		ops[i].value = opcodes[i].opcode;	// with the correct targe values
	}
}
示例#11
0
void
dictionary_rep::load (url u) {
  if (is_none (u)) return;
  if (is_or (u)) {
    load (u[1]);
    load (u[2]);
    return;
  }

  string s;
  if (load_string (u, s, false)) return;
  tree t= block_to_scheme_tree (s);
  if (!is_tuple (t)) return;

  int i, n= N(t);
  for (i=0; i<n; i++)
    if (is_func (t[i], TUPLE, 2) &&
        is_atomic (t[i][0]) && is_atomic (t[i][1]))
    {
      string l= t[i][0]->label; if (is_quoted (l)) l= scm_unquote (l);
      string r= t[i][1]->label; if (is_quoted (r)) r= scm_unquote (r);
      if (to == "chinese" ||  to == "japanese"  || to == "german" ||
          to == "korean"  ||  to == "taiwanese" ||
          to == "russian" ||  to == "ukrainian" || to == "bulgarian")
        r= utf8_to_cork (r);
      table (l)= r;
    }
}
示例#12
0
文件: gvccmd.c 项目: 131/gsview
static void put_points(char *buf, int len, float n)
{
    TCHAR tbuf[32];
    char ubuf[32];
    float factor = 1.0;
    if (len < 1)
        return;
    buf[0] = '\0';
    ubuf[0] = '\0';
    load_string(IDS_UNITNAME + option.unit - IDM_UNITPT, tbuf, sizeof(tbuf));
    convert_widechar(ubuf, tbuf, sizeof(ubuf));
    if (len < 32 + (int)strlen(ubuf))
        return;
    switch (option.unit) {
    case IDM_UNITMM:
        factor = (float)(25.4 / 72.0);
        break;
    case IDM_UNITINCH:
        factor = (float)(1.0 / 72.0);
        break;
    case IDM_UNITPT:
    default:
        factor = 1.0;
    }
    sprintf(buf, "%g %s", n*factor, ubuf);
}
示例#13
0
void Settings::LoadFromFile(std::istream &is,  std::string (*load_string)(std::istream &is))
{
	for (int i = 0; i < number_of_fields; ++i)
	{
		names[i] = load_string( is);
	}
}
示例#14
0
translator
load_virtual (string name) {
  if (translator::instances -> contains (name))
    return translator (name);
  translator trl= tm_new<translator_rep> (name);

  string s, r;
  name= name * ".vfn";
  if (DEBUG_STD) debug_fonts << "Loading " << name << "\n";
  url u ("$TEXMACS_HOME_PATH/fonts/virtual:$TEXMACS_PATH/fonts/virtual", name);
  load_string (u, s, true);
  tree t= string_to_scheme_tree (s);
  ASSERT (is_tuple (t, "virtual-font"), "bad virtual font format");

  int i, n= N(t);
  trl->virt_def= array<tree> (n);
  for (i=1; i<n; i++)
    if (is_func (t[i], TUPLE, 2) && is_atomic (t[i][0])) {
      string s= as_string (t[i][0]);
      if (N(s)>1) s= "<" * s * ">";
      trl->dict (s)= i;
      trl->virt_def[i]= t[i][1];
      // cout << s << "\t" << i << "\t" << t[i][1] << "\n";
    }
  return trl;
}
示例#15
0
/*---------------------- start plugin init ------------------------------ */
int start(struct pluginlink * pluginlink, int argc, char** argv)
{
 FILE *f=NULL;

 mypl=pluginlink;
  
 if(old_proxy_table||old_admin_table) restore_old_table(NULL);
  
 if(!(f=fopen(argv[1],"r"))) return 1001;

  /*count string service PROXY in 3proxy  */
  count_str_proxy_in_3proxy=0;
  while( mypl->proxy_table[count_str_proxy_in_3proxy] != NULL ) 
       { count_str_proxy_in_3proxy++; }

  /*count string service ADMIN in 3proxy  */
  count_str_admin_in_3proxy=0;
  while( mypl->admin_table[count_str_admin_in_3proxy] != NULL ) 
       { count_str_admin_in_3proxy++; }

  /*---- load string for PROXY service ----*/
   old_proxy_table=load_string(f,count_str_proxy_in_3proxy,
 				&count_load_str_proxy_from_file,
			       "[--proxy--]","[/--proxy--]",
				mypl->proxy_table);
  

  if (old_proxy_table == NULL) 
   { 
     fprintf(stderr,"Error StringsPlugin: No load string from file %s \
             for service PROXY !\n",argv[1]);
   }
示例#16
0
int load_value (FILE *f, value *v, string *lnames)
{ value nv;
  int tag;
  if (!load_int (f, &tag)) return (0);
  nv = new_value (tag);
  nv -> dptr = (void *) lnames;
  switch (tag)
    { case string_value:
	if (!load_string (f, &nv -> u.str)) return (0);
	break;
      case integer_value:
	if (!load_int (f, &nv -> u.inum)) return (0);
	break;
      case real_value:
	if (!load_real(f, &nv -> u.rnum)) return (0);
	break;
      case tuple_value:
	if (!load_value_list (f, &nv -> u.tuple, lnames)) return (0);
	break;
      case small_lattice_value:
	if (!load_int (f, &nv -> u.slat)) return (0);
	break;
      case large_lattice_value:
	if (!load_int_list (f, &nv -> u.elat)) return (0);
	break;
      default:
	bad_tag (tag, "load_value");
    };
  *v = nv;
  return (1);
};
示例#17
0
void
cache_load (string buffer) {
  if (!cache_loaded->contains (buffer)) {
    url cache_file = texmacs_home_path * url ("system/cache/" * buffer);
    //cout << "cache_file "<< cache_file << LF;
    string cached;
    if (!load_string (cache_file, cached, false)) {
      if (buffer == "file_cache" || buffer == "doc_cache") {
	int i=0, n= N(cached);
	while (i<n) {
	  int start= i;
	  while (i<n && cached[i] != '\n') i++;
	  string key= cached (start, i);
	  i++; start= i;
	  while (i<n && (cached[i] != '\n' ||
			 !test (cached, i+1, "%-%-tm-cache-%-%"))) i++;
	  string im= cached (start, i);
	  i++;
	  while (i<n && cached[i] != '\n') i++;
	  i++;
	  //cout << "key= " << key << "\n----------------------\n";
	  //cout << "im= " << im << "\n----------------------\n";
	  cache_data (tuple (buffer, key))= im;
	}
      }
      else {
	tree t= scheme_to_tree (cached);
	for (int i=0; i<N(t)-1; i+=2)
	  cache_data (tuple (buffer, t[i]))= t[i+1];
      }
    }
    cache_loaded->insert (buffer);
  }
}
示例#18
0
void
setup_texmacs () {
  url settings_file= "$TEXMACS_HOME_PATH/system/settings.scm";
  debug_boot << "Welcome to TeXmacs " TEXMACS_VERSION "\n";
  debug_boot << HRULE;

  set_setting ("VERSION", TEXMACS_VERSION);
  setup_tex ();
  setup_inkscape_extension ();
  
  string s= scheme_tree_to_block (texmacs_settings);
  //cout << "settings_t= " << texmacs_settings << "\n";
  //cout << "settings_s= " << s << "\n";
  if (save_string (settings_file, s) || load_string (settings_file, s, false)) {
    failed_error << HRULE;
    failed_error << "I could not save or reload the file\n\n";
    failed_error << "\t" << settings_file << "\n\n";
    failed_error << "Please give me full access control over this file and\n";
    failed_error << "rerun 'TeXmacs'.\n";
    failed_error << HRULE;
    FAILED ("unable to write settings");
  }
  
  debug_boot << HRULE;
  debug_boot << "Installation completed successfully !\n";
  debug_boot << "I will now start up the editor\n";
  debug_boot << HRULE;
}
示例#19
0
int		draw_table(t_display *win, t_menu_entry *menu)
{
  t_menu_table	*info;

  info = (t_menu_table*)menu->info;
  win->dest.x = info->x;
  win->dest.y = info->y;
  win->dest.w = info->width;
  win->dest.h = info->height;
  fprintf(fd_log, "drawing a fecking table at x[%i]y[%i]h[%i]w[%i]\n",
	  win->dest.x,win->dest.y,win->dest.h,win->dest.w);
  win->img = SDL_CreateRGBSurface(SDL_HWSURFACE, win->dest.w, win->dest.h,
						  gfx->bpp,
						  win->sdlMainScreen->format->Rmask,
						  win->sdlMainScreen->format->Gmask,
						  win->sdlMainScreen->format->Bmask,
						  win->sdlMainScreen->format->Amask);
  SDL_SetColorKey(win->img, SDL_SRCCOLORKEY,0);
  SDL_FillRect(win->img, NULL, SDL_MapRGB(win->sdlMainScreen->format,42,42,42));
  aff_surf(win->img, 200);
  SDL_FreeSurface(win->img);
  win->text = load_string(info->title, FONT, 14);
  win->dest.x = info->x + ((info->width - win->text->w) / 2);
  win->dest.y = info->y + 12;
  aff_surf(win->text, 255);
  SDL_FreeSurface(win->text);
  return(0);
}
示例#20
0
int	draw_txtbox(t_display *win, t_menu_entry *menu)
{
  t_menu_text	*info;
  char		*old;

  // implement txtbox growth according to font size
  // implement coloring according to 
  info = (t_menu_text*)menu->info;
  win->dest.x = info->x;
  win->dest.y = info->y;
  if (info->value)
    win->text = load_string(info->value, FONT, info->text_size);
  else
    win->text = load_string(" ", FONT, info->text_size);
  win->dest.h = win->text->h + 4;
  win->dest.w = TXTBOX_WIDTH + 4;
  win->img = SDL_CreateRGBSurface(SDL_HWSURFACE, win->dest.w, win->dest.h,
						  gfx->bpp,
						  win->sdlMainScreen->format->Rmask,
						  win->sdlMainScreen->format->Gmask,
						  win->sdlMainScreen->format->Bmask,
						  win->sdlMainScreen->format->Amask);
  SDL_SetColorKey(win->img, SDL_SRCCOLORKEY,0);
  SDL_FillRect(win->img, NULL, SDL_MapRGB(win->sdlMainScreen->format,42,42,42));
  win->dest.x = 1;
  win->dest.y = 1;
  win->dest.h = win->text->h + 2;
  win->dest.w = TXTBOX_WIDTH + 2;
  SDL_FillRect(win->img, &(win->dest), GetColor(win, info->background));
  win->dest.x = info->x;
  win->dest.y = info->y;
  aff_surf(win->img, 255);
  SDL_FreeSurface(win->img);
  win->dest.x = info->x + 4;
  win->dest.y = info->y + 2;
  while (win->text->w > TXTBOX_WIDTH - 4)
  {
    old = info->value;
    info->value = xstrndup(info->value, xstrlen(info->value) - 1);
    free(old);
    SDL_FreeSurface(win->text);  
    win->text = load_string(info->value, FONT, info->text_size);    
  }
  aff_surf(win->text, 255);
  SDL_FreeSurface(win->text);  
  return(0);
}
示例#21
0
void
tmfs_import (url prj_dir, url u, string prj) {
  cout << "Process " << (prj_dir * u) << "\n";
  if (is_or (u)) {
    tmfs_import (prj_dir, u[1], prj);
    tmfs_import (prj_dir, u[2], prj);
  }
  else if (is_directory (prj_dir * u)) {
    bool flag;
    array<string> a= read_directory (prj_dir * u, flag);
    if (flag) return;
    for (int i=0; i<N(a); i++)
      if (!is_cruft (a[i]) && a[i] != "." && a[i] != "..")
	tmfs_import (prj_dir, u * a[i], prj);
  }
  else if (is_regular (prj_dir * u)) {
    string loc= as_string (u);
    properties ps;
    ps << seq ("mirror", "?file", prj, loc) << seq ("in", "?file", prj);
    collection files= tmfs_query (ps, "?file");
    if (N (files) == 0) {
      properties xps; xps << seq ("mirror", "self", prj, loc);
      string val = load_string (prj_dir * u);
      string name= create_name (as_string (tail (u)), val);
      string file= tmfs_create_file (name, val, prj, xps);
      cout << "Import " << u << " -> " << file << "\n";
    }
    else {
      string file= first (files);
      string val1= tmfs_load_file (file);
      string val2= load_string (prj_dir * u);
      if (val1 == val2) return;
      tmfs_save_file (file, val2);
      cout << "Update " << u << " -> " << file << "\n";
    }
  }

  properties ps= tmfs_list_heads_inside (u, prj);
  for (int i=0; i<N(ps); i++) {
    url    v = ps[i][0];
    string file= ps[i][1];
    if (!exists (prj_dir * v)) {
      tmfs_reset_head (file);
      cout << "Remove " << v << " -> " << file << "\n";
    }
  }
}
示例#22
0
文件: gvccmd.c 项目: 131/gsview
static float get_points(const char *str)
{
    float val;
    char ptbuf[32];
    char inchbuf[32];
    char mmbuf[32];
    TCHAR tbuf[32];
    const char *p = str;
    int i;
    ptbuf[0] = inchbuf[0] = mmbuf[0] = '\0';
    load_string(IDS_UNITNAME + IDM_UNITPT - IDM_UNITPT, tbuf, sizeof(tbuf));
    convert_widechar(ptbuf, tbuf, sizeof(ptbuf));
    load_string(IDS_UNITNAME + IDM_UNITINCH - IDM_UNITPT,
                tbuf, sizeof(tbuf));
    convert_widechar(inchbuf, tbuf, sizeof(inchbuf));
    load_string(IDS_UNITNAME + IDM_UNITMM - IDM_UNITPT, tbuf, sizeof(tbuf));
    convert_widechar(mmbuf, tbuf, sizeof(mmbuf));
    while (*p && (*p == ' '))
        p++;
    val = (float)atof(p);
    while (*p && (isdigit((int)(*p)) || (*p == '.')))
        p++;
    while (*p && (*p == ' '))
        p++;
    i = 0;;
    while (p[i] && (isalpha((int)(p[i]))))
        i++;
    if (p[i])
        i++;
    if ((strnicmp(p, ptbuf, max(i, (int)strlen(ptbuf))) == 0) ||
            (strnicmp(p, "pt", 2) == 0)) {
        /* do nothing */
    }
    else if ((strnicmp(p, inchbuf, max(i, (int)strlen(inchbuf))) == 0) ||
             (strnicmp(p, "in", 2) == 0))
        val *= 72.0;
    else if ((strnicmp(p, mmbuf, max(i, (int)strlen(mmbuf))) == 0) ||
             (strnicmp(p, "mm", 2) == 0))
        val *= (float)(72.0 / 25.4);
    else if (strnicmp(p, "cm", 2) == 0)
        val *= (float)(72.0 / 2.54);
    else if (strnicmp(p, "m", 1) == 0)
        val *= (float)(72.0 / 0.0254);
    else if (strnicmp(p, "ft", 2) == 0)
        val *= (float)(72.0 * 12.0);
    return val;
}
示例#23
0
char *
xload_dbpath(void)
{
	char *homepath, *confpath, *dbpath;
	GKeyFile *kf;
	GError *error;

	/* Get home directory */
	if (g_getenv(ENV_HOME_DIR))
		homepath = g_strdup(g_getenv(ENV_HOME_DIR));
	else if (g_getenv("HOME"))
		homepath = g_build_filename(g_getenv("HOME"), DOT_MPDCRON, NULL);
	else {
		g_printerr("Neither "ENV_HOME_DIR" nor HOME is set, exiting!");
		exit(1);
	}

	/* Set keyfile path */
	confpath = g_build_filename(homepath, PACKAGE".conf", NULL);

	/* Load key file */
	dbpath = NULL;
	error = NULL;
	kf = g_key_file_new();
	if (!g_key_file_load_from_file(kf, confpath, G_KEY_FILE_NONE, &error)) {
		switch (error->code) {
			case G_FILE_ERROR_NOENT:
			case G_KEY_FILE_ERROR_NOT_FOUND:
				g_error_free(error);
				g_key_file_free(kf);
				goto skip;
			default:
				g_printerr("Failed to parse configuration file `%s': %s",
					confpath, error->message);
				g_error_free(error);
				g_key_file_free(kf);
				exit(1);
		}
	}

	error = NULL;
	if (!load_string(kf, "stats", "dbpath", false, &dbpath, &error)) {
		g_printerr("%s\n", error->message);
		g_error_free(error);
		g_free(confpath);
		g_free(homepath);
		g_key_file_free(kf);
		exit(1);
	}
	g_key_file_free(kf);

skip:
	if (dbpath == NULL)
		dbpath = g_build_filename(homepath, "stats.db", NULL);
	g_free(confpath);
	g_free(homepath);

	return dbpath;
}
示例#24
0
	virtual type_list get(){
		type_list my_int_list_;
		std::string results = execute("XQUERY <list>{for $i in 1 to 10 return <i>{$i}</i>}</list>");
		std::cout << "Result: " << results << std::endl;
		load_string(results.c_str());
		my_int_list_ = get_list<int>("/list/i");
		return my_int_list_;
	};
示例#25
0
// Call load_string and protected call. Make them throw exceptions.
//
void lua_kernel_base::throwing_run(const char * prog, int nArgs)
{
	cmd_log_ << "$ " << prog << "\n";
	error_handler eh = std::bind(&lua_kernel_base::throw_exception, this, _1, _2 );
	load_string(prog, eh);
	lua_insert(mState, -nArgs - 1);
	protected_call(nArgs, 0, eh);
}
示例#26
0
void init_lexicon() {
	for (int i = 0; i < OPCODES; ++i) {		// For each opcode we compile a simple definition
		memory[--lexicon] = ops[i].value;	// which will form the basis for the Core Object
		memory[--lexicon] = ops[i].key;		// In the native compiler, we'll use these as lits
	}
	load_string("Core");				// We can load the string "Core" for the core
	memory[--lexicon] = OPCODES;			// Object, but we never use this with find
	memory[--lexicon] = string(); 			// it is just a tool for debugging
}
示例#27
0
文件: setup.c 项目: malikcjm/mc-nt
char *load_anon_passwd ()
{
    char buffer [255];

    load_string ("Misc", "ftpfs_password", "", buffer, sizeof (buffer));
    if (buffer [0])
	return strdup (buffer);
    else
	return 0;
}
示例#28
0
文件: gvcbeta.c 项目: 131/gsview
int beta_warn(void)
{
  TCHAR buf[256];
  TCHAR mess[MAXSTR];
  load_string(IDS_BETAWARN, mess, sizeof(mess)/sizeof(TCHAR)-1);
  wsprintf(buf, mess, BETA_YEAR, BETA_MONTH, BETA_DAY);
  if (message_box(buf, MB_OKCANCEL | MB_ICONEXCLAMATION) != IDOK)
      return 1;
  return beta();
}
示例#29
0
文件: gvcbeta.c 项目: 131/gsview
int beta(void)
{
  if (beta_expired()) {
    TCHAR buf[MAXSTR];
    load_string(IDS_BETAEXPIRED, buf, sizeof(buf)/sizeof(TCHAR)-1);
    message_box(buf, MB_OK | MB_ICONHAND);
    return 1;
  }
  return 0;
}
/*
 * Class:     calliope_AeseSpeller
 * Method:    hasWord
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
 */
JNIEXPORT jboolean JNICALL Java_calliope_AeseSpeller_hasWord
  (JNIEnv *env, jobject obj, jstring jword, jstring lang)
{
    int correct = 0;
    jboolean copied1, copied2;
    checker *c = checkers;
    const char *word = load_string( env, jword, &copied1 );
    const char *language = load_string( env, lang, &copied2 );
    while ( c != NULL )
        if ( strcmp(language,c->lang)!=0 )
            c = c->next;
        else
            break;
    if ( c == NULL )
    {
        c = checker_create( language );
        if ( c != NULL )
        {
            if ( checkers == NULL )
                checkers = c;
            else
            {
                checker *temp = checkers;
                while ( temp->next != NULL )
                    temp = temp->next;
                temp->next = c;
            }
        }
    }
    if ( c != NULL )
    {
        correct = aspell_speller_check(c->spell_checker, word, 
            strlen(word));
    }
    else
        fprintf(stderr,"checker: no dict for language %s\n",language);
    if ( copied1 )
        unload_string( env, jword, word, copied1 );
    if ( copied2 )
        unload_string( env, lang, language, copied2 );
    return correct;
}