/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* fbc_Monitor - Edit Monitor sections
*/
#include <stdio.h> /* NULL */
#include "xf86Parser.h" /* Public function, etc. declarations */
#include "Configint.h" /* xf86conffree(), xf86confmalloc() */
#include "configProcs.h" /* Private function, etc. declarations */
#include "fbc_xorg.h" /* Edit config file data representations */
#include "fbc_Monitor.h" /* Edit Monitor sections */
#include "fbc_Option.h" /* Edit Option lists */
#include "fbc_error.h" /* Error reporting */
#include "fbc_line_er.h" /* External Representation of config lines */
#include "fbc_write_config.h" /* Write an updated config file */
/*
* fbc_find_Monitor_Mode()
*
* Given a Monitor section pointer and the name of a ModeLine /
* Mode-EndMode entry, return a pointer to the matching entry that is
* available to this Monitor section. "Available" means the entry is
* contained either within the Monitor section or within a Modes
* section named by a UseModes entry in the Monitor section. Return
* NULL if no available ModeLine / Mode-EndMode entry has that name.
*
* Compare this function with xf86validateMonitor() in Monitor.c.
*/
const char *mode_name) /* ModeLine / Mode-EndMode name */
{
/*
* Search Monitior section for the named ModeLine / Mode-EndMode entry
*/
return (mlptr); /* Found ModeLine / Mode-EndMode */
}
/*
* Traverse the list of Modes sectns specified by any UseModes entries
*/
/*
* Search Modes section for ModeLine / Mode-EndMode entry
*
* Note that xf86validateMonitor() should already
* have translated the UseModes names to Modes
* sections links (modeslink->ml_modes), which is why
* we don't have to call xf86findModes().
*/
break;
}
}
return (mlptr);
} /* fbc_find_Monitor_Mode() */
/*
* fbc_edit_Monitor_section()
*
* Modify or insert Monitor section values to the Internal
* Representation of the configuration file.
* Gamma <gamma_value> # -g <gamma_value>
* # Gamma <gamma_red> <gamma_green> <gamma_blue>
*/
int
{
/*
* Make any Gamma entry modification
*/
/*
* Edit the External Representation of the Gamma entry
*/
if (monitor_sectn_ptr->mon_gamma_red > 0.) {
/*
* Insert or modify the line's External Representation
*/
(xf86_print_fn_t *)
} else {
/*
* Delete the Gamma line's External Representation
*/
}
}
return (0);
} /* fbc_edit_Monitor_section() */
/*
* fbc_insert_new_Monitor_section()
*
* Insert a new, mostly empty Monitor section in the configuration at
* the specified location.
*
* Section "Monitor"
* Identifier "<monitor_identifier>"
* EndSection
* <blank line>
*
* Note that the Monitor section identifier string, mon_identifier,
* has been dynamically allocated by our caller.
*/
static
int
char *mon_identifier, /* Monitor section identifier */
{
/*
* Allocate and initialize the Internal Rep for a new Monitor section
*/
if (*monitor_ptr == NULL) {
return (FBC_ERR_NOMEM);
}
/*
* Insert the External Representation data for the Monitor section
*/
/* Section "Monitor" */
(void) fbc_insert_line_ER(
/* Identifier "<monitor_identifier>" */
(void) fbc_insert_line_ER(
/* EndSection */
(*monitor_ptr)->mon_end_line_er =
/* <blank line> */
(void) fbc_insert_line_ER(
"\n",
/*
* Add the new Monitor section to the in-memory configuration
*/
return (FBC_SUCCESS);
} /* fbc_insert_new_Monitor_section() */
/*
* fbc_insert_Monitor_section()
*
* Insert a new, empty Monitor section in the configuration at the
* specified location.
*/
int
const char *mon_ident_tmpl, /* Monitor section ident template */
{
unsigned int i; /* Loop counter / uniqueness factor */
/*
* Allocate memory for the new Monitor identifier string
*
* Allocate space for the intended name and any extra
* underscore and decimal digits needed to make it unique.
* The number of digits will never be greater than the byte
* size of the loop counter, i, multiplied by three decimal
* digits per byte.
*/
+ 1 /* "_" */
+ 3 * sizeof (i) /* Digits */
+ 1); /* Nul */
if (mon_identifier == NULL) {
return (FBC_ERR_NOMEM);
}
/*
* Insure that the new Monitor section identifier will be unique
*/
ident_format = "%s";
for (i = 0; ; ) {
/*
* Try the name alone and then the name with a numeric suffix
*/
ident_format = "%s_%u";
/*
* Search for this name among the existing Monitor sections
*/
mon_ptr->mon_identifier) == 0) {
break; /* Not unique */
}
}
/*
* Stop when the name is unique (or if the loop counter wraps)
*/
i += 1;
break; /* The name is unique enough */
}
}
/*
* Insert a new Monitor section into the in-memory configuration
*/
if (error_code != FBC_SUCCESS) {
return (error_code);
}
return (FBC_SUCCESS);
} /* fbc_insert_Monitor_section() */
/*
* fbc_insert_UseModes_entry()
*
* Insert the specified UseModes entry into the specified Monitor
* section.
*
* It is assumed that this function is called when no such UseModes
* entry can be found in the Monitor section.
*/
int
{
/*
* Allocate, zero, and further initialize the generic UseModes entry element
*/
if (usemodes_ptr == NULL) {
return (FBC_ERR_NOMEM);
}
return (FBC_ERR_NOMEM);
}
/*
* Append the new UseModes entry element to the (empty) list
*/
(glp)usemodes_ptr);
/*
* Insert the device specific UseModes entry
*/
sprintf(usemodes_name, "%s_%s", modes_sectn_ptr->modes_identifier, monitor_sectn_ptr->mon_identifier);
if (usemodes_er_ptr == NULL) {
/*
* Allocate, zero, and further initialize the UseModes entry element
*/
if (usemodes_er_ptr == NULL) {
return (FBC_ERR_NOMEM);
}
/*
* Append the new UseModes entry element to the (empty) list
*/
(void *)usemodes_er_ptr,
}
return (FBC_SUCCESS);
} /* fbc_insert_UseModes_entry() */
/* End of fbc_Monitor.c */