# Copyright (c) Hexacorn.com 2015
#
# strings_to_const v0.1
#
# Feel free to do whatever you want with it
#
# if you use different string prefix, replace
# the regexp in line 20
#
import idaapi
curseg = FirstSeg()

while curseg != BADADDR:
  sname = SegName(curseg);
  s = SegStart(curseg)
  e = SegEnd(curseg)
  if e>s:
     for i in range(s,e):
        nm = Name(i)
        m=re.search('^s->',nm,re.IGNORECASE)
        if m:
           gt=GetType(i)
           if not gt:
              gt=GuessType(i)
           if gt:
              print "%s, %s" % (nm, gt)
              SetType(i,"const "+gt)

  curseg = NextSeg(curseg)
