static void fgettext_add_one_path(char *path, int position) { char *dir,*domain; FGettextPath *tmp; if (!HaveNLSSupport) { return; } domain = GetQuotedString(path, &dir, ";", NULL, NULL, NULL); if (!dir || dir[0] == '\0' || dir[0] != '/') { if (dir) { free(dir); } CopyString(&dir, FGDefaultDir); } if (!domain || domain[0] == '\0') { domain = FGDefaultDomain; } tmp = (FGettextPath *)safemalloc(sizeof(FGettextPath)); tmp->dir = dir; CopyString(&tmp->domain, domain); FGPathList = flist_insert_obj(FGPathList, tmp, position); }
/* * name * family * description * */ void AddSensor( char * input_string ) { char * s_name = NULL ; char * s_family = NULL ; char * s_description = NULL ; char * s_data = NULL ; char * start_pointer = input_string ; if ( input_string == NULL ) { return ; } if ( ! Globals.allow_external ) { LEVEL_DEBUG("External prgroams not supported by %s",Globals.argv[0]) ; return ; } // name GetQuotedString( name ) ; // family GetQuotedString( family ) ; // description GetQuotedString( description ) ; // data GetQuotedString( data ) ; if ( strlen(s_name) > 0 && strlen(s_family) > 0 ) { // Actually add AddFamilyToTree( s_family ) ; AddSensorToTree( s_name, s_family, s_description, s_data ) ; create_just_print( "family", s_family, s_family ) ; create_just_print( "type", s_family, "external" ) ; } // Clean up owfree( s_name ); owfree( s_family ) ; owfree( s_description ) ; owfree( s_data ) ; }
WRes CProcess::Create(LPCWSTR imageName, const UString ¶ms, LPCWSTR curDir) { Close(); const UString params2 = #ifndef UNDER_CE GetQuotedString(imageName) + L' ' + #endif params; #ifdef UNDER_CE curDir = 0; #else imageName = 0; #endif PROCESS_INFORMATION pi; BOOL result; #ifndef _UNICODE if (!g_IsNT) { STARTUPINFOA si; si.cb = sizeof(si); si.lpReserved = 0; si.lpDesktop = 0; si.lpTitle = 0; si.dwFlags = 0; si.cbReserved2 = 0; si.lpReserved2 = 0; CSysString curDirA; if (curDir != 0) curDirA = GetSystemString(curDir); result = ::CreateProcessA(NULL, (LPSTR)(LPCSTR)GetSystemString(params2), NULL, NULL, FALSE, 0, NULL, ((curDir != 0) ? (LPCSTR)curDirA: 0), &si, &pi); } else #endif { STARTUPINFOW si; si.cb = sizeof(si); si.lpReserved = 0; si.lpDesktop = 0; si.lpTitle = 0; si.dwFlags = 0; si.cbReserved2 = 0; si.lpReserved2 = 0; result = CreateProcessW(imageName, (LPWSTR)(LPCWSTR)params2, NULL, NULL, FALSE, 0, NULL, (LPWSTR)curDir, &si, &pi); } if (result == 0) return ::GetLastError(); ::CloseHandle(pi.hThread); _handle = pi.hProcess; return 0; }
/* translate a colorset spec into a colorset structure */ void parse_colorset(int n, char *line) { int i; int w; int h; int tmp; int percent; colorset_t *cs; char *optstring; char *args; char *option; char *tmp_str; char *fg = NULL; char *bg = NULL; char *hi = NULL; char *sh = NULL; char *fgsh = NULL; char *tint = NULL; char *fg_tint = NULL; char *bg_tint = NULL; char *icon_tint = NULL; Bool have_pixels_changed = False; Bool has_icon_pixels_changed = False; Bool has_fg_changed = False; Bool has_bg_changed = False; Bool has_sh_changed = False; Bool has_hi_changed = False; Bool has_fgsh_changed = False; Bool has_fg_alpha_changed = False; Bool has_tint_changed = False; Bool has_fg_tint_changed = False; Bool has_bg_tint_changed = False; Bool has_icon_tint_changed = False; Bool has_pixmap_changed = False; Bool has_shape_changed = False; Bool has_image_alpha_changed = False; Bool pixmap_is_a_bitmap = False; Bool do_reload_pixmap = False; Bool is_server_grabbed = False; XColor color; XGCValues xgcv; static char *name = "parse_colorset"; Window win = Scr.NoFocusWin; static GC gc = None; /* initialize statics */ if (gc == None) { gc = fvwmlib_XCreateGC(dpy, win, 0, &xgcv); } /* make sure it exists and has sensible contents */ alloc_colorset(n); cs = &Colorset[n]; /*** Parse the options ***/ while (line && *line) { /* Read next option specification delimited by a comma or \0. */ line = GetQuotedString( line, &optstring, ",", NULL, NULL, NULL); if (!optstring) break; args = GetNextToken(optstring, &option); if (!option) { free(optstring); break; } switch((i = GetTokenIndex(option, csetopts, 0, NULL))) { case 0: /* Foreground */ case 1: /* Fore */ case 2: /* fg */ get_simple_color( args, &fg, cs, FG_SUPPLIED, FG_CONTRAST, "contrast"); has_fg_changed = True; break; case 3: /* Background */ case 4: /* Back */ case 5: /* bg */ get_simple_color( args, &bg, cs, BG_SUPPLIED, BG_AVERAGE, "average"); has_bg_changed = True; break; case 6: /* Hilight */ case 7: /* Hilite */ case 8: /* hi */ get_simple_color(args, &hi, cs, HI_SUPPLIED, 0, NULL); has_hi_changed = True; break; case 9: /* Shadow */ case 10: /* Shade */ case 11: /* sh */ get_simple_color(args, &sh, cs, SH_SUPPLIED, 0, NULL); has_sh_changed = True; break; case 12: /* fgsh */ get_simple_color( args, &fgsh, cs, FGSH_SUPPLIED, 0,NULL); has_fgsh_changed = True; break; case 13: /* fg_alpha */ case 14: /* fgAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->fg_alpha_percent) { cs->fg_alpha_percent = tmp; has_fg_alpha_changed = True; } break; case 15: /* TiledPixmap */ case 16: /* Pixmap */ case 17: /* AspectPixmap */ has_pixmap_changed = True; free_colorset_background(cs, True); tmp_str = PeekToken(args, &args); if (tmp_str) { CopyString(&cs->pixmap_args, tmp_str); do_reload_pixmap = True; cs->gradient_type = 0; /* set the flags */ if (csetopts[i][0] == 'T') { cs->pixmap_type = PIXMAP_TILED; } else if (csetopts[i][0] == 'A') { cs->pixmap_type = PIXMAP_STRETCH_ASPECT; } else { cs->pixmap_type = PIXMAP_STRETCH; } } /* the pixmap is build later */ break; case 18: /* Shape */ case 19: /* TiledShape */ case 20: /* AspectShape */ parse_shape(win, cs, i, args, &has_shape_changed); break; case 21: /* Plain */ has_pixmap_changed = True; free_colorset_background(cs, True); break; case 22: /* NoShape */ has_shape_changed = True; if (cs->shape_mask) { add_to_junk(cs->shape_mask); cs->shape_mask = None; } break; case 23: /* Transparent */ /* This is only allowable when the root depth == fvwm * visual depth otherwise bad match errors happen, * it may be even more restrictive but my tests (on * exceed 6.2) show that only == depth is necessary */ if (Pdepth != DefaultDepth(dpy, (DefaultScreen(dpy)))) { fvwm_msg( ERR, name, "can't do Transparent " "when root_depth!=fvwm_depth"); break; } has_pixmap_changed = True; free_colorset_background(cs, True); cs->pixmap = ParentRelative; cs->pixmap_type = PIXMAP_STRETCH; break; case 24: /* RootTransparent */ if (Pdepth != DefaultDepth(dpy, (DefaultScreen(dpy)))) { fvwm_msg( ERR, name, "can't do RootTransparent " "when root_depth!=fvwm_depth"); break; } free_colorset_background(cs, True); has_pixmap_changed = True; cs->pixmap_type = PIXMAP_ROOT_PIXMAP_PURE; do_reload_pixmap = True; tmp_str = PeekToken(args, &args); if (StrEquals(tmp_str, "buffer")) { cs->allows_buffered_transparency = True; } else { cs->allows_buffered_transparency = False; } cs->is_maybe_root_transparent = True; break; case 25: /* Tint */ case 26: /* PixmapTint */ case 27: /* ImageTint */ case 28: /* TintMask */ parse_simple_tint( cs, args, &tint, TINT_SUPPLIED, &has_tint_changed, &percent, "tint"); if (has_tint_changed) { cs->tint_percent = percent; } break; case 29: /* NoTint */ has_tint_changed = True; cs->tint_percent = 0; cs->color_flags &= ~TINT_SUPPLIED; break; case 30: /* fgTint */ parse_simple_tint( cs, args, &fg_tint, FG_TINT_SUPPLIED, &has_fg_tint_changed, &percent, "fgTint"); if (has_fg_tint_changed) { cs->fg_tint_percent = percent; } break; case 31: /* bgTint */ parse_simple_tint( cs, args, &bg_tint, BG_TINT_SUPPLIED, &has_bg_tint_changed, &percent, "bgTint"); if (has_bg_tint_changed) { cs->bg_tint_percent = percent; } break; case 32: /* dither */ if (cs->pixmap_args || cs->gradient_args) { has_pixmap_changed = True; do_reload_pixmap = True; } cs->dither = True; break; case 33: /* nodither */ if (cs->pixmap_args || cs->gradient_args) { has_pixmap_changed = True; do_reload_pixmap = True; } cs->dither = False; break; case 34: /* Alpha */ case 35: /* PixmapAlpha */ case 36: /* ImageAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->image_alpha_percent) { has_image_alpha_changed = True; cs->image_alpha_percent = tmp; } break; /* dither icon is not dynamic (yet) maybe a bad opt: default * to False ? */ case 37: /* ditherIcon */ cs->do_dither_icon = True; break; case 38: /* DoNotDitherIcon */ cs->do_dither_icon = False; break; case 39: /* IconTint */ parse_simple_tint( cs, args, &icon_tint, ICON_TINT_SUPPLIED, &has_icon_tint_changed, &percent, "IconTint"); if (has_icon_tint_changed) { cs->icon_tint_percent = percent; has_icon_pixels_changed = True; } break; case 40: /* NoIconTint */ has_icon_tint_changed = True; if (cs->icon_tint_percent != 0) { has_icon_pixels_changed = True; } cs->icon_tint_percent = 0; break; case 41: /* IconAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->icon_alpha_percent) { has_icon_pixels_changed = True; cs->icon_alpha_percent = tmp; } break; default: /* test for ?Gradient */ if (option[0] && StrEquals(&option[1], "Gradient")) { cs->gradient_type = toupper(option[0]); if (!IsGradientTypeSupported(cs->gradient_type)) break; has_pixmap_changed = True; free_colorset_background(cs, True); CopyString(&cs->gradient_args, args); do_reload_pixmap = True; if (cs->gradient_type == V_GRADIENT) { cs->pixmap_type = PIXMAP_STRETCH_Y; } else if (cs->gradient_type == H_GRADIENT) cs->pixmap_type = PIXMAP_STRETCH_X; else cs->pixmap_type = PIXMAP_STRETCH; } else { fvwm_msg( WARN, name, "bad colorset pixmap " "specifier %s %s", option, line); } break; } /* switch */ if (option) { free(option); option = NULL; } free(optstring); optstring = NULL; } /* while (line && *line) */ /* * ---------- change the "pixmap" tint colour ---------- */ if (has_tint_changed) { /* user specified colour */ if (tint != NULL) { Pixel old_tint = cs->tint; PictureFreeColors(dpy, Pcmap, &cs->tint, 1, 0, True); cs->tint = GetColor(tint); if (old_tint != cs->tint) { have_pixels_changed = True; } } else if (tint == NULL) { /* default */ Pixel old_tint = cs->tint; PictureFreeColors(dpy, Pcmap, &cs->tint, 1, 0, True); cs->tint = GetColor(black); if (old_tint != cs->tint) { have_pixels_changed = True; } } } /* * reload the gradient if the tint or the alpha have changed. * Do this too if we need to recompute the bg average and the * gradient is tinted (perforemence issue). */ if ((has_tint_changed || has_image_alpha_changed || (has_bg_changed && (cs->color_flags & BG_AVERAGE) && cs->tint_percent > 0)) && cs->gradient_args) { do_reload_pixmap = True; } /* * reset the pixmap if the tint or the alpha has changed */ if (!do_reload_pixmap && (has_tint_changed || has_image_alpha_changed || (has_bg_changed && cs->alpha_pixmap != None))) { if (cs->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE || cs->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN) { do_reload_pixmap = True; } else if (cs->picture != NULL && cs->pixmap) { XSetClipMask(dpy, gc, cs->picture->mask); reset_cs_pixmap(cs, gc); XSetClipMask(dpy, gc, None); has_pixmap_changed = True; } } /* * (re)build the pixmap or the gradient */ if (do_reload_pixmap) { free_colorset_background(cs, False); has_pixmap_changed = True; if (cs->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE || cs->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN) { cs->pixmap_type = 0; if (root_pic.pixmap) { cs->pixmap = root_pic.pixmap; cs->width = root_pic.width; cs->height = root_pic.height; cs->pixmap_type = PIXMAP_ROOT_PIXMAP_PURE; #if 0 fprintf(stderr,"Cset %i LoadRoot 0x%lx\n", n, cs->pixmap); #endif } } else if (cs->pixmap_args) { parse_pixmap(win, gc, cs, &pixmap_is_a_bitmap); } else if (cs->gradient_args) { cs->pixmap = CreateGradientPixmapFromString( dpy, win, gc, cs->gradient_type, cs->gradient_args, &w, &h, &cs->pixels, &cs->nalloc_pixels, cs->dither); cs->width = w; cs->height = h; } has_pixmap_changed = True; } if (cs->picture != NULL && cs->picture->depth != Pdepth) { pixmap_is_a_bitmap = True; } /* * ---------- change the background colour ---------- */ if (has_bg_changed || (has_pixmap_changed && (cs->color_flags & BG_AVERAGE) && cs->pixmap != None && cs->pixmap != ParentRelative && !pixmap_is_a_bitmap)) { Bool do_set_default_background = False; Pixmap average_pix = None; if (cs->color_flags & BG_AVERAGE) { if (cs->picture != NULL && cs->picture->picture != None) { average_pix = cs->picture->picture; } else if (cs->pixmap != ParentRelative) { average_pix = cs->pixmap; } if (average_pix == root_pic.pixmap) { int w; int h; XID dummy; MyXGrabServer(dpy); is_server_grabbed = True; if (!XGetGeometry( dpy, average_pix, &dummy, (int *)&dummy, (int *)&dummy, (unsigned int *)&w, (unsigned int *)&h, (unsigned int *)&dummy, (unsigned int *)&dummy)) { average_pix = None; } else { if (w != cs->width || h != cs->height) { average_pix = None; } } if (average_pix == None) { MyXUngrabServer(dpy); is_server_grabbed = False; } } } /* note: no average for bitmap */ if ((cs->color_flags & BG_AVERAGE) && average_pix) { /* calculate average background color */ XColor *colors; XImage *image; XImage *mask_image = None; unsigned int i, j, k = 0; unsigned long red = 0, blue = 0, green = 0; unsigned long tred, tblue, tgreen; double dred = 0.0, dblue = 0.0, dgreen = 0.0; has_bg_changed = True; /* create an array to store all the pixmap colors in */ /* Note: this may allocate a lot of memory: * cs->width * cs->height * 12 and then the rest of the * procedure can take a lot of times */ colors = (XColor *)safemalloc( cs->width * cs->height * sizeof(XColor)); /* get the pixmap and mask into an image */ image = XGetImage( dpy, average_pix, 0, 0, cs->width, cs->height, AllPlanes, ZPixmap); if (cs->mask != None) { mask_image = XGetImage( dpy, cs->mask, 0, 0, cs->width, cs->height, AllPlanes, ZPixmap); } if (is_server_grabbed == True) { MyXUngrabServer(dpy); } if (image != None && mask_image != None) { /* only fetch the pixels that are not masked * out */ for (i = 0; i < cs->width; i++) { for (j = 0; j < cs->height; j++) { if ( cs->mask == None || XGetPixel( mask_image, i, j) == 0) { colors[k++].pixel = XGetPixel( image, i, j); } } } } if (image != None) { XDestroyImage(image); } if (mask_image != None) { XDestroyImage(mask_image); } if (k == 0) { do_set_default_background = True; } else { /* look them all up, XQueryColors() can't * handle more than 256 */ for (i = 0; i < k; i += 256) { XQueryColors( dpy, Pcmap, &colors[i], min(k - i, 256)); } /* calculate average, add overflows in a double * .red is short, red is long */ for (i = 0; i < k; i++) { tred = red; red += colors[i].red; if (red < tred) { dred += (double)tred; red = colors[i].red; } tgreen = green; green += colors[i].green; if (green < tgreen) { dgreen += (double)tgreen; green = colors[i].green; } tblue = blue; blue += colors[i].blue; if (blue < tblue) { dblue += (double)tblue; blue = colors[i].blue; } } dred += red; dgreen += green; dblue += blue; /* get it */ color.red = dred / k; color.green = dgreen / k; color.blue = dblue / k; { Pixel old_bg = cs->bg; PictureFreeColors( dpy, Pcmap, &cs->bg, 1, 0, True); PictureAllocColor( dpy, Pcmap, &color, True); cs->bg = color.pixel; if (old_bg != cs->bg) { have_pixels_changed = True; } } } free(colors); } /* average */ else if ((cs->color_flags & BG_SUPPLIED) && bg != NULL) { /* user specified colour */ Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetColor(bg); if (old_bg != cs->bg) { have_pixels_changed = True; } } /* user specified */ else if (bg == NULL && has_bg_changed) { /* default */ do_set_default_background = True; } /* default */ if (do_set_default_background) { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetColor(white); if (old_bg != cs->bg) { have_pixels_changed = True; } has_bg_changed = True; } if (has_bg_changed) { /* save the bg color for tinting */ cs->bg_saved = cs->bg; } } /* has_bg_changed */ /* * ---------- setup the bg tint colour ---------- */ if (has_bg_tint_changed && cs->bg_tint_percent > 0 && bg_tint != NULL) { PictureFreeColors(dpy, Pcmap, &cs->bg_tint, 1, 0, True); cs->bg_tint = GetColor(bg_tint); } /* * ---------- tint the bg colour ---------- */ if (has_bg_tint_changed || (has_bg_changed && cs->bg_tint_percent > 0)) { if (cs->bg_tint_percent == 0) { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = cs->bg_saved; if (old_bg != cs->bg) { have_pixels_changed = True; has_bg_changed = True; } } else { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetTintedPixel( cs->bg_saved, cs->bg_tint, cs->bg_tint_percent); if (old_bg != cs->bg) { have_pixels_changed = True; has_bg_changed = True; } } } /* * ---------- setup the fg tint colour ---------- */ if (has_fg_tint_changed && cs->fg_tint_percent > 0 && fg_tint != NULL) { PictureFreeColors(dpy, Pcmap, &cs->fg_tint, 1, 0, True); cs->fg_tint = GetColor(fg_tint); } /* * ---------- change the foreground colour ---------- */ if (has_fg_changed || (has_bg_changed && (cs->color_flags & FG_CONTRAST))) { if (cs->color_flags & FG_CONTRAST) { Pixel old_fg = cs->fg; /* calculate contrasting foreground color */ color.pixel = cs->bg; XQueryColor(dpy, Pcmap, &color); color.red = (color.red > 32767) ? 0 : 65535; color.green = (color.green > 32767) ? 0 : 65535; color.blue = (color.blue > 32767) ? 0 : 65535; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); PictureAllocColor(dpy, Pcmap, &color, True); cs->fg = color.pixel; if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* contrast */ else if ((cs->color_flags & FG_SUPPLIED) && fg != NULL) { /* user specified colour */ Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetColor(fg); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* user specified */ else if (fg == NULL) { /* default */ Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetColor(black); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* save the fg color for tinting */ cs->fg_saved = cs->fg; } /* has_fg_changed */ /* * ---------- tint the foreground colour ---------- */ if (has_fg_tint_changed || (has_fg_changed && cs->fg_tint_percent > 0)) { if (cs->fg_tint_percent == 0) { Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = cs->fg_saved; if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } else { Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetTintedPixel( cs->fg_saved, cs->fg_tint, cs->fg_tint_percent); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } } /* * ---------- change the hilight colour ---------- */ if (has_hi_changed || (has_bg_changed && !(cs->color_flags & HI_SUPPLIED))) { has_hi_changed = 1; if ((cs->color_flags & HI_SUPPLIED) && hi != NULL) { /* user specified colour */ Pixel old_hilite = cs->hilite; PictureFreeColors(dpy, Pcmap, &cs->hilite, 1, 0, True); cs->hilite = GetColor(hi); if (old_hilite != cs->hilite) { have_pixels_changed = True; } } /* user specified */ else if (hi == NULL) { Pixel old_hilite = cs->hilite; PictureFreeColors(dpy, Pcmap, &cs->hilite, 1, 0, True); cs->hilite = GetHilite(cs->bg); if (old_hilite != cs->hilite) { have_pixels_changed = True; } } } /* has_hi_changed */ /* * ---------- change the shadow colour ---------- */ if (has_sh_changed || (has_bg_changed && !(cs->color_flags & SH_SUPPLIED))) { has_sh_changed = 1; if ((cs->color_flags & SH_SUPPLIED) && sh != NULL) { /* user specified colour */ Pixel old_shadow = cs->shadow; PictureFreeColors(dpy, Pcmap, &cs->shadow, 1, 0, True); cs->shadow = GetColor(sh); if (old_shadow != cs->shadow) { have_pixels_changed = True; } } /* user specified */ else if (sh == NULL) { Pixel old_shadow = cs->shadow; PictureFreeColors(dpy, Pcmap, &cs->shadow, 1, 0, True); cs->shadow = GetShadow(cs->bg); if (old_shadow != cs->shadow) { have_pixels_changed = True; } } } /* has_sh_changed */ /* * ---------- change the shadow foreground colour ---------- */ if (has_fgsh_changed || ((has_fg_changed || has_bg_changed) && !(cs->color_flags & FGSH_SUPPLIED))) { has_fgsh_changed = 1; if ((cs->color_flags & FGSH_SUPPLIED) && fgsh != NULL) { /* user specified colour */ Pixel old_fgsh = cs->fgsh; PictureFreeColors(dpy, Pcmap, &cs->fgsh, 1, 0, True); cs->fgsh = GetColor(fgsh); if (old_fgsh != cs->fgsh) { have_pixels_changed = True; } } /* user specified */ else if (fgsh == NULL) { Pixel old_fgsh = cs->fgsh; PictureFreeColors(dpy, Pcmap, &cs->fgsh, 1, 0, True); cs->fgsh = GetForeShadow(cs->fg, cs->bg); if (old_fgsh != cs->fgsh) { have_pixels_changed = True; } } } /* has_fgsh_changed */ /* * ------- the pixmap is a bitmap: create here cs->pixmap ------- */ if (cs->picture != None && pixmap_is_a_bitmap && (has_pixmap_changed || has_bg_changed)) { cs->pixmap = XCreatePixmap( dpy, win, cs->width, cs->height, Pdepth); XSetBackground(dpy, gc, cs->bg); XSetForeground(dpy, gc, cs->fg); reset_cs_pixmap(cs, gc); } /* * ------- change the masked out parts of the background pixmap ------- */ if (cs->pixmap != None && cs->pixmap != ParentRelative && (!CSETS_IS_TRANSPARENT_ROOT(cs)|| cs->allows_buffered_transparency) && (cs->mask != None || cs->alpha_pixmap != None || cs->image_alpha_percent < 100 || cs->tint_percent > 0) && (has_pixmap_changed || has_bg_changed || has_image_alpha_changed || has_tint_changed)) { /* Now that we know the background colour we can update the * pixmap background. */ FvwmRenderAttributes fra; Pixmap temp, mask, alpha; memset(&fra, 0, sizeof(fra)); temp = XCreatePixmap(dpy, win, cs->width, cs->height, Pdepth); if (cs->picture != NULL) { mask = cs->picture->mask; alpha = cs->picture->alpha; } else { mask = None; alpha = None; } XSetForeground(dpy, gc, cs->bg); XFillRectangle( dpy, temp, gc, 0, 0, cs->width, cs->height); fra.mask = FRAM_HAVE_ADDED_ALPHA | FRAM_HAVE_TINT; fra.added_alpha_percent = cs->image_alpha_percent; fra.tint = cs->tint; fra.tint_percent = cs->tint_percent; PGraphicsRenderPixmaps( dpy, win, cs->pixmap, mask, alpha, Pdepth, &fra, temp, gc, Scr.MonoGC, Scr.AlphaGC, 0, 0, cs->width, cs->height, 0, 0, cs->width, cs->height, False); if (cs->pixmap != root_pic.pixmap) { add_to_junk(cs->pixmap); } cs->pixmap = temp; has_pixmap_changed = True; if (CSETS_IS_TRANSPARENT_ROOT(cs)) { cs->pixmap_type = PIXMAP_ROOT_PIXMAP_TRAN; } } /* has_pixmap_changed */ /* * ---------- change the icon tint colour ---------- */ if (has_icon_tint_changed) { /* user specified colour */ if (icon_tint != NULL) { Pixel old_tint = cs->icon_tint; PictureFreeColors( dpy, Pcmap, &cs->icon_tint, 1, 0, True); cs->icon_tint = GetColor(icon_tint); if (old_tint != cs->icon_tint) { has_icon_pixels_changed = True; } } else { /* default */ Pixel old_tint = cs->icon_tint; PictureFreeColors( dpy, Pcmap, &cs->icon_tint, 1, 0, True); cs->icon_tint = GetColor(black); if (old_tint != cs->icon_tint) { has_icon_pixels_changed = True; } } } /* * ---------- send new colorset to fvwm and clean up ---------- */ /* make sure the server has this to avoid races */ XSync(dpy, False); /* inform modules of the change */ if (have_pixels_changed || has_pixmap_changed || has_shape_changed || has_fg_alpha_changed || has_icon_pixels_changed) { BroadcastColorset(n); } if (fg) { free(fg); } if (bg) { free(bg); } if (hi) { free(hi); } if (sh) { free(sh); } if (fgsh) { free(fgsh); } if (tint) { free(tint); } if (fg_tint) { free(fg_tint); } if (bg_tint) { free(bg_tint); } if (icon_tint) { free(icon_tint); } return; }
INT cmd_set (LPTSTR param) { LPTSTR p; LPTSTR lpEnv; LPTSTR lpOutput; if ( !_tcsncmp (param, _T("/?"), 2) ) { ConOutResPaging(TRUE,STRING_SET_HELP); return 0; } param = (LPTSTR)skip_ws(param); /* if no parameters, show the environment */ if (param[0] == _T('\0')) { lpEnv = (LPTSTR)GetEnvironmentStrings (); if (lpEnv) { lpOutput = lpEnv; while (*lpOutput) { if (*lpOutput != _T('=')) ConOutPuts(lpOutput); lpOutput += _tcslen(lpOutput) + 1; } FreeEnvironmentStrings (lpEnv); } return 0; } /* the /A does *NOT* have to be followed by a whitespace */ if ( !_tcsnicmp (param, _T("/A"), 2) ) { BOOL Success; StripQuotes(param); Success = seta_eval ( skip_ws(param+2) ); if(!Success) { /*might seem random but this is what windows xp does */ nErrorLevel = 9165; } return !Success; } if (!_tcsnicmp(param, _T("/P"), 2)) { TCHAR value[1023]; param = GetQuotedString((LPTSTR)skip_ws(param + 2)); p = _tcschr(param, _T('=')); if (!p) { ConErrResPuts(STRING_SYNTAX_COMMAND_INCORRECT); nErrorLevel = 1; return 1; } *p++ = _T('\0'); ConOutPrintf(_T("%s"), GetQuotedString(p)); ConInString(value, 1023); if (!*value || !SetEnvironmentVariable(param, value)) { nErrorLevel = 1; return 1; } return 0; } param = GetQuotedString(param); p = _tcschr (param, _T('=')); if (p) { /* set or remove environment variable */ if (p == param) { /* handle set =val case */ ConErrResPuts(STRING_SYNTAX_COMMAND_INCORRECT); nErrorLevel = 1; return 1; } *p++ = _T('\0'); if (!SetEnvironmentVariable(param, *p ? p : NULL)) { nErrorLevel = 1; return 1; } } else { /* display all environment variable with the given prefix */ BOOL bFound = FALSE; while (_istspace(*param) || *param == _T(',') || *param == _T(';')) param++; p = _tcsrchr(param, _T(' ')); if (!p) p = param + _tcslen(param); *p = _T('\0'); lpEnv = GetEnvironmentStrings(); if (lpEnv) { lpOutput = lpEnv; while (*lpOutput) { if (!_tcsnicmp(lpOutput, param, p - param)) { ConOutPuts(lpOutput); bFound = TRUE; } lpOutput += _tcslen(lpOutput) + 1; } FreeEnvironmentStrings(lpEnv); } if (!bFound) { ConErrResPrintf (STRING_PATH_ERROR, param); nErrorLevel = 1; return 1; } } return 0; }
/*#define DEBUG_PARSER*/ static void ParseButton(button_info **uberb, char *s) { button_info *b, *ub = *uberb; int i, j; char *t, *o; b = alloc_button(ub, (ub->c->num_buttons)++); s = trimleft(s); if (*s == '(' && s++) { char *opts[] = { "back", "fore", "font", "title", "icon", "frame", "padding", "swallow", "panel", "actionignoresclientwindow", "actiononpress", "container", "end", "nosize", "size", "left", "right", "center", "colorset", "action", "id", "activeicon", "activetitle", "pressicon", "presstitle", "activecolorset", "presscolorset", "top", NULL }; s = trimleft(s); while (*s && *s != ')') { Bool is_swallow = False; if (*s == ',') { s++; s = trimleft(s); continue; } if (isdigit(*s) || *s == '+' || *s == '-') { char *geom; int x, y, flags; unsigned int w, h; geom = seekright(&s); if (geom) { flags = XParseGeometry(geom, &x, &y, &w, &h); if (flags&WidthValue) { b->BWidth = w; } if (flags&HeightValue) { b->BHeight = h; } if (flags & XValue) { b->BPosX = x; b->flags.b_PosFixed = 1; } if (flags & YValue) { b->BPosY = y; b->flags.b_PosFixed = 1; } if (flags & XNegative) { b->BPosX = -1 - x; } if (flags & YNegative) { b->BPosY = -1 - y; } free(geom); } s = trimleft(s); continue; } switch (GetTokenIndex(s, opts, -1, &s)) { case 0: /* Back */ s = trimleft(s); if (*s == '(' && s++ && ParseBack(&s)) { b->flags.b_IconBack = 1; } if (b->flags.b_Back && b->back) { free(b->back); } b->back = seekright(&s); if (b->back) { b->flags.b_Back = 1; } else { b->flags.b_IconBack = 0; b->flags.b_Back = 0; } break; case 1: /* Fore */ if (b->flags.b_Fore && b->fore) { free(b->fore); } b->fore = seekright(&s); b->flags.b_Fore = (b->fore ? 1 : 0); break; case 2: /* Font */ if (b->flags.b_Font && b->font_string) { free(b->font_string); } b->font_string = my_get_font(&s); b->flags.b_Font = (b->font_string ? 1 : 0); break; /* ----------------- title --------------- */ case 3: /* Title */ s = trimleft(s); if (*s == '(' && s++) { b->justify = 0; b->justify_mask = 0; ParseTitle( &s, &b->justify, &b->justify_mask); if (b->justify_mask) { b->flags.b_Justify = 1; } } t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->title) { free(b->title); } b->title = t; #ifdef DEBUG_PARSER fprintf(stderr, "PARSE: Title \"%s\"\n", b->title); #endif b->flags.b_Title = 1; } else { fprintf(stderr, "%s: Missing title argument\n", MyName); if (t) { free(t); } } break; /* ------------------ icon --------------- */ case 4: /* Icon */ t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->flags.b_Swallow) { fprintf(stderr, "%s: a button can not " "have an icon and a " "swallowed window at " "the same time. " "Ignoring icon\n", MyName); } else { if (b->icon_file) { free(b->icon_file); } b->icon_file = t; b->flags.b_Icon = 1; } } else { fprintf(stderr, "%s: Missing Icon argument\n", MyName); if (t) { free(t); } } break; /* ----------------- frame --------------- */ case 5: /* Frame */ i = strtol(s, &t, 10); if (t > s) { b->flags.b_Frame = 1; b->framew = i; s = t; } else { fprintf(stderr, "%s: Illegal frame argument\n", MyName); } break; /* ---------------- padding -------------- */ case 6: /* Padding */ i = strtol(s,&t,10); if (t>s) { b->xpad = b->ypad = i; b->flags.b_Padding = 1; s = t; i = strtol(s, &t, 10); if (t > s) { b->ypad = i; s = t; } } else { fprintf(stderr, "%s: Illegal padding " "argument\n", MyName); } break; /* ---------------- swallow -------------- */ case 7: /* Swallow */ is_swallow = True; /* fall through */ case 8: /* Panel */ s = trimleft(s); if (is_swallow) { b->swallow = 0; b->swallow_mask = 0; } else { /* set defaults */ b->swallow = b_Respawn; b->swallow_mask = b_Respawn; b->slide_direction = SLIDE_UP; b->slide_position = SLIDE_POSITION_CENTER; b->slide_context = SLIDE_CONTEXT_PB; b->relative_x = 0; b->relative_y = 0; b->slide_steps = 12; b->slide_delay_ms = 5; } if (*s == '(' && s++) { if (is_swallow) { ParseSwallow( &s, &b->swallow, &b->swallow_mask, b); } else { ParsePanel( &s, &b->swallow, &b->swallow_mask, &b->slide_direction, &b->slide_steps, &b->slide_delay_ms, &b->panel_flags, &b->indicator_size, &b->relative_x, &b->relative_y, &b->slide_position, &b->slide_context); } } t = seekright(&s); o = seekright(&s); if (t) { if (b->hangon) { free(b->hangon); } b->hangon = t; if (is_swallow) { if (b->flags.b_Icon) { fprintf(stderr, "%s: a button can not " "have an icon and a " "swallowed window at " "the same time. " "Ignoring icon\n", MyName); b->flags.b_Icon = 0; } b->flags.b_Swallow = 1; b->flags.b_Hangon = 1; } else { b->flags.b_Panel = 1; b->flags.b_Hangon = 1; b->newflags.is_panel = 1; b->newflags.panel_mapped = 0; } b->swallow |= 1; if (!(b->swallow & b_NoHints)) { b->hints = (XSizeHints*) mymalloc(sizeof(XSizeHints)); } if (o) { char *p; p = module_expand_action( Dpy, screen, o, NULL, UberButton->c->fore, UberButton->c->back); if (p) { if (!(buttonSwallow(b)&b_UseOld)) { exec_swallow(p,b); } if (b->spawn) { free(b->spawn); } /* Might be needed if * respawning sometime */ b->spawn = o; free(p); } } } else { fprintf(stderr, "%s: Missing swallow " "argument\n", MyName); if (t) { free(t); } if (o) { free(o); } } /* check if it is a module by command line inspection if * this hints has not been given in the swallow option */ if (is_swallow && !(b->swallow_mask & b_FvwmModule)) { if (b->spawn != NULL && (strncasecmp(b->spawn, "module", 6) == 0 || strncasecmp(b->spawn, "fvwm", 4) == 0)) { b->swallow |= b_FvwmModule; } } break; case 9: /* ActionIgnoresClientWindow */ b->flags.b_ActionIgnoresClientWindow = 1; break; case 10: /* ActionOnPress */ b->flags.b_ActionOnPress = 1; break; /* ---------------- container ------------ */ case 11: /* Container */ /* * SS: This looks very buggy! The FvwmButtons * man page suggests it's here to restrict the * options used with "Container", but it only * restricts those options appearing _before_ * the "Container" keyword for a button. * b->flags&=b_Frame|b_Back|b_Fore|b_Padding|b_Action; */ MakeContainer(b); *uberb = b; s = trimleft(s); if (*s == '(' && s++) { ParseContainer(&s,b); } break; case 12: /* End */ *uberb = ub->parent; ub->c->buttons[--(ub->c->num_buttons)] = NULL; free(b); if (!ub->parent) { fprintf(stderr,"%s: Unmatched END in config file\n",MyName); exit(1); } if (ub->parent->c->flags.b_Colorset || ub->parent->c->flags.b_ColorsetParent) { ub->c->flags.b_ColorsetParent = 1; } if (ub->parent->c->flags.b_IconBack || ub->parent->c->flags.b_IconParent) { ub->c->flags.b_IconParent = 1; } return; case 13: /* NoSize */ b->flags.b_Size = 1; b->minx = b->miny = 0; break; case 14: /* Size */ i = strtol(s, &t, 10); j = strtol(t, &o, 10); if (t > s && o > t) { b->minx = i; b->miny = j; b->flags.b_Size = 1; s = o; } else { fprintf(stderr, "%s: Illegal size arguments\n", MyName); } break; case 15: /* Left */ b->flags.b_Left = 1; b->flags.b_Right = 0; break; case 16: /* Right */ b->flags.b_Right = 1; b->flags.b_Left = 0; break; case 17: /* Center */ b->flags.b_Right = 0; b->flags.b_Left = 0; break; case 18: /* Colorset */ i = strtol(s, &t, 10); if (t > s) { b->colorset = i; b->flags.b_Colorset = 1; s = t; AllocColorset(i); } else { b->flags.b_Colorset = 0; } break; /* ----------------- action -------------- */ case 19: /* Action */ s = trimleft(s); i = 0; if (*s == '(') { s++; if (strncasecmp(s, "mouse", 5) != 0) { fprintf(stderr, "%s: Couldn't parse " "action\n", MyName); } s += 5; i = strtol(s, &t, 10); s = t; while (*s && *s != ')') { s++; } if (*s == ')') { s++; } } { char *r; char *u = s; s = GetQuotedString(s, &t, ",)", NULL, "(", ")"); r = s; if (t && r > u + 1) { /* remove unquoted trailing spaces */ r -= 2; while (r >= u && isspace(*r)) { r--; } r++; if (isspace(*r)) { t[strlen(t) - (s - r - 1)] = 0; } } } if (t) { AddButtonAction(b,i,t); free(t); } else { fprintf(stderr, "%s: Missing action argument\n", MyName); } break; case 20: /* Id */ s = trimleft(s); s = DoGetNextToken(s, &t, NULL, ",)", &terminator); /* it should include the delimiter */ if (s && terminator == ')') { s--; } if (t) { if (isalpha(t[0])) { /* should check for duplicate ids first... */ b->flags.b_Id = 1; if (b->id) { free(b->id); } CopyString(&b->id, t); } else { fprintf(stderr, "%s: Incorrect id '%s' " "ignored\n", MyName, t); } free(t); } else { fprintf(stderr, "%s: Missing id argument\n", MyName); } break; /* ------------------ ActiveIcon --------------- */ case 21: /* ActiveIcon */ t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->flags.b_Swallow) { fprintf(stderr, "%s: a button can not " "have a ActiveIcon and " "a swallowed window at " "the same time. " "Ignoring ActiveIcon.\n", MyName); } else { if (b->active_icon_file) { free(b->active_icon_file); } b->active_icon_file = t; b->flags.b_ActiveIcon = 1; } } else { fprintf(stderr, "%s: Missing ActiveIcon " "argument\n", MyName); if (t) { free(t); } } break; /* --------------- ActiveTitle --------------- */ case 22: /* ActiveTitle */ s = trimleft(s); if (*s == '(') { fprintf(stderr, "%s: justification not allowed " "for ActiveTitle.\n", MyName); } t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->activeTitle) { free(b->activeTitle); } b->activeTitle = t; #ifdef DEBUG_PARSER fprintf(stderr, "PARSE: ActiveTitle \"%s\"\n", b->activeTitle); #endif b->flags.b_ActiveTitle = 1; } else { fprintf(stderr, "%s: Missing ActiveTitle " "argument\n", MyName); if (t) { free(t); } } break; /* --------------- PressIcon --------------- */ case 23: /* PressIcon */ t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->flags.b_Swallow) { fprintf(stderr, "%s: a button can not " "have a PressIcon and " "a swallowed window at " "the same time. " "Ignoring PressIcon.\n", MyName); } else { if (b->press_icon_file) { free(b->press_icon_file); } b->press_icon_file = t; b->flags.b_PressIcon = 1; } } else { fprintf(stderr, "%s: Missing PressIcon " "argument\n", MyName); if (t) { free(t); } } break; /* --------------- PressTitle --------------- */ case 24: /* PressTitle */ s = trimleft(s); if (*s == '(') { fprintf(stderr, "%s: justification not allowed " "for PressTitle.\n", MyName); } t = seekright(&s); if (t && *t && (t[0] != '-' || t[1] != 0)) { if (b->pressTitle) { free(b->pressTitle); } b->pressTitle = t; #ifdef DEBUG_PARSER fprintf(stderr, "PARSE: PressTitle \"%s\"\n", b->pressTitle); #endif b->flags.b_PressTitle = 1; } else { fprintf(stderr, "%s: Missing PressTitle " "argument\n", MyName); if (t) { free(t); } } break; /* --------------- --------------- */ case 25: /* ActiveColorset */ i = strtol(s, &t, 10); if (t > s) { b->activeColorset = i; b->flags.b_ActiveColorset = 1; s = t; AllocColorset(i); } else { b->flags.b_ActiveColorset = 0; } break; /* --------------- --------------- */ case 26: /* PressColorset */ i = strtol(s, &t, 10); if (t > s) { b->pressColorset = i; b->flags.b_PressColorset = 1; s = t; AllocColorset(i); } else { b->flags.b_PressColorset = 0; } break; case 27: /* top */ b->flags.b_Top = 1; break; /* --------------- --------------- */ default: t = seekright(&s); fprintf(stderr, "%s: Illegal button option \"%s\"\n", MyName, (t) ? t : ""); if (t) { free(t); } break; } /* end switch */ s = trimleft(s); } if (s && *s) { s++; s = trimleft(s); } } /* get title and iconname */ if (!b->flags.b_Title) { b->title = seekright(&s); if (b->title && *b->title && ((b->title)[0] != '-' || (b->title)[1] != 0)) { b->flags.b_Title = 1; } else if (b->title) { free(b->title); } } else { char *temp; temp = seekright(&s); if (temp) { free(temp); } } if (!b->flags.b_Icon) { b->icon_file = seekright(&s); if (b->icon_file && b->icon_file && ((b->icon_file)[0] != '-'||(b->icon_file)[1] != 0)) { b->flags.b_Icon = 1; } else if (b->icon_file) { free(b->icon_file); } } else { char *temp; temp = seekright(&s); if (temp) { free(temp); } } s = trimleft(s); /* Swallow hangon command */ if (strncasecmp(s, "swallow", 7) == 0 || strncasecmp(s, "panel", 7) == 0) { if (b->flags.b_Swallow || b->flags.b_Panel) { fprintf(stderr, "%s: Illegal with both old and new swallow!\n", MyName); exit(1); } s += 7; /* * Swallow old 'swallowmodule' command */ if (strncasecmp(s, "module", 6) == 0) { s += 6; } if (b->hangon) { free(b->hangon); } b->hangon = seekright(&s); if (!b->hangon) { b->hangon = safestrdup(""); } if (tolower(*s) == 's') { b->flags.b_Swallow = 1; b->flags.b_Hangon = 1; } else { b->flags.b_Panel = 1; b->flags.b_Hangon = 1; } b->swallow |= 1; s = trimleft(s); if (!(b->swallow & b_NoHints)) { b->hints = (XSizeHints*)mymalloc(sizeof(XSizeHints)); } if (*s) { if (!(buttonSwallow(b) & b_UseOld)) { SendText(fd, s, 0); } b->spawn = safestrdup(s); } } else if (*s) { AddButtonAction(b, 0, s); } return; }
void parse_message_line(char *line) { char *rest; int action = -1; button_info *b; char *act; char *buttonn; int mousebutton; silent = False; do { action = GetTokenIndex(line, actions, -1, &rest); if (action == -1) { show_error("Message not understood: %s", line); return; } if (action == 0) { silent = True; break; } } while (action == 0); /* If silent was given (to surpress erros from parsing commands, then * retokenise the rest of the line, so that token matching for the * actual command is possible. */ if (silent == True) { line = PeekToken(line, &rest); action = GetTokenIndex(rest, actions, -1, &rest); } /* find out which button */ b = parse_button_id(&rest); if (!b || !rest) { return; } switch (action) { case 1: /* ChangeButton */ /* The dimensions of individual buttons (& the overall size of * the FvwmButtons window) is based on the initial * configuration for the module. In some configurations, * dynamically adding/changing a title/icon may mean it no * longer fits on a button. Currently, there are no checks for * this occurance. */ while (rest && rest[0] != '\0') { char *option_pair; int option, i; char *value0, *value; FvwmPicture *icon; /* parse option and value and give diagnostics */ rest = GetQuotedString( rest, &option_pair, ",", NULL, NULL, NULL); while (isspace(*rest)) { rest++; } if (!option_pair) continue; option = GetTokenIndex( option_pair, button_options, -1, &value0); if (option < 0) { show_error( "Unsupported button option line '%s'\n", option_pair); free(option_pair); continue; } GetNextToken(value0, &value); free(option_pair); if (value == NULL) { show_error( "No title/icon to change specified.\n"); continue; } switch (option) { case 0: /* Title */ if (b->flags.b_Title) free(b->title); b->flags.b_Title = 1; b->title = value; value = NULL; break; case 2: /* ActiveTitle */ if (b->flags.b_ActiveTitle) free(b->activeTitle); b->flags.b_ActiveTitle = 1; b->title = value; value = NULL; break; case 4: /* PressTitle */ if (b->flags.b_PressTitle) free(b->pressTitle); b->flags.b_PressTitle = 1; b->title = value; value = NULL; break; case 6: /* Colorset */ i = atoi(value); b->colorset = i; b->flags.b_Colorset = 1; AllocColorset(i); break; default: if ( LoadIconFile( value, &icon, b->colorset) == 0) { show_error( "Cannot load icon \"%s\"\n", value); } else { switch (option) { case 1: /* Icon */ if (b->flags.b_Icon) { free(b->icon_file); PDestroyFvwmPicture( Dpy, b->icon); } b->flags.b_Icon = 1; b->icon_file = value; value = NULL; b->icon = icon; break; case 3: /* ActiveIcon */ if (b->flags.b_ActiveIcon) { free(b->active_icon_file); PDestroyFvwmPicture( Dpy, b->activeicon); } b->flags.b_ActiveIcon = 1; b->active_icon_file = value; value = NULL; b->activeicon = icon; break; case 5: /* PressIcon */ if (b->flags.b_PressIcon) { free(b->press_icon_file); PDestroyFvwmPicture( Dpy, b->pressicon); } b->flags.b_PressIcon = 1; b->press_icon_file = value; value = NULL; b->pressicon = icon; break; } } break; } if (value) { free(value); } } RedrawButton(b, DRAW_FORCE, NULL); if (UberButton->c->flags.b_TransBack) { SetTransparentBackground(UberButton, Width, Height); } break; case 2: /* ExpandButtonVars */ line = expand_button_vars(b, rest); if (line) { SendText(fd, line, 0); free(line); } break; case 3: /* PressButton */ rest = GetQuotedString(rest, &buttonn, "", NULL, NULL, NULL); if (buttonn) { mousebutton = atoi(buttonn); free(buttonn); if ( mousebutton <= 0 || mousebutton > NUMBER_OF_EXTENDED_MOUSE_BUTTONS) { mousebutton = 1; } } else { mousebutton = 1; } CurrentButton = b; act = GetButtonAction(b, mousebutton); ButtonPressProcess(b, &act); if (act) { free(act); } CurrentButton = NULL; break; } return; }
void FGettextSetLocalePath(const char *path) { char *exp_path = NULL; char *before = NULL; char *after, *p, *str; int count; if (!HaveNLSSupport || !FGettextInitOk) { return; } FGLastPath = NULL; if (path == NULL || path[0] == '\0') { fgettext_free_fgpath_list(); FGLastPath = (FGettextPath *)safemalloc(sizeof(FGettextPath)); CopyString(&FGLastPath->domain, FGDefaultDomain); CopyString(&FGLastPath->dir, FGDefaultDir); FGPathList = flist_append_obj(FGPathList, FGLastPath); FGLastPath = NULL; return; } exp_path = envDupExpand(path, 0); if (StrEquals(exp_path,"None")) { fgettext_free_fgpath_list(); goto bail; } after = GetQuotedString(exp_path, &before, "+", NULL, NULL, NULL); if ((after && strchr(after, '+')) || (before && strchr(before, '+'))) { fprintf( stderr,"[%s][SetLocalePath]: " "To many '+' in locale path specification: %s\n", FGModuleName, path); goto bail; } if (!strchr(exp_path, '+')) { fgettext_free_fgpath_list(); } while(after && *after) { after = GetQuotedString(after, &p, ":", NULL, NULL, NULL); if (p && *p) { fgettext_add_one_path(p,-1); } if (p) { free(p); } } count = 0; str = before; while (str && *str) { str = GetQuotedString(str, &p, ":", NULL, NULL, NULL); if (p && *p) { fgettext_add_one_path(p,count); count++; } if (p) { free(p); } } bail: if (before) { free(before); } if (exp_path) { free(exp_path); } }
void ParseMultipartFormData( webserver::http_request& req, Socket* s) { static const std::string multipart_form_data = "multipart/form-data"; if(req.content_type_.substr(0, multipart_form_data.size()) == multipart_form_data) // Difficult data... :( { AStringVector ContentTypeData = StringSplit( req.content_type_, "; " ); std::string boundary; // Find boundary for( unsigned int i = 0; i < ContentTypeData.size(); ++i ) { static const std::string boundary_ = "boundary="; if( ContentTypeData[i].substr(0, boundary_.size()) == boundary_ ) // Found boundary { boundary = ContentTypeData[i].substr( boundary_.size() ); } } //LOGINFO("Boundary: %s", boundary.c_str() ); std::string boundary_start = "--" + boundary; std::string boundary_end = boundary_start + "--"; std::string Content = s->ReceiveBytes( req.content_length_ ); //printf("Total content: \n%s\n", Content.c_str() ); // Should start with boundary! std::string line = EatLine( Content ); if( line.substr(0, boundary_start.size() ) != boundary_start ) { // Something was wrong! :( Content.clear(); } while( !Content.empty() ) { webserver::formdata FormData; static const std::string content_disposition = "Content-Disposition: "; static const std::string content_type = "Content-Type: "; std::string f_disposition; while( 1 ) { std::string line = EatLine( Content ); if( line.empty() ) break; unsigned int pos_cr_lf = line.find_first_of("\x0a\x0d"); if (pos_cr_lf == 0) break; // Empty line, indicates end of mime thingy if( line.substr(0, content_disposition.size() ) == content_disposition ) { f_disposition = line.substr(content_disposition.size()); LOGINFO("Disposition: %s", f_disposition.c_str() ); } else if( line.substr(0, content_type.size() ) == content_type ) { FormData.content_type_ = line.substr(content_type.size()); } //LOGINFO("Got line: '%s'", line.c_str() ); } // Check if we got the proper headers if( !f_disposition.empty() ) { static const std::string disp_name = "name="; static const std::string disp_filename = "filename="; // Parse the disposition AStringVector DispositionData = StringSplit( f_disposition, "; " ); for( unsigned int i = 0; i < DispositionData.size(); ++i ) { if( DispositionData[i].substr(0, disp_name.size()) == disp_name ) { FormData.name_ = GetQuotedString( DispositionData[i].substr(disp_name.size()) ); } else if( DispositionData[i].substr(0, disp_filename.size()) == disp_filename ) { FormData.filename_ = GetQuotedString( DispositionData[i].substr(disp_filename.size()) ); } } std::string ContentValue; // Parse until boundary_end is found while( 1 ) { std::string line = EatLine( Content ); if( line.empty() ) break; if( line.substr(0, boundary_end.size() ) == boundary_end ) { break; } else if( line.substr(0, boundary_start.size() ) == boundary_start ) { break; } ContentValue.append( line.c_str(), line.size() ); } FormData.value_ = ContentValue; } req.multipart_formdata_.push_back( FormData ); } } }
void FlocaleCharsetSetFlocaleCharset( Display *dpy, FlocaleFont *flf, char *hints, char *encoding, char *module) { char *charset = NULL; char *iconv = NULL; Bool iconv_found = False; int i = 0; FlocaleCharsetInit(dpy, module); if (hints && *hints) { iconv = GetQuotedString( hints, &charset, "/", NULL, NULL, NULL); if (charset && *charset && *charset != '*' ) { flf->fc = FlocaleCharsetOfXCharset(charset); } if (flf->fc == NULL && charset && *charset && *charset != '*') { flf->fc = FlocaleCharsetOfLocaleCharset(charset); } if (flf->fc == NULL && iconv && *iconv) { flf->fc = FlocaleCharsetOfLocaleCharset(iconv); } } if (flf->fc == NULL) { if (FftSupport && flf->fftf.fftfont != NULL) { flf->fc = FlocaleCharsetOfXCharset(flf->fftf.encoding); } else if (flf->fontset != None) { if (FLCXOMCharset != NULL) { flf->fc = FLCXOMCharset; } else { /* we are here if !HAVE_XOUTPUT_METHOD */ XFontStruct **fs_list; char **ml; if (XFontsOfFontSet( flf->fontset, &fs_list, &ml) > 0) { flf->fc = FLCXOMCharset = FlocaleCharsetOfFontStruct( dpy, fs_list[0]); } } } else if (flf->font != NULL) { flf->fc = FlocaleCharsetOfFontStruct(dpy, flf->font); } } if (flf->fc != NULL && iconv && *iconv) { /* the user has specified an iconv converter name: * check if we have it and force user choice */ while(!iconv_found && FLC_GET_LOCALE_CHARSET(flf->fc,i) != NULL) { if ( strcmp( iconv, FLC_GET_LOCALE_CHARSET(flf->fc,i)) == 0) { iconv_found = True; /* Trust the user? yes ... */ FLC_SET_ICONV_INDEX(flf->fc,i); } i++; } } if (iconv && *iconv && !iconv_found) { FlocaleCharset *fc; /* the user has specified an iconv converter name and we do not * have it: must create a FlocaleCharset */ flf->flags.must_free_fc = True; fc = (FlocaleCharset *)safemalloc(sizeof(FlocaleCharset)); if (flf->fc != NULL) { CopyString(&fc->x, flf->fc->x); fc->encoding_type = flf->fc->encoding_type; if (flf->fc->bidi) CopyString(&fc->bidi, flf->fc->bidi); else fc->bidi = NULL; } else { CopyString(&fc->x, "Unknown"); /* for simplicity */ fc->bidi = NULL; fc->encoding_type = FLC_ENCODING_TYPE_FONT; } fc->locale = (char **)safemalloc(2*sizeof(char *)); CopyString(&fc->locale[0], iconv); fc->locale[1] = NULL; fc->iconv_index = FLC_INDEX_ICONV_CHARSET_NOT_INITIALIZED; flf->fc = fc; } if (charset != NULL) { free(charset); } if (flf->fc == NULL) { flf->fc = &UnknownCharset; } /* now the string charset */ if (encoding != NULL) { flf->str_fc = FlocaleCharsetOfXCharset(encoding); if (flf->str_fc == NULL) { flf->str_fc = FlocaleCharsetOfLocaleCharset(encoding); } if (flf->str_fc == NULL) { flf->str_fc = &UnknownCharset; } } else if (FftSupport && flf->fftf.fftfont != NULL) { if (flf->fftf.str_encoding != NULL) { flf->str_fc = FlocaleCharsetOfXCharset( flf->fftf.str_encoding); if (flf->str_fc == NULL) { flf->str_fc = FlocaleCharsetOfLocaleCharset( flf->fftf.str_encoding); } if (flf->str_fc == NULL) { flf->str_fc = &UnknownCharset; } } else { flf->str_fc = FlocaleCharsetGetDefaultCharset(dpy, module); } } if (flf->str_fc == NULL) { if (flf->fc != &UnknownCharset) { flf->str_fc = flf->fc; } else { flf->str_fc = FlocaleCharsetGetDefaultCharset(dpy, module); } } }
// Parse element node // Returns true if parsing level complete bool XMLParser::ParseElement() { CString elementName; CString attributeName; WhiteSpace elemspace = m_whiteSpace; // Skip leading '<' m_pointer++; if(GetIdentifier(elementName)) { // Creating an identifier CString namesp = SplitNamespace(elementName); MakeElement(namesp,elementName); if(isspace(*m_pointer)) { SkipWhiteSpace(); // See if we must get attributes while(GetIdentifier(attributeName)) { SkipWhiteSpace(); NeedToken('='); CString value = GetQuotedString(); SkipWhiteSpace(); // Adding an attribute m_message->SetAttribute(m_lastElement,attributeName,value); // In special case "[xml:]space", we must change whitespace preserving if(attributeName.Compare("space") == 0) { elemspace = value.Compare("preserve") == 0 ? WhiteSpace::PRESERVE_WHITESPACE : WhiteSpace::COLLAPSE_WHITESPACE; } } } if(*m_pointer && strncmp((const char*)m_pointer,"/>",2) == 0) { m_pointer += 2; return false; } if(*m_pointer == '>') { // Closing of the element m_pointer++; SkipOuterWhiteSpace(); if(*m_pointer && *m_pointer == '<') { // Push element and space-preserving and parse next level XMLElement* level = m_element; WhiteSpace space = m_whiteSpace; m_whiteSpace = elemspace; m_element = m_lastElement; ParseLevel(); m_element = level; m_whiteSpace = space; } else { ParseText(); } } // Need to see ending of the element CString closing; NeedToken('<'); NeedToken('/'); if(GetIdentifier(closing)) { CString closingNS = SplitNamespace(closing); if(elementName.Compare(closing) == 0) { if(namesp.Compare(closingNS)) { CString error; error.Format("Element [%s] has closing tag with different namespace.",elementName.GetString()); SetError(XmlError::XE_MissingEndTag,(uchar*)error.GetString()); } NeedToken('>'); SkipOuterWhiteSpace(); // Parsing level complete return strncmp((const char*)m_pointer,"</",2) == 0; } CString error; error.Format("Element [%s] has incorrect closing tag [%s]",elementName.GetString(),closing.GetString()); SetError(XmlError::XE_MissingEndTag,(uchar*)error.GetString()); } else { CString error; error.Format("Missing end tag for element: %s",elementName.GetString()); SetError(XmlError::XE_MissingEndTag,(uchar*)error.GetString()); } } // End of a list of elements if(*m_pointer == '/') { m_pointer--; return true; } CString error; error.Format("Missing ending of XML element: %s",elementName.GetString()); SetError(XmlError::XE_MissingElement,(uchar*)error.GetString()); return false; }
// Parse the declaration of form: // <?xml version="1.0" encoding="utf-8" space="preserve" standalone="yes"?> void XMLParser::ParseDeclaration() { CString attributeName; // Initially set to empty. // The 'encoding' could have been set by the // HTTP content type 'charset' attribute, so we leave it for now. m_message->m_version.Empty(); m_message->m_standalone.Empty(); // Skip over "<?xml" m_pointer += 5; SkipWhiteSpace(); while(GetIdentifier(attributeName)) { SkipWhiteSpace(); NeedToken('='); CString value = GetQuotedString(); SkipWhiteSpace(); // Remove possibly "xml" namespace CString namesp = SplitNamespace(attributeName); if(attributeName.Compare("version") == 0) { if(value.Compare("1.0") == 0) { m_message->m_version = value; } } else if(attributeName.Compare("encoding") == 0) { m_message->m_encoding = XMLEncoding::ENC_Plain; if(value.CompareNoCase("utf-8") == 0) { m_utf8 = true; m_message->m_encoding = XMLEncoding::ENC_UTF8; } else if(value.Left(6).CompareNoCase("utf-16") == 0) { // Works for "UTF-16", "UTF-16LE" and "UTF-16BE" as of RFC 2781 // Although one should only specify "utf-16" without the endianess m_message->m_encoding = XMLEncoding::ENC_UTF16; } else if(value.CompareNoCase("iso-8859-1") == 0) { m_message->m_encoding = XMLEncoding::ENC_ISO88591; } else { // If it was send in the current codepage, use that if(GetACP() == (UINT) CharsetToCodepage(value)) { m_message->m_encoding = XMLEncoding::ENC_Plain; } else { CString message; message.Format("Unknown XML character encoding: %s",value.GetString()); SetError(XmlError::XE_UnknownEncoding,(uchar*)message.GetString()); } } } else if(attributeName.Compare("standalone") == 0) { if(value.CompareNoCase("yes") == 0 || value.CompareNoCase("no") == 0) { m_message->m_standalone = value; } } else { CString message; message.Format("Unknown header attributes [%s=%s]",attributeName.GetString(),value.GetString()); SetError(XmlError::XE_HeaderAttribs,(uchar*)message.GetString()); } if(!namesp.IsEmpty() && namesp.Compare("xml")) { CString message; message.Format("Unknown root namespace [%s] for attribute [%s]",namesp.GetString(),attributeName.GetString()); SetError(XmlError::XE_HeaderAttribs,(uchar*)message.GetString()); } } // Skip over end of declaration NeedToken('?'); NeedToken('>'); SkipWhiteSpace(); }
/*#define DEBUG_PARSER*/ static void ParseButton(button_info **uberb,char *s) { button_info *b,*ub=*uberb; int i,j; char *t,*o; b = alloc_button(ub, (ub->c->num_buttons)++); s = trimleft(s); if(*s=='(' && s++) { char *opts[] = { "back", "fore", "font", "title", "icon", "frame", "padding", "swallow", "panel", "action", "container", "end", "nosize", "size", "left", "right", "center", "colorset", NULL }; s = trimleft(s); while(*s && *s!=')') { Bool is_swallow = False; if (*s == ',') { s++; s = trimleft(s); continue; } if((*s>='0' && *s<='9') || *s=='+' || *s=='-') { char *geom; int x,y,flags; unsigned int w,h; geom=seekright(&s); if (geom) { flags=XParseGeometry(geom, &x, &y, &w, &h); if(flags&WidthValue) b->BWidth=w; if(flags&HeightValue) b->BHeight=h; if(flags&XValue) { b->BPosX=x; b->flags|=b_PosFixed; } if(flags&YValue) { b->BPosY=y; b->flags|=b_PosFixed; } if(flags&XNegative) b->BPosX=-1-x; if(flags&YNegative) b->BPosY=-1-y; free(geom); } s = trimleft(s); continue; } switch(GetTokenIndex(s,opts,-1,&s)) { case 0: /* Back */ s = trimleft(s); if(*s=='(' && s++) if(ParseBack(&s)) b->flags|=b_IconBack; if(b->flags&b_Back && b->back) free(b->back); b->back=seekright(&s); if(b->back) { b->flags|=b_Back; } else b->flags&=~(b_IconBack|b_Back); break; case 1: /* Fore */ if(b->flags&b_Fore && b->fore) free(b->fore); b->fore=seekright(&s); if(b->fore) { b->flags|=b_Fore; } else b->flags&=~b_Fore; break; case 2: /* Font */ if(b->flags&b_Font && b->font_string) free(b->font_string); b->font_string = my_get_font(&s); if(b->font_string) { b->flags|=b_Font; } else b->flags&=~b_Font; break; /* --------------------------- Title ------------------------- */ case 3: /* Title */ s = trimleft(s); if(*s=='(' && s++) { b->justify=0; b->justify_mask=0; ParseTitle(&s,&b->justify,&b->justify_mask); if(b->justify_mask) b->flags|=b_Justify; } t=seekright(&s); if(t && *t && (t[0]!='-' || t[1]!=0)) { if (b->title) free(b->title); b->title=t; #ifdef DEBUG_PARSER fprintf(stderr,"PARSE: Title \"%s\"\n",b->title); #endif b->flags|=b_Title; } else { fprintf(stderr,"%s: Missing title argument\n",MyName); if(t)free(t); } break; /* ---------------------------- icon ------------------------- */ case 4: /* Icon */ t=seekright(&s); if(t && *t && (t[0] != '-' || t[1] != 0)) { if (b->flags & b_Swallow) { fprintf( stderr,"%s: a button can not have an icon and a swallowed window" " at the same time. Ignoring icon", MyName); } else { if (b->icon_file) free(b->icon_file); b->icon_file=t; b->IconWin=None; b->flags|=b_Icon; } } else { fprintf(stderr,"%s: Missing icon argument\n",MyName); if(t)free(t); } break; /* --------------------------- frame ------------------------- */ case 5: /* Frame */ i=strtol(s,&t,10); if(t>s) { b->flags|=b_Frame; b->framew=i; s=t; } else fprintf(stderr,"%s: Illegal frame argument\n",MyName); break; /* -------------------------- padding ------------------------ */ case 6: /* Padding */ i=strtol(s,&t,10); if(t>s) { b->xpad=b->ypad=i; b->flags |= b_Padding; s=t; i=strtol(s,&t,10); if(t>s) { b->ypad=i; s=t; } } else fprintf(stderr,"%s: Illegal padding argument\n",MyName); break; /* -------------------------- swallow ------------------------ */ case 7: /* Swallow */ is_swallow = True; /* fall through */ case 8: /* Panel */ s = trimleft(s); if (is_swallow) { b->swallow=0; b->swallow_mask=0; } else { /* set defaults */ b->swallow = b_Respawn; b->swallow_mask = b_Respawn; b->slide_direction = SLIDE_UP; b->slide_position = SLIDE_POSITION_CENTER; b->slide_context = SLIDE_CONTEXT_PB; b->relative_x = 0; b->relative_y = 0; b->slide_steps = 12; b->slide_delay_ms = 5; } if(*s=='(' && s++) { if (is_swallow) ParseSwallow(&s, &b->swallow,&b->swallow_mask); else ParsePanel(&s, &b->swallow, &b->swallow_mask, &b->slide_direction, &b->slide_steps, &b->slide_delay_ms, &b->panel_flags, &b->indicator_size, &b->relative_x, &b->relative_y, &b->slide_position, &b->slide_context); } t=seekright(&s); o=seekright(&s); if(t) { if (b->hangon) free(b->hangon); b->hangon=t; if (is_swallow) { if (b->flags & b_Icon) { fprintf( stderr,"%s: a button can not have an icon and a swallowed " " window at the same time. Ignoring icon", MyName); b->flags &= ~ b_Icon; } b->flags |= (b_Swallow | b_Hangon); } else { b->flags |= (b_Panel | b_Hangon); b->newflags.is_panel = 1; b->newflags.panel_mapped = 0; } b->swallow|=1; if(!(b->swallow&b_NoHints)) b->hints=(XSizeHints*)mymalloc(sizeof(XSizeHints)); if(o) { char *p; p = expand_action(o, NULL); if (p) { if(!(buttonSwallow(b)&b_UseOld)) SendText(fd,p,0); if (b->spawn) free(b->spawn); b->spawn=o; /* Might be needed if respawning sometime */ free(p); } } } else { fprintf(stderr,"%s: Missing swallow argument\n",MyName); if(t) free(t); if(o) free(o); } break; /* --------------------------- action ------------------------ */ case 9: /* Action */ s = trimleft(s); i=0; if(*s=='(') { s++; if(strncasecmp(s,"mouse",5)!=0) { fprintf(stderr,"%s: Couldn't parse action\n",MyName); } s+=5; i=strtol(s,&t,10); s=t; while(*s && *s!=')') s++; if(*s==')') s++; } { char *r; char *u = s; s = GetQuotedString(s, &t, ",)", NULL, "(", ")"); r = s; if (t && r > u + 1) { /* remove unquoted trailing spaces */ r -= 2; while (r >= u && isspace(*r)) r--; r++; if (isspace(*r)) { t[strlen(t) - (s - r - 1)] = 0; } } } if(t) { AddButtonAction(b,i,t); free(t); } else fprintf(stderr,"%s: Missing action argument\n",MyName); break; /* -------------------------- container ---------------------- */ case 10: /* Container */ b->flags&=b_Frame|b_Back|b_Fore|b_Padding|b_Action; MakeContainer(b); *uberb=b; s = trimleft(s); if(*s=='(' && s++) ParseContainer(&s,b); break; case 11: /* End */ *uberb=ub->parent; ub->c->buttons[--(ub->c->num_buttons)]=NULL; free(b); if(!ub->parent) { fprintf(stderr,"%s: Unmatched END in config file\n",MyName); exit(1); } return; case 12: /* NoSize */ b->flags|=b_Size; b->minx=b->miny=0; break; case 13: /* Size */ i=strtol(s,&t,10); j=strtol(t,&o,10); if(t>s && o>t) { b->minx=i; b->miny=j; b->flags|=b_Size; s=o; } else fprintf(stderr,"%s: Illegal size arguments\n",MyName); break; case 14: /* Left */ b->flags |= b_Left; b->flags &= ~b_Right; break; case 15: /* Right */ b->flags |= b_Right; b->flags &= ~b_Left; break; case 16: /* Center */ b->flags &= ~(b_Right|b_Left); break; case 17: /* Colorset */ i = strtol(s, &t, 10); if(t > s) { b->colorset = i; b->flags |= b_Colorset; s=t; AllocColorset(i); } else { b->flags &= ~b_Colorset; } break; default: t=seekright(&s); fprintf(stderr,"%s: Illegal button option \"%s\"\n",MyName, (t)?t:""); if (t) free(t); break; } s = trimleft(s); } if (s && *s) { s++; s = trimleft(s); } } /* get title and iconname */ if(!(b->flags&b_Title)) { b->title=seekright(&s); if(b->title && *b->title && ((b->title)[0]!='-'||(b->title)[1]!=0)) b->flags |= b_Title; else if(b->title)free(b->title); } else { char *temp; temp = seekright(&s); if (temp) free(temp); } if(!(b->flags&b_Icon)) { b->icon_file=seekright(&s); if(b->icon_file && b->icon_file && ((b->icon_file)[0]!='-'||(b->icon_file)[1]!=0)) { b->flags|=b_Icon; b->IconWin=None; } else if(b->icon_file)free(b->icon_file); } else { char *temp; temp = seekright(&s); if (temp) free(temp); } s = trimleft(s); /* Swallow hangon command */ if (strncasecmp(s,"swallow",7)==0 || strncasecmp(s,"panel",7)==0) { if(b->flags & (b_Swallow | b_Panel)) { fprintf(stderr,"%s: Illegal with both old and new swallow!\n", MyName); exit(1); } s+=7; /* * Swallow old 'swallowmodule' command */ if (strncasecmp(s,"module",6)==0) { s+=6; } if (b->hangon) free(b->hangon); b->hangon=seekright(&s); if (!b->hangon) b->hangon = safestrdup(""); if (tolower(*s) == 's') b->flags |= b_Swallow | b_Hangon; else b->flags |= b_Panel | b_Hangon; b->swallow|=1; s = trimleft(s); if(!(b->swallow&b_NoHints)) b->hints=(XSizeHints*)mymalloc(sizeof(XSizeHints)); if(*s) { if(!(buttonSwallow(b)&b_UseOld)) SendText(fd,s,0); b->spawn=safestrdup(s); } } else if(*s) AddButtonAction(b,0,s); return; }
/* * property * family * structure * read * write * data * other * */ void AddProperty( char * input_string, enum external_type et ) { char * s_family = NULL ; char * s_property = NULL ; char * s_dummy ; ssize_t s_array ; enum ag_combined s_combined ; enum ag_index s_index_type ; enum ft_format s_format ; ssize_t s_length ; enum fc_change s_change ; char * s_read = NULL ; char * s_write = NULL ; char * s_data = NULL ; char * s_other = NULL; char * start_pointer = input_string ; if ( input_string == NULL ) { return ; } if ( ! Globals.allow_external ) { LEVEL_DEBUG("External prgroams not supported by %s",Globals.argv[0]) ; return ; } // property GetQuotedString( property ) ; // family GetQuotedString( family ) ; // type GetQuotedString( dummy ) ; switch ( s_dummy[0] ) { case 'D': s_length = PROPERTY_LENGTH_DIRECTORY ; s_format = ft_directory ; break ; case 'i': s_length = PROPERTY_LENGTH_INTEGER ; s_format = ft_integer ; break ; case 'u': s_length = PROPERTY_LENGTH_UNSIGNED ; s_format = ft_unsigned ; break ; case 'f': s_length = PROPERTY_LENGTH_FLOAT ; s_format = ft_float ; break ; case 'a': s_length = 1 ; s_format = ft_ascii ; break ; case 'b': s_length = 1 ; s_format = ft_binary ; break ; case 'y': s_length = PROPERTY_LENGTH_YESNO ; s_format = ft_yesno ; break ; case 'd': s_length = PROPERTY_LENGTH_DATE ; s_format = ft_date ; break ; case 't': s_length = PROPERTY_LENGTH_TEMP ; s_format = ft_temperature ; break ; case 'g': s_length = PROPERTY_LENGTH_TEMPGAP ; s_format = ft_tempgap ; break ; case 'p': s_length = PROPERTY_LENGTH_PRESSURE ; s_format = ft_pressure ; break ; default: LEVEL_DEFAULT("Unrecognized variable type <%s> for property <%s> family <%s>",s_dummy,s_property,s_family); s_format = ft_unknown ; return ; } if ( s_dummy[1] ) { int temp_length ; temp_length = strtol( &s_dummy[1], NULL, 0 ) ; if ( temp_length < 1 ) { LEVEL_DEFAULT("Unrecognized variable length <%s> for property <%s> family <%s>",s_dummy,s_property,s_family); return ; } s_length = temp_length ; } // array GetQuotedString( dummy ) ; switch ( s_dummy[0] ) { case '1': case '0': case '\0': s_combined = ag_separate ; s_index_type = ag_numbers ; s_array = 1 ; break ; case '-': s_array = 1 ; switch ( s_dummy[1] ) { case '1': s_combined = ag_sparse ; s_index_type = ag_numbers ; break ; default: s_combined = ag_sparse ; s_index_type = ag_letters ; break ; } break ; case '+': if ( isalpha( (int) s_dummy[1] ) ) { s_array = toupper( (int) s_dummy[1] ) - 'A' ; s_combined = ag_aggregate ; s_index_type = ag_letters ; } else { s_array = strtol( s_dummy, NULL, 0 ) ; s_combined = ag_aggregate ; s_index_type = ag_numbers ; } break ; default: if ( isalpha( (int) s_dummy[0] ) ) { s_array = toupper( (int) s_dummy[0] ) - 'A' ; s_combined = ag_separate ; s_index_type = ag_letters ; } else { s_array = strtol( s_dummy, NULL, 0 ) ; s_combined = ag_separate ; s_index_type = ag_numbers ; } break ; } if ( s_array < 1 ) { LEVEL_DEFAULT("Unrecognized array type <%s> for property <%s> family <%s>",s_dummy,s_property,s_family); return ; } // persistance GetQuotedString( dummy ) ; switch ( s_dummy[0] ) { case 'f': s_change = fc_static ; break ; case 's': s_change = fc_stable ; break ; case 'v': s_change = fc_volatile ; break ; case 't': s_change = fc_second ; break ; case 'u': s_change = fc_uncached ; break ; default: LEVEL_DEFAULT("Unrecognized persistance <%s> for property <%s> family <%s>",s_dummy,s_property,s_family); return ; } // read GetQuotedString( read ) ; // write GetQuotedString( write ) ; // data GetQuotedString( data ) ; // other GetQuotedString( other ) ; // test minimums if ( strlen( s_family ) > 0 && strlen( s_property ) > 0 ) { // Actually add AddFamilyToTree( s_family ) ; AddPropertyToTree( s_property, s_family, s_format, s_array, s_combined, s_index_type, s_length, s_change, s_read, s_write, s_data, s_other, et ) ; create_subdirs( s_property, s_family ) ; } // Clean up owfree( s_property ) ; owfree( s_family ) ; owfree( s_read ) ; owfree( s_write ) ; owfree( s_data ) ; owfree( s_other ) ; }