aboutsummaryrefslogtreecommitdiffstats
path: root/template/en/default/admin/params/common.html.tmpl
blob: c23c2ca9a5078fe4ef9bd5bcaeb5a512e9072801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
  #                 Marc Schumann <wurblzap@gmail.com>
  #%]
[%# INTERFACE:
  # panel: hash representing the current panel.
  #%]

[% sortlist_separator = '---' %]

<dl>
  [% FOREACH param = panel.param_list %]
    <dt><a name="[% param.name FILTER html %]">[% param.name FILTER html %]</a></dt>
    <dd>[% panel.param_descs.${param.name} FILTER none %]
      <p>
      [% IF param.type == "t" %]
        <input type="text" size="80" name="[% param.name FILTER html %]"
               id="[% param.name FILTER html %]" value="[% Param(param.name) FILTER html %]">
      [% ELSIF param.type == "p" %]
        <input type="password" size="80" name="[% param.name FILTER html %]"
               id="[% param.name FILTER html %]" value="[% Param(param.name) FILTER html %]"
               autocomplete="off">
      [% ELSIF param.type == "l" %]
        <textarea name="[% param.name FILTER html %]" id="[% param.name FILTER html %]"
                  rows="10" cols="80">[% Param(param.name) FILTER html %]</textarea>
      [% ELSIF param.type == "b" %]
        <input type="radio" name="[% param.name FILTER html %]" id="[% param.name FILTER html %]-on"
               value=1 [% "checked=\"checked\"" IF Param(param.name) %]>
        <label for="[% param.name FILTER html %]-on">On</label>
        <input type="radio" name="[% param.name FILTER html %]" id="[% param.name FILTER html %]-off"
               value=0 [% "checked=\"checked\"" IF !Param(param.name) %]>
        <label for="[% param.name FILTER html %]-off">Off</label>
      [% ELSIF param.type == "m" %]
        [% boxSize = 5 %]
        [% boxSize = param.choices.size IF param.choices.size < 5 %]

        <select multiple="multiple" size="[% boxSize FILTER html %]"
                name="[% param.name FILTER html %]" id="[% param.name FILTER html %]">
          [% FOREACH item = param.choices %]
            <option value="[% item FILTER html %]"
                    [% " selected=\"selected\"" IF lsearch(Param(param.name), item) != -1 %]>
              [% item FILTER html %]
            </option>
          [% END %]
        </select>
      [% ELSIF param.type == "o" %]
        <script type="text/javascript"><!--
          document.write("<span style=\"display: none\">");
        // -->
        </script>
        <input id="input_[% param.name FILTER html %]" size="80"
               name="[% param.name FILTER html %]"
               value="[% Param(param.name) FILTER html %]"><br>
        <script type="text/javascript"><!--
          document.write("<\/span>");
        // -->
        </script>
        [% boxSize = 7 %]
        [% boxSize = 3 + param.choices.size IF param.choices.size < 7 %]
        [% plist = Param(param.name).split(',') %]

        <script type="text/javascript"><!--
          document.write(
            '<table>' +
            '  <tr>' +
            '    <td rowspan="2">' +
            '      <select id="select_[% param.name FILTER html %]"' +
            '              size="[% boxSize FILTER html %]"' +
            '              name="select_[% param.name FILTER html %]">' +
                     [% FOREACH item = plist %]
            '          <option value="[% item FILTER html %]">[% item FILTER html %]<\/option>' +
                     [% END %]
            '        <option class="sortlist_separator"' +
            '                disabled="disabled"' +
            '                value="[% sortlist_separator %]">active&uarr;&nbsp;&darr;inactive<\/option>' +
                     [% FOREACH item = param.choices %]
                       [% IF lsearch(plist, item) == -1 %]
            '            <option value="[% item FILTER html %]">[% item FILTER html %]<\/option>' +
                       [% END %]
                     [% END %]
            '      <\/select>' +
            '    <\/td>' +
            '    <td style="vertical-align: bottom">' +
            '      <button type="button"' +
            '              onClick="sortedList_moveItem(\'[% param.name FILTER html %]\', -1, \'[% sortlist_separator %]\');">&uarr;<\/button>' +
            '    <\/td>' +
            '  <\/tr>' +
            '  <tr>' +
            '    <td style="vertical-align: top">' +
            '      <button type="button"' +
            '              onClick="sortedList_moveItem(\'[% param.name FILTER html %]\', +1, \'[% sortlist_separator %]\');">&darr;<\/button>' +
            '    <\/td>' +
            '  <\/tr>' +
            '<\/table>');
        // -->
        </script>
      [% ELSIF param.type == "s" %]
        <select name="[% param.name FILTER html %]" id="[% param.name FILTER html %]">
          [% FOREACH item = param.choices %]
            <option value="[% item FILTER html %]"
                    [% " selected=\"selected\"" IF item == Param(param.name) %]>
              [% item FILTER html %]
            </option>
          [% END %]
        </select>
      [% ELSE %]
        <font color="red">
          <blink>Unknown param type [% param.type FILTER html %]!!!</blink>
        </font>
      [% END %]  
      </p>
      <p>
        <input type="checkbox" name="reset-[% param.name FILTER html %]"
               id="reset-[% param.name FILTER html %]">
        <label for="reset-[% param.name FILTER html %]">Reset</label>
      </p>
      <hr>
    </dd>
  [% END %]
</dl>
' href='#n283'>283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
/* Elf file, section, and symbol manipulation routines.
   Copyright 1996, 1997 Linux International.

   Contributed by Richard Henderson <rth@tamu.edu>

   This file is part of the Linux modutils.

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2 of the License, or (at your
   option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <alloca.h>

#include <obj.h>
#include <util.h>
#include <module.h>

/*======================================================================*/

/* Standard ELF hash function.  */
inline unsigned long
obj_elf_hash_n(const char *name, unsigned long n)
{
  unsigned long h = 0;
  unsigned long g;
  unsigned char ch;

  while (n > 0)
    {
      ch = *name++;
      h = (h << 4) + ch;
      if ((g = (h & 0xf0000000)) != 0)
	{
	  h ^= g >> 24;
	  h &= ~g;
	}
      n--;
    }
  return h;
}

unsigned long
obj_elf_hash (const char *name)
{
  return obj_elf_hash_n(name, strlen(name));
}

void
obj_set_symbol_compare (struct obj_file *f,
			int (*cmp)(const char *, const char *),
			unsigned long (*hash)(const char *))
{
  if (cmp)
    f->symbol_cmp = cmp;
  if (hash)
    {
      struct obj_symbol *tmptab[HASH_BUCKETS], *sym, *next;
      int i;

      f->symbol_hash = hash;

      memcpy(tmptab, f->symtab, sizeof(tmptab));
      memset(f->symtab, 0, sizeof(f->symtab));

      for (i = 0; i < HASH_BUCKETS; ++i)
	for (sym = tmptab[i]; sym ; sym = next)
	  {
	    unsigned long h = hash(sym->name) % HASH_BUCKETS;
	    next = sym->next;
	    sym->next = f->symtab[h];
	    f->symtab[h] = sym;
	  }
    }
}

struct obj_symbol *
obj_add_symbol (struct obj_file *f, const char *name, unsigned long symidx,
		int info, int secidx, ElfW(Addr) value, unsigned long size)
{
  struct obj_symbol *sym;
  unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;
  int n_type = ELFW(ST_TYPE)(info);
  int n_binding = ELFW(ST_BIND)(info);

  for (sym = f->symtab[hash]; sym; sym = sym->next)
    if (f->symbol_cmp(sym->name, name) == 0)
      {
	int o_secidx = sym->secidx;
	int o_info = sym->info;
	int o_type = ELFW(ST_TYPE)(o_info);
	int o_binding = ELFW(ST_BIND)(o_info);

	/* A redefinition!  Is it legal?  */

	if (secidx == SHN_UNDEF)
	  return sym;
	else if (o_secidx == SHN_UNDEF)
	  goto found;
	else if (n_binding == STB_GLOBAL && o_binding == STB_LOCAL)
	  {
	    /* Cope with local and global symbols of the same name
	       in the same object file, as might have been created
	       by ld -r.  The only reason locals are now seen at this
	       level at all is so that we can do semi-sensible things
	       with parameters.  */

	    struct obj_symbol *nsym, **p;

	    nsym = arch_new_symbol();
	    nsym->next = sym->next;
	    nsym->ksymidx = -1;

	    /* Excise the old (local) symbol from the hash chain.  */
	    for (p = &f->symtab[hash]; *p != sym; p = &(*p)->next)
	      continue;
	    *p = sym = nsym;
	    goto found;
	  }
	else if (n_binding == STB_LOCAL)
	  {
	    /* Another symbol of the same name has already been defined.
	       Just add this to the local table.  */
	    sym = arch_new_symbol();
	    sym->next = NULL;
	    sym->ksymidx = -1;
	    f->local_symtab[symidx] = sym;
	    goto found;
	  }
	else if (n_binding == STB_WEAK)
	  return sym;
	else if (o_binding == STB_WEAK)
	  goto found;
	/* Don't unify COMMON symbols with object types the programmer
	   doesn't expect.  */
	else if (secidx == SHN_COMMON
		 && (o_type == STT_NOTYPE || o_type == STT_OBJECT))
	  return sym;
	else if (o_secidx == SHN_COMMON
		 && (n_type == STT_NOTYPE || n_type == STT_OBJECT))
	  goto found;
	else
	  {
	    /* Don't report an error if the symbol is coming from
	       the kernel or some external module.  */
	    if (secidx <= SHN_HIRESERVE)
	      error("%s multiply defined", name);
	    return sym;
	  }
      }

  /* Completely new symbol.  */
  sym = arch_new_symbol();
  sym->next = f->symtab[hash];
  f->symtab[hash] = sym;
  sym->ksymidx = -1;

  if (ELFW(ST_BIND)(info) == STB_LOCAL && symidx != -1) {
    if (symidx >= f->local_symtab_size)
      error("local symbol %s with index %ld exceeds local_symtab_size %ld",
        name, (long) symidx, (long) f->local_symtab_size);
    else
      f->local_symtab[symidx] = sym;
  }

found:
  sym->name = name;
  sym->value = value;
  sym->size = size;
  sym->secidx = secidx;
  sym->info = info;
  sym->r_type = 0;	/* should be R_arch_NONE for all arch */

  return sym;
}

struct obj_symbol *
obj_find_symbol (struct obj_file *f, const char *name)
{
  struct obj_symbol *sym;
  unsigned long hash = f->symbol_hash(name) % HASH_BUCKETS;

  for (sym = f->symtab[hash]; sym; sym = sym->next)
    if (f->symbol_cmp(sym->name, name) == 0)
      return sym;

  return NULL;
}

ElfW(Addr)
obj_symbol_final_value (struct obj_file *f, struct obj_symbol *sym)
{
  if (sym)
    {
      if (sym->secidx >= SHN_LORESERVE)
	return sym->value;

      return sym->value + f->sections[sym->secidx]->header.sh_addr;
    }
  else
    {
      /* As a special case, a NULL sym has value zero.  */
      return 0;
    }
}

struct obj_section *
obj_find_section (struct obj_file *f, const char *name)
{
  int i, n = f->header.e_shnum;

  for (i = 0; i < n; ++i)
    if (strcmp(f->sections[i]->name, name) == 0)
      return f->sections[i];

  return NULL;
}

#if defined (ARCH_alpha)
#define ARCH_SHF_SHORT	SHF_ALPHA_GPREL
#elif defined (ARCH_ia64)
#define ARCH_SHF_SHORT	SHF_IA_64_SHORT
#else
#define ARCH_SHF_SHORT	0
#endif

static int
obj_load_order_prio(struct obj_section *a)
{
  unsigned long af, ac;

  af = a->header.sh_flags;

  ac = 0;
  if (a->name[0] != '.'
      || strlen(a->name) != 10
      || strcmp(a->name + 5, ".init"))
    ac |= 64;
  if (af & SHF_ALLOC) ac |= 32;
  if (af & SHF_EXECINSTR) ac |= 16;
  if (!(af & SHF_WRITE)) ac |= 8;
  if (a->header.sh_type != SHT_NOBITS) ac |= 4;
  /* Desired order is
		P S  AC & 7
	.data	1 0  4
	.got	1 1  3
	.sdata  1 1  1
	.sbss   0 1  1
	.bss    0 0  0  */
  if (strcmp (a->name, ".got") == 0) ac |= 2;
  if (af & ARCH_SHF_SHORT)
    ac = (ac & ~4) | 1;

  return ac;
}

void
obj_insert_section_load_order (struct obj_file *f, struct obj_section *sec)
{
  struct obj_section **p;
  int prio = obj_load_order_prio(sec);
  for (p = f->load_order_search_start; *p ; p = &(*p)->load_next)
    if (obj_load_order_prio(*p) < prio)
      break;
  sec->load_next = *p;
  *p = sec;
}

struct obj_section *
obj_create_alloced_section (struct obj_file *f, const char *name,
			    unsigned long align, unsigned long size,
			    unsigned long flags)
{
  int newidx = f->header.e_shnum++;
  struct obj_section *sec;

  f->sections = xrealloc(f->sections, (newidx+1) * sizeof(sec));
  f->sections[newidx] = sec = arch_new_section();

  memset(sec, 0, sizeof(*sec));
  sec->header.sh_type = SHT_PROGBITS;
  sec->header.sh_flags = flags | SHF_ALLOC;
  sec->header.sh_size = size;
  sec->header.sh_addralign = align;
  sec->name = name;
  sec->idx = newidx;
  if (size)
    sec->contents = xmalloc(size);

  obj_insert_section_load_order(f, sec);

  return sec;
}

struct obj_section *
obj_create_alloced_section_first (struct obj_file *f, const char *name,
				  unsigned long align, unsigned long size)
{
  int newidx = f->header.e_shnum++;
  struct obj_section *sec;

  f->sections = xrealloc(f->sections, (newidx+1) * sizeof(sec));
  f->sections[newidx] = sec = arch_new_section();

  memset(sec, 0, sizeof(*sec));
  sec->header.sh_type = SHT_PROGBITS;
  sec->header.sh_flags = SHF_WRITE|SHF_ALLOC;
  sec->header.sh_size = size;
  sec->header.sh_addralign = align;
  sec->name = name;
  sec->idx = newidx;
  if (size)
    sec->contents = xmalloc(size);

  sec->load_next = f->load_order;
  f->load_order = sec;
  if (f->load_order_search_start == &f->load_order)
    f->load_order_search_start = &sec->load_next;

  return sec;
}

void *
obj_extend_section (struct obj_section *sec, unsigned long more)
{
  unsigned long oldsize = sec->header.sh_size;