Index: trunk/bibopa.sh
===================================================================
--- trunk/bibopa.sh	(revision 46)
+++ trunk/bibopa.sh	(revision 47)
@@ -55,7 +55,7 @@
 #
 # example :
-# $ ./bibopa.sh -i data/biball.txt -t raw
-# $ ./bibopa.sh -i data/mail2007-04-25T08:58:16Z.txt -t mailbody
-# $ ./bibopa.sh -i data/petitpolyfp.bib -t bibtex
+# $ ./bibopa.sh -p birefnemo -i data/biball.txt -t raw
+# $ ./bibopa.sh -p bibrefnemo -i data/mail2007-04-25T08:58:16Z.txt -t mailbody
+# $ ./bibopa.sh -p polyfortran -i data/petitpolyfp.bib -t bibtex -l fr
 #
 # see also mailtouser.sh
@@ -69,4 +69,7 @@
 # ++ option debug
 # $Id$
+# fplod 2008-03-12T16:11:07Z aedon.locean-ipsl.upmc.fr (Darwin)
+# add -p option (to overide bibrefnemo in file name and id)
+# add -l option by default en
 # fplod 2008-03-11T11:25:27Z aedon.locean-ipsl.upmc.fr (Darwin)
 # add bibtex entry (not finished)++
@@ -111,13 +114,16 @@
 fi
 #
-usage=" Usage : ${command} -i filein -t type"
-#
-minargcount=4
+usage=" Usage : ${command} -i filein -t type -p project -l lang"
+#
+# default
+lang=en
+#
+minargcount=6
 echo " narg ${#}"
 if [ ${#} -lt ${minargcount} ]
 then
-  echo "eee : not enought arguments"
-  echo "${usage}"
-  exit 1
+   echo "eee : not enought arguments"
+   echo "${usage}"
+   exit 1
 fi
 #
@@ -131,4 +137,12 @@
  -t) # type
   type=${2}
+  shift
+ ;;
+ -p)
+  project=${2}
+  shift
+ ;;
+ -l)
+  lang=${2}
   shift
  ;;
@@ -150,6 +164,6 @@
 if [ ! -f ${filein} ]
 then
-  echo "eee : ${filein} not found"
-  exit 1
+   echo "eee : ${filein} not found"
+   exit 1
 fi
 #
@@ -274,5 +288,5 @@
 <!DOCTYPE bibliography PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-<bibliography id="bibrefnemo" lang="en">
+<bibliography id="bib${project}ref" lang="${lang}">
 <bibliographyinfo>
 <date>$( date -u +"%Y-%m-%dT%H:%M:%SZ" )</date>
@@ -322,5 +336,4 @@
       # parsing bibtex line
       bibtex=1
-# ++
       # before the first ,
       tmp=${line%%,*}
@@ -329,6 +342,14 @@
       refid=${tmp#*{}
       # ++ test if refid already exist
-      auths=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(author * = *{\)\(.*\)\(}\)/\2/")
-      echo "auths $auths" # genre  Michael Metcalf and John Reid and Malcolm Cohen
+      # check if author field is there
+      echo ${endline} | grep -q "author"
+      hasauthor=${?}
+      if [ ${hasauthor} -eq 0 ] 
+      then 
+         auths=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(author * = *{\)\(.*\)\(}\)/\2/")
+         echo "auths $auths" # genre  Michael Metcalf and John Reid and Malcolm Cohen
+      else
+        echo "pas d'auteurs" # ++
+      fi
       endline=${endline#*,}
       title=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(title * = *{\)\(.*\)\(}\)/\2/")
@@ -338,13 +359,22 @@
       endline=${endline#*,}
       publisher=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(publisher * = *{\)\(.*\)\(}\)/\2/")
-
-     ## first author before the first and
-       first=${auths%%and*}
-     # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe
-     # firstsn=${first##* } . ok en interactif . pas ok en script
-       firstsn=$( echo ${first}  | awk '{print $2}')
-       echo "firstsn $firstsn"
-     # its firstname before the first " "
-       firstfn=${first%% *}
+      endline=${endline#*,}
+      edition=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(edition * = *{\)\(.*\)\(}\)/\2/")
+      endline=${endline#*,}
+      isbn=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(isbn * = *{\)\(.*\)\(}\)/\2/")
+      endline=${endline#*,}
+      pag=$( echo ${endline} | awk -F "," '{print $1}' | sed -e "s/\(page * = *{\)\(.*\)\(}\)/\2/")
+
+      if [ ${hasauthor} -eq 1 ] 
+      then 
+         ## first author before the first and
+         first=${auths%%and*}
+         # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe
+         # firstsn=${first##* } . ok en interactif . pas ok en script
+         firstsn=$( echo ${first}  | awk '{print $2}')
+         echo "firstsn $firstsn"
+         # its firstname before the first " "
+         firstfn=${first%% *}
+      fi
    fi
 
@@ -357,4 +387,8 @@
   ${orgline}
   -->
+EOF
+      if [ ${hasauthor} -eq 1 ] 
+      then 
+	  cat <<EOF >> ${fileou}
   <authorgroup>
     <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author>
@@ -378,5 +412,4 @@
      next=""
    fi
-   read a
   fi
   echo "previous ${previous}"
@@ -400,7 +433,4 @@
          # get the first next author; before the first "and"
          next=${next%%and *}
-  echo "next 2= ${next}"
-  read a
-
          # its surname after the last " "  ++ pas vrai double nom et pb blanc dans la syntaxe
          # nextsn=${next##* } . ok en interactif . pas ok en script
@@ -425,4 +455,5 @@
   done
   echo "  </authorgroup>"  >> ${fileou}
+  fi
 
 # end of the line ; after the first :
@@ -443,6 +474,23 @@
       echo "eee: Journal not found "
       echo "${endline}"
-      exit
-  fi
+      exit 1
+#+++ following lines are not yet validate
+      # it might be a book, a manual, a conference, etc. ++
+      echo "  <title>${title}</title>" >> ${fileou}
+      echo "  <biblioid class=\"isbn\">${isbn}</biblioid>" >> ${fileou}
+	  cat <<EOF >> ${fileou}
+  <biblioset relation="nojournal">
+    <title>${title}</title>
+    <pagenums>${pag}</pagenums>
+    <pubdate>${year}</pubdate>
+  </biblioset>
+EOF
+	  cat <<EOF >> ${fileou}
+</biblioentry>
+
+EOF
+  fi # end of if jfound empty (ie not an article)
+  if [ "${jfound}" != "" ]
+  then
 ## title
 # before the first :
@@ -519,5 +567,5 @@
 
 
-
+  fi # end of if jfound not empty
   l=$(( ${l} + 1 ))
 
@@ -551,6 +599,6 @@
 #
 echo " iii : you have a some new or modified bibliographic references in ${fileou} (biblioentry)"
-echo " iii : you can add them in bibrefnemo.xml" #++ filename path
-echo " iii : modify date in bibrefnemo.xml" #++ filename path
+echo " iii : you can add them in ${fileou}" #++ filename path
+echo " iii : modify date in ${fileou}" #++ filename path
 echo " iii : but please take care of id last part (after underscore) that may"
 echo " iii : be in conflict with existing ones" #++ pour s'affranchir de ce souci il faudrait donner en entrée complémentaire le fichier à compléter.
