gen_constants_h.awk 1.35 KB
Newer Older
1
BEGIN {
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
  print "/*";
  print "    This file is part of telegram-client.";
  print "";
  print "    Telegram-client is free software: you can redistribute it and/or modify";
  print "    it under the terms of the GNU General Public License as published by";
  print "    the Free Software Foundation, either version 2 of the License, or";
  print "    (at your option) any later version.";
  print "";
  print "    Telegram-client is distributed in the hope that it will be useful,";
  print "    but WITHOUT ANY WARRANTY; without even the implied warranty of";
  print "    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the";
  print "    GNU General Public License for more details.";
  print "";
  print "    You should have received a copy of the GNU General Public License";
  print "    along with this telegram-client.  If not, see <http://www.gnu.org/licenses/>.";
  print "";
  print "    Copyright Vitaly Valtman 2013";
  print "*/";
20 21 22 23 24
  print "#ifndef CONSTANTS_H";
  print "#define CONSTANTS_H";
}
//  {
  if (split ($1, a, "#") == 2) {
25
    gsub (/[ABCDEFGHIJKLMNOPQRSTUVWXYZ]/, "_&", a[1]);
26 27 28 29 30 31 32 33 34 35 36 37
    gsub (/[.]/, "_", a[1]);
    if (a[2] in h) {
      print "ERROR: Duplicate magic " a[2] " for define " a[1] " and " h[a[2]] >"/dev/stderr/"
      exit 1;
    }
    h[a[2]] = a[1];
    print "#define", "CODE_" tolower(a[1]), "0x" a[2];
  }
}
END {
  print "#endif";
}