1515
1616#include "gene_core.h"
1717#include "GDB.h"
18+ #include "ANO.h"
1819
19- static char * Usage = "[-vinfx] <source:path>[.1gdb|.gix] <target:path>[.1gdb|.gix]" ;
20+ static char * Usage = "[-vinfx] <source:path>[.1gdb|.gix|.1ano ] <target:path>[.1gdb|.gix|.1ano ]" ;
2021
2122int main (int argc , char * argv [])
2223{ int VERBOSE ;
@@ -78,8 +79,9 @@ int main(int argc, char *argv[])
7879
7980 { char * SPATH , * SROOT , * SEXTN ;
8081 char * TPATH , * TROOT , * TEXTN ;
81- int HAS_GDB , HAS_GIX ;
82+ int HAS_GDB , HAS_GIX , HAS_ANO ;
8283 GDB _gdb , * gdb = & _gdb ;
84+ ANO _ano , * ano = & _ano ;
8385 struct stat status ;
8486 char com [10 ];
8587 int a , yes ;
@@ -91,7 +93,7 @@ int main(int argc, char *argv[])
9193 else
9294 sprintf (com ,"mv" );
9395
94- HAS_GDB = HAS_GIX = 0 ;
96+ HAS_GDB = HAS_GIX = HAS_ANO = 0 ;
9597
9698 SPATH = argv [1 ];
9799 p = rindex (SPATH ,'/' );
@@ -140,6 +142,16 @@ int main(int argc, char *argv[])
140142 SROOT [strlen (SROOT )- 4 ] = '\0' ;
141143 }
142144
145+ input = fopen (Catenate (SPATH ,"/" ,SROOT ,".1ano" ),"r" );
146+ if (input != NULL )
147+ { fclose (input );
148+ HAS_ANO = 1 ;
149+ }
150+ else if (strcmp (SROOT + (strlen (SROOT )- 5 ),".1ano" ) == 0 )
151+ { HAS_ANO = 1 ;
152+ SROOT [strlen (SROOT )- 5 ] = '\0' ;
153+ }
154+
143155 TEXTN = ".1gdb" ;
144156 TPATH = argv [2 ];
145157 if (stat (TPATH ,& status ) == 0 && (status .st_mode & S_IFMT ) == S_IFDIR )
@@ -168,8 +180,8 @@ int main(int argc, char *argv[])
168180 command = Malloc (strlen (SPATH )+ strlen (SROOT )+ strlen (TPATH )+ strlen (TROOT )+ 100 ,
169181 "Allocating command buffer" );
170182
171- if (HAS_GIX + HAS_GDB == 0 )
172- fprintf (stderr ," There is no GDB or GIX with root %s/%s\n" ,SPATH ,SROOT );
183+ if (HAS_GIX + HAS_GDB + HAS_ANO == 0 )
184+ fprintf (stderr ," There is no GDB, GIX, or ANO with root %s/%s\n" ,SPATH ,SROOT );
173185
174186 if (HAS_GIX )
175187 { yes = 1 ;
@@ -255,7 +267,48 @@ int main(int argc, char *argv[])
255267 if (system (command ) != 0 ) goto sys_error ;
256268
257269 Write_GDB (gdb ,Catenate (TPATH ,"/" ,TROOT ,TEXTN ));
258- Close_GDB (gdb );
270+
271+ if (HAS_ANO )
272+ { yes = 1 ;
273+ if (ASK )
274+ { yes = 0 ;
275+ #ifdef MOVE
276+ printf ("Move %s/%s.1ano? " ,SPATH ,SROOT );
277+ #else
278+ printf ("Copy %s/%s.1ano? " ,SPATH ,SROOT );
279+ #endif
280+ fflush (stdout );
281+ while ((a = getc (stdin )) != '\n' )
282+ if (a == 'y' || a == 'Y' )
283+ yes = 1 ;
284+ else if (a == 'n' || a == 'N' )
285+ yes = 0 ;
286+ fflush (stdout );
287+ }
288+ if (yes )
289+ { if (!NO_OVER || stat (Catenate (TPATH ,"/" ,TROOT ,".1ano" ),& status ) != 0 )
290+ { if (VERBOSE )
291+ #ifdef MOVE
292+ { fprintf (stderr ," Moving %s/%s.1ano to %s/%s.1ano\n" ,
293+ SPATH ,SROOT ,TPATH ,TROOT );
294+ #else
295+ { fprintf (stderr ," Copying %s/%s.1ano to %s/%s.1ano\n" ,
296+ SPATH ,SROOT ,TPATH ,TROOT );
297+ #endif
298+ fflush (stderr );
299+ }
300+ Read_ANO (ano ,Catenate (SPATH ,"/" ,SROOT ,".1ano" ), gdb );
301+ #ifdef MOVE
302+ sprintf (command ,"rm %s/%s.1ano" ,SPATH ,SROOT );
303+ if (system (command ) != 0 ) goto sys_error ;
304+ #endif
305+
306+ Write_ANO (ano ,Catenate (TPATH ,"/" ,TROOT ,".1ano" ));
307+ Free_ANO (ano );
308+ }
309+ }
310+ }
311+ Close_GDB (gdb );
259312 }
260313 }
261314 }
0 commit comments