[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: CVS update: gnetlist.c



  User: ahvezda 
  Date: 07/02/10 11:11:17

  Modified:    .        gnetlist.c parsecmd.c
  Log:
  Applied patch by Tomaz Solc [ 1593644 ] gnetlist: use "-g help" to list available backends. Thanks!
  
  
  
  
  Revision  Changes    Path
  1.54      +64 -0     eda/geda/gaf/gnetlist/src/gnetlist.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: gnetlist.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gnetlist/src/gnetlist.c,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -b -r1.53 -r1.54
  --- gnetlist.c	7 Sep 2006 02:41:28 -0000	1.53
  +++ gnetlist.c	10 Feb 2007 16:11:17 -0000	1.54
  @@ -21,6 +21,13 @@
   
   #include <stdio.h>
   #include <sys/param.h>
  +#include <sys/types.h>
  +#ifdef HAVE_ERRNO_H
  +#include <errno.h>
  +#endif
  +#ifdef HAVE_DIRENT_H
  +#include <dirent.h>
  +#endif
   #ifdef HAVE_STRING_H
   #include <string.h>
   #endif
  @@ -28,6 +35,7 @@
   #include <unistd.h>
   #endif
   
  +
   #include <libgeda/libgeda.h>
   
   #include "../include/globals.h"
  @@ -37,6 +45,8 @@
   #include <dmalloc.h>
   #endif
   
  +#define BACKEND_LIST_COLS	3
  +
   void gnetlist_quit(void)
   {
       s_clib_free();
  @@ -48,6 +58,53 @@
       g_slist_free (backend_params);
   }
   
  +/** @brief Prints a list of all installed gnetlist backends to standard output.
  + *
  + * @param current Pointer to the toplevel struct.
  + */ 
  +void gnetlist_backends(TOPLEVEL *current)
  +{
  +	DIR *schemedir;
  +	struct dirent *entry;
  +	char *filename;
  +	int n;
  +
  +	schemedir=opendir(current->scheme_directory);
  +	if(schemedir==NULL) {
  +		fprintf(stderr, "\nERROR! Can't open directory %s: %s\n",
  +					current->scheme_directory,
  +					strerror(errno));
  +		return;
  +	}
  +
  +	printf("List of available backends:\n\n");
  +
  +	n=1;
  +	while(1) {
  +		entry=readdir(schemedir);
  +		if(entry==NULL) break;
  +
  +		filename=strdup(entry->d_name);
  +
  +		if(g_str_has_prefix(filename, "gnet-")&&
  +					g_str_has_suffix(filename, ".scm")) {
  +
  +			/* strip the suffix */
  +			filename[strlen(filename)-4]='\0';
  +			/* and skip the prefix */
  +			printf("%-25s", &filename[5]);
  +			if(n>=BACKEND_LIST_COLS) {
  +				printf("\n");
  +				n=0;
  +			}
  +			n++;
  +		}
  +
  +		free(filename);
  +	}
  +	printf("\n");
  +}
  +
   void main_prog(void *closure, int argc, char *argv[])
   {
       int i;
  @@ -139,6 +196,13 @@
   
       s_rename_init();
   
  +    if(guile_proc!=NULL) {
  +	if(!strcmp(guile_proc, "help")) {
  +		gnetlist_backends(pr_current);
  +		exit(0);
  +    	}
  +    }
  +
       i = argv_index;
       while (argv[i] != NULL) {
         gchar *filename; 
  
  
  
  1.25      +2 -1      eda/geda/gaf/gnetlist/src/parsecmd.c
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: parsecmd.c
  ===================================================================
  RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gnetlist/src/parsecmd.c,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -b -r1.24 -r1.25
  --- parsecmd.c	16 Jul 2006 02:11:31 -0000	1.24
  +++ parsecmd.c	10 Feb 2007 16:11:17 -0000	1.25
  @@ -72,7 +72,8 @@
       printf("  -l filename       Load scheme file before loading backend\n");
       printf("  -m filename       Load scheme file after loading backend,\n");
       printf("                    but still before executing procedure\n");
  -    printf("  -g proc           Scheme procedure to execute\n");
  +    printf("  -g proc           Scheme procedure to execute.\n");
  +    printf("                    Use '-g help' to list available backends.\n");
       printf("  -o filename       Output netlist filename\n");
       printf("  -c string         Execute string as a scheme script\n");
       printf("  -O option         Pass the given option to the backend\n");
  
  
  


_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs