public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* New whitelist.c and more stuff
@ 2009-11-20  0:06 Rodolfo (kix)
  2009-11-21 23:45 ` Pavel Machek
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Rodolfo (kix) @ 2009-11-20  0:06 UTC (permalink / raw)
  To: pm list, Rafael J. Wysocki, Pavel Machek, suspend-devel List

[-- Attachment #1: Type: text/plain, Size: 693 bytes --]

Hi,

this is an email-pack with many things:

A new database file: whitelist_2009111900.{c|csv} This file includes
de updates from 3/aug to now. One change and some new machines.

I include too a new database file: whitelist_nodup.c, is the old
(original, actual in git) whitelist.c file (without the new machines)
and without duplicates.

I add a new version of the dbcheck tool and the new perl scripts to
the database management:

wlc2csv.pl:   C -> CSV
wlcsv2c.pl    CSV -> C

Please, send me your comments about this files and the other three
patchs. Include the new database in the git.
Sorry for the email size.

kix.

-- 
Rodolfo García "kix"
EA4ERH - IN80ER

[-- Attachment #2: whitelist_2009112000.c --]
[-- Type: application/octet-stream, Size: 104071 bytes --]

[-- Attachment #3: whitelist_2009112000.csv --]
[-- Type: application/vnd.ms-excel, Size: 98263 bytes --]

[-- Attachment #4: wlc2csv.pl --]
[-- Type: application/octet-stream, Size: 1089 bytes --]

#!/usr/bin/perl

#!/usr/bin/perl
## Rodolfo Garcia kix_at_kix.es
## suspend database management v1.0

use Switch;

switch ($#ARGV) {
  case 0 {
    my $fin = $ARGV[0];
    open(INF, "<$fin") or die "Could not open input file\n";
    open(OUF, ">&STDOUT") or die "Could not open output file\n";
  }
  case 1 {
    my $fin = $ARGV[0];
    my $fout = $ARGV[1];
    open(INF, "<$fin") or die "Could not open input file\n";
    open(OUF, ">$fout") or die "Could not open output file\n";
  }
  else {
    my $msg = $0 . " <input-file> [output-file]";
    die $msg;
  }
}

# We have two important cases, comment and info

while(<INF>) {
  if (/\s*\/\*(.*)\*\/$/) {
    $comments = "/*" . $1 . "*/";
  }

  if (/\s*{\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*([\w\|]*)\s*}\s*,\s*(.*)/) {
    $sys_vendor = $1;
    $sys_product = $2;
    $sys_version = $3;
    $bios_version = $4;
    $flags = $5;
    print OUF "\"" . $sys_vendor . "\", \"" . $sys_product . "\", \"" . $sys_version . "\", \"" . $bios_version . "\", " . $flags . ", " . $comments . "\n";
  }
}

close(INF);
close(OUF);

[-- Attachment #5: wlcsv2c.pl --]
[-- Type: application/octet-stream, Size: 2029 bytes --]

#!/usr/bin/perl
# Rodolfo Garcia kix_at_kix.es
# suspend database management v1.0

use Switch;

switch ($#ARGV) {
  case 0 {
    my $fin = $ARGV[0];
    open(INF, "<$fin") or die "Could not open input file\n";
    open(OUF, ">&STDOUT") or die "Could not open output file\n";
  }
  case 1 {
    my $fin = $ARGV[0];
    my $fout = $ARGV[1];
    open(INF, "<$fin") or die "Could not open input file\n";
    open(OUF, ">$fout") or die "Could not open output file\n";
  }
  else {
    my $msg = $0 . " <input-file> [output-file]";
    die $msg;
  }
}

&print_c_header;

my $sys_vendor = "";
my $sys_product = "";
my $sys_version = "";
my $bios_version = "";
my $flags = "";
my $comments = "";

while(<INF>) {
  if (/"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*"([^"]*)",\s*([^,]*),\s*(.*)/) {
    $sys_vendor = $1;
    $sys_product = $2;
    $sys_version = $3;
    $bios_version = $4;
    $flags = $5;
    $comments = $6;

    printf OUF "\t$comments\n";
    printf OUF "\t{ \"" . $sys_vendor . "\",\t\"" . $sys_product . "\",\t\"" . $sys_version . "\",\t\"" . $bios_version . "\",\t" . $flags . " },\n";
  }
}

&print_c_footer;

close(INF);
close(OUF);

sub print_c_header 
{
  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

  printf OUF "/* whitelist.c\n";
  printf OUF " * whitelist of machines that are known to work somehow\n";
  printf OUF " * and all the workarounds\n";
  printf OUF " * Script generated file, please do not edit by hand\n";
  printf OUF " */\n";
  printf OUF "\n";
  printf OUF "\#include \"config.h\"\n";
  printf OUF "\#include \<stdlib.h\>\n";
  printf OUF "\#include \"whitelist.h\"\n";
  printf OUF "\n";

  printf OUF "char *whitelist_version = \"\$Id: whitelist.c ver. ";
  printf OUF "%4d%02d%02d %02d:%02d:%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec;
  printf OUF " automatic generation - kix - Exp \$\";\n";
  printf OUF "\n";
  printf OUF "struct machine_entry whitelist[] = {\n";
}

sub print_c_footer
{
  print OUF "\t{ NULL, NULL, NULL, NULL, 0 }\n";
  print OUF "};\n";
}

[-- Attachment #6: whitelist_nodup.csv --]
[-- Type: application/vnd.ms-excel, Size: 90936 bytes --]

[-- Attachment #7: dbcheck.c --]
[-- Type: application/octet-stream, Size: 1169 bytes --]

/*
 * Suspend-to-RAM
 *
 * Database Comparation Tool
 * Rodolfo Garcia <kix@kix.es>, 11/2009
 * Distribute under GPLv2.
 */

#include <stdio.h>
#include <string.h>
#include "s2ram.h"
#include "whitelist.h"

int main(void)
{
	int i, j, ret = 0;

	/* sys_vendor = NULL terminates the whitelist array */

	for (i = 0; whitelist[i].sys_vendor; i++) {
		for (j = 0; whitelist[j].sys_vendor; j++) {
			if (match(whitelist[i].sys_vendor,   whitelist[j].sys_vendor)  &&
			    match(whitelist[i].sys_product,  whitelist[j].sys_product) &&
			    match(whitelist[i].sys_version,  whitelist[j].sys_version) &&
			    match(whitelist[i].bios_version, whitelist[j].bios_version) &&
			    i != j) {
				printf("Database conflict %d = %d:\n", i, j);
				printf("\tsys_vendor:\t [%s] = [%s]\n", whitelist[i].sys_vendor, whitelist[j].sys_vendor);
				printf("\tsys_product:\t [%s] = [%s]\n", whitelist[i].sys_product, whitelist[j].sys_product);
				printf("\tsys_version:\t [%s] = [%s]\n", whitelist[i].sys_version, whitelist[j].sys_version);
				printf("\tbios_version:\t [%s] = [%s]\n", whitelist[i].bios_version, whitelist[j].bios_version);
				ret++;
			}
		}
	}
	return ret;
}



[-- Attachment #8: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-11-29 23:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-20  0:06 New whitelist.c and more stuff Rodolfo (kix)
2009-11-21 23:45 ` Pavel Machek
2009-11-29 23:01   ` Rafael J. Wysocki
2009-11-29 22:59 ` Rafael J. Wysocki
2009-11-29 23:16 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox