Index: app/src/dgp/Makefile
===================================================================
--- app/src/dgp/Makefile	(revision a5fdde96132cd61c3f2e6d56c426c96b741427c8)
+++ app/src/dgp/Makefile	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
@@ -3,4 +3,7 @@
 SHELL = /bin/sh
 LIB_PATH=../../lib
+COMMON_PATH=../common
+CMDLINE_FILE='"../dgp/cmdline.h"'
+
 
 #vpath %.o  .
@@ -9,5 +12,5 @@
 
 sources = main.cc grammar.cc symbol.cc mgraph.cc sgraph.cc dgp0.cc cmdline.cc \
-          common.cc global.cc
+          $(COMMON_PATH)/common.cc global.cc
 
 bin  = dgp
@@ -22,5 +25,5 @@
 
 %.o: %.cc
-	${CXX} -c ${CXXFLAGS} -o $@ $<
+	${CXX} -D _CMDLINE_FILE=$(CMDLINE_FILE) -c ${CXXFLAGS} -o $@ $<
 
 %.d: %.cc
@@ -29,6 +32,15 @@
 	rm -f $@.$$$$
 
-cmdline.cc cmdline.h : cmdline.ggo
-	gengetopt --c-extension=cc -i cmdline.ggo
+# stare:
+# cmdline.cc cmdline.h : cmdline.ggo
+# 	gengetopt --c-extension=cc -i cmdline.ggo
+# nowe
+cmdline.cc cmdline.h: cmdline.ggo
+	gengetopt -i cmdline.ggo  --c-extension=cc --conf-parser
+
+cmdline.ggo: cmdline_dgp.ggo ../common/cmdline_common.ggo
+	cat cmdline_dgp.ggo ../common/cmdline_common.ggo > cmdline.ggo
+# endnowe
+
 
 clean:
Index: app/src/dgp/cmdline.ggo
===================================================================
--- app/src/dgp/cmdline.ggo	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ 	(revision )
@@ -1,42 +1,0 @@
-package "dgp"
-version "0.1"
-
-option  "process"	p	"Process segments with this tag."
-				string no multiple
-
-option  "select"	s	"Select only segments with this field. [Not implemented.]" 
-				string no multiple
-
-option  "ignore"	S	"Select only segments without this field. [Not implemented]" 
-				string no multiple
-
-option  "input"		f	"Input file"
-				string typestr="filename" no
-
-option  "output"	o	"Output file"
-				string typestr="filename" no
-
-option  "failed"	e	"Fail file"
-				string typestr="filename" no
-
-option  "copy"		c	"Copy unprocessed"
-				flag off
-
-option	"grammar"	g	"Grammar file"
-				string typestr="filename" default="dgp.dg"
-
-option  "long"		l	"Long output"
-				flag off
-
-option  "interactive"	-	"Interactive use."
-				flag off
-
-option  "debug"		d	"Debug mode."
-				flag off
-
-option	"info"		i	"Print info. 
-h - heads         d - dependents
-s - sets
-c - constraints	  n - node/arc counts	t - parse time
-"
-				string default="gh"
Index: app/src/dgp/cmdline_dgp.ggo
===================================================================
--- app/src/dgp/cmdline_dgp.ggo	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
+++ app/src/dgp/cmdline_dgp.ggo	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
@@ -0,0 +1,42 @@
+package "dgp"
+version "0.1"
+
+#option  "process"	p	"Process segments with this tag."
+#				string no multiple
+
+#option  "select"	s	"Select only segments with this field. [Not implemented.]" 
+#				string no multiple
+
+#option  "ignore"	S	"Select only segments without this field. [Not implemented]" 
+#				string no multiple
+
+#option  "input"		f	"Input file"
+#				string typestr="filename" no
+
+#option  "output"	o	"Output file"
+#				string typestr="filename" no
+
+#option  "failed"	e	"Fail file"
+#				string typestr="filename" no
+
+#option  "copy"		c	"Copy unprocessed"
+#				flag off
+
+option	"grammar"	g	"Grammar file"
+				string typestr="filename" default="dgp.dg"
+
+option  "long"		l	"Long output"
+				flag off
+
+#option  "interactive"	-	"Interactive use."
+#				flag off
+
+option  "debug"		d	"Debug mode."
+				flag off
+
+option	"info"		-	"Print info. 
+h - heads         d - dependents
+s - sets
+c - constraints	  n - node/arc counts	t - parse time
+"
+				string default="gh"
Index: app/src/dgp/common.cc
===================================================================
--- app/src/dgp/common.cc	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ 	(revision )
@@ -1,39 +1,0 @@
-#include <stdlib.h>
-#include <string.h>
-#include "common.h"
-
-FILE* inputf=stdin;
-FILE* outputf=stdout;
-FILE* failedf=stdout;
-bool copy_processed=0;
-
-void process_common_options(gengetopt_args_info args)
-{
-  if(args.help_given)
-      cmdline_parser_print_help ();
-
-  if(args.input_given)
-    if(!(inputf=fopen(args.input_arg,"r")))
-    {
-      fprintf(stderr,"No such file: %s.\n", args.input_arg);
-      exit(1);
-    }
-  
-  if(args.output_given)
-    if(!(outputf=fopen(args.output_arg,"w")))
-    {
-      fprintf(stderr,"Cannot open output file: %s.\n", args.output_arg);
-      exit(1);
-    }
-  
-  if(args.failed_given)
-      if(!(failedf=fopen(args.failed_arg,"w")))
-      {
-	fprintf(stderr,"Cannot open output file: %s.\n", args.failed_arg);
-	exit(1);
-      }
-
-
-  if(args.copy_given)
-    copy_processed=true;
-}
Index: app/src/dgp/common.h
===================================================================
--- app/src/dgp/common.h	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ 	(revision )
@@ -1,277 +1,0 @@
-#ifndef __COMMON_H
-#define __COMMON_H
-
-#include <stdio.h>
-#include <ctype.h>
-
-#include "cmdline.h"
-#include "const.hh"
-
-
-/**************************************************
- * Stale dotyczace wejscia/wyjscia
- */
-
-#define EMPTYFORM '*'
-#define INFIELD_SEP ':'
-#define MAXAUX 64
-#define FIELD_SEP " \t\n"
-
-/**************************************************/
-
-
-extern FILE* inputf;
-extern FILE* outputf;
-extern FILE* failedf;
-
-extern char* input_filename;
-extern char* output_filename;
-extern char* failed_filename;
-
-extern bool copy_processed;
-extern bool append_output;
-extern bool append_failed;
-
-extern void process_common_options(gengetopt_args_info args);
-
-
-
-/**************************************************/
-/*
-parameters:
-  -seg  - segment
-  -name - field name
-  +val  - field contents
-return value:
-  1 if specified field exists, 0 otherwise
-*/
-
-inline int getfield(const char* seg, const char* pref, char* val)
-{
-  const char* p=seg;
-
-  while(*p==' ') ++p;
-  
- pos:
-  if(isdigit(*p) or *p=='*')
-    if(*pref=='1') return sscanf(p,"%s",val); else while(*p!=' ') ++p; 
-  else
-    if(*pref=='1') return 0; else goto type;
-
-  while(*p==' ') ++p;
-  
- len:
-  if(isdigit(*p) or *p=='*')
-    if(*pref=='2') return sscanf(p,"%s",val); else while(*p!=' ') ++p; 
-  else
-    if(*pref=='2') return 0; else goto type;
-
-  while(*p==' ') ++p;
-  
- type:
-
-  if(*pref=='3') return sscanf(p,"%s",val); else while(*p!=' ') ++p;
-
-  while(*p==' ') ++p;
-
- form:
-  if(*pref=='4') return sscanf(p,"%s",val); else while(*p!=' ') ++p;
-
-  while(*p==' ') ++p;
-
- annotation:
-  do p=strstr(p,pref); while(p!=NULL && *(p-1)!=' ' && *(p-1)!='\t');
-  
-  if(p==NULL) return 0;
-  else
-  {
-    p+=strlen(pref);
-    int len=strcspn(p,FIELD_SEP "\n\r\f\0");
-    strncpy(val,p,len);
-    val[len]='\0';
-    return 1;
-  }
-}
-
-
-/*
-parameters:
-  +seg - segment
-  -pref - prefix of the new field
-  -val  - contents of the new field
-return value:
-  1 - success, 0 - fail (limit on segment length exceeded)
-*/
-inline int addfield(char *seg, const char *pref, const char *val)
-     // zalozenie, ze seg konczy sie znakiem \n
-{
-  if(strlen(seg)+strlen(pref)+strlen(val) >= MAXLINE) return 0; // bezpieczniej, ale wolniej
-
-  int seglen=strlen(seg);
-  sprintf(seg+(seglen-1)," %s%s\n",pref,val);
-  return 1;
-}
-
-
-inline
-bool processseg(const char* s, gengetopt_args_info& args)
-{
-  bool ret = !args.process_given;
-  char field[MAXAUX];
-    
-  if(args.process_given)
-  {
-    getfield(s,"3",field);
-    for(int i=0; i<args.process_given; ++i)
-      if(strcmp(args.process_arg[i],field)==0)
-      {
-        ret=true;
-        break;
-      }
-  }
-
-  for(int i=0; i<args.select_given; ++i)
-    if(! getfield(s,args.select_arg[i],field))
-      ret=false;
-  
-  for(int i=0; i<args.ignore_given; ++i)
-    if(getfield(s,args.ignore_arg[i],field))
-      ret=false;
-
-  return ret;
-}
-
-
-/* DEPRICATED */
-
-
-/* definicja struktury wejscia/wyjscia
- */
-struct Segment
-{
-  int filepos, len;
-  char* tag;
-  char* form;
-  char* aux[MAXAUX];
-  int auxn;
-
-  bool parse(char* line);
-  char* getfield(char* fieldname);
-  void print(char* line);
-  bool addfield(char* s);
-  bool clearfields();
-};
-
-/*
- * Sprawdza czy nalezy przetwarzac dany segment.
- */
-
-inline
-bool process_seg(Segment& s, gengetopt_args_info& args)
-{
-  bool ret = !args.process_given;
-
-  for(int i=0; i<args.process_given; ++i)
-    if(strcmp(args.process_arg[i],s.tag)==0)
-      {
-        ret=true;
-        break;
-      }
-
-  for(int i=0; i<args.select_given; ++i)
-    if(! s.getfield(args.select_arg[i]))
-      ret=false;
-
-  for(int i=0; i<args.ignore_given; ++i)
-    if(s.getfield(args.ignore_arg[i]))
-      ret=false;
-
-  return ret;
-}
-
-
-/*
- * FUNKCJE OBSLUGUJACE WEJSCIE/WYJSCIE
- */
-// napisy zostaj na miejscu (w line), tylko wskazniki sa ustawian
-// i zara dopisywane zera s dopisywane
-
-inline
-bool Segment::parse(char* line)
-{
-  auxn=0;
-  char* field;
-  if((field=strtok(line,FIELD_SEP))!=NULL)
-    filepos=atoi(field); // nie sprawdzana poprawnosc
-  else
-    return false;
-  if((field=strtok(NULL,FIELD_SEP))!=NULL)
-    len=atoi(field); // nie sprawdzana poprawnosc
-  else return false;
-  if((tag=strtok(NULL,FIELD_SEP))==NULL) return false;
-  if((form=strtok(NULL,FIELD_SEP))==NULL)
-    return false;
-/*   else */
-/*     if(form[0] == EMPTYFORM && form[1] =='\0') */
-/*       form=NULL; */
-
-  while((aux[auxn]=strtok(NULL,FIELD_SEP))!=NULL) ++auxn;
-
-  return true;
-}
-
-
-inline char* Segment::getfield(char* f)
-{
-  int flen=strlen(f);
-  for(int i=0; i<auxn; ++i)
-    if(strncmp(aux[i],f,flen)==0 && aux[i][flen]==INFIELD_SEP)
-      return aux[i]+flen+1;
-  return NULL;
-}
-
-inline bool Segment::clearfields() {
-  for (int i=0; i<auxn; ++i) {
-    //    free(aux[i]);
-    aux[i] = NULL;
-  }
-  auxn=0;
-  return true;
-}
-
-inline // NIEEFEKTYWNE
-void Segment::print(char* line)
-{
-  sprintf(line,"%04d %02d %s", filepos, len, tag);
-  if(form)
-    {
-      strcat(line," ");
-      strcat(line,form);
-    }
-  else
-    if(auxn)
-      strcat(line," *");
-
-  for(int i=0; i<auxn; ++i)
-    {
-      strcat(line," ");
-      strcat(line,aux[i]);
-    }
-
-  strcat(line,"\n");
-}
-
-
-inline
-bool Segment::addfield(char* s)
-{
-  if(auxn<MAXAUX)
-    {
-      aux[auxn++]=s;
-      return true;
-    }
-  else
-    return false;
-}
-
-#endif
Index: app/src/dgp/main.cc
===================================================================
--- app/src/dgp/main.cc	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/main.cc	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
@@ -13,5 +13,5 @@
 #include "grammar.hh"
 #include "dgp0.hh"
-#include "common.h"
+#include "../common/common.h"
 
 #define MAXSEGMENTS 500
@@ -75,5 +75,5 @@
     char segtype[80];
 
-    seg_mnode[segcount] = processseg(line, args) ? mgraph.add_node(line) : -1;
+    seg_mnode[segcount] = process_seg(line, args) ? mgraph.add_node(line) : -1;
 
     segcount++;
Index: app/src/dgp/mgraph.cc
===================================================================
--- app/src/dgp/mgraph.cc	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/mgraph.cc	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
@@ -3,5 +3,4 @@
 #include "thesymbols.hh"
 #include "const.hh"
-#include "common.h"
 
 #include <stdio.h>
Index: app/src/dgp/mgraph.hh
===================================================================
--- app/src/dgp/mgraph.hh	(revision 0214596e4d70b25df913a24f19d50cb0f1b4a69f)
+++ app/src/dgp/mgraph.hh	(revision 28e9ae0020002f67cf91ba795ab44945930c0e98)
@@ -6,5 +6,5 @@
 #include "const.hh"
 #include "thesymbols.hh"
-#include "common.h"
+#include "../common/common.h"
 
 class MNode
