/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/gvc/gvjobs.c

Go to the documentation of this file.
00001 /* $Id: gvjobs.c,v 1.29 2007/08/29 19:39:49 ellson Exp $ $Revision: 1.29 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 
00021 #include        "memory.h"
00022 #include        "types.h"
00023 #include        "gvplugin.h"
00024 #include        "gvcjob.h"
00025 #include        "gvcint.h"
00026 #include        "gvcproc.h"
00027 
00028 static GVJ_t *output_filename_job;
00029 static GVJ_t *output_langname_job;
00030 
00031 /*
00032  * -T and -o can be specified in any order relative to the other, e.g.
00033  *            -T -T -o -o
00034  *            -T -o -o -T
00035  * The first -T is paired with the first -o, the second with the second, and so on.
00036  *
00037  * If there are more -T than -o, then the last -o is repeated for the remaining -T
00038  * and vice-versa
00039  *
00040  * If there are no -T or -o then a single job is instantiated.
00041  *
00042  * If there is no -T on the first job, then "dot" is used.
00043  *
00044  * As many -R as are specified before a completed -T -o pair (according to the above rules)
00045  * are used as renderer-specific switches for just that one job.  -R must be restated for 
00046  * each job.
00047  */
00048 
00049 /* -o switches */
00050 void gvjobs_output_filename(GVC_t * gvc, char *name)
00051 {
00052     if (!gvc->jobs) {
00053         output_filename_job = gvc->job = gvc->jobs = zmalloc(sizeof(GVJ_t));
00054     } else {
00055         if (!output_filename_job) {
00056             output_filename_job = gvc->jobs;
00057         } else {
00058             if (!output_filename_job->next) {
00059                 output_filename_job->next = zmalloc(sizeof(GVJ_t));
00060             }
00061             output_filename_job = output_filename_job->next;
00062         }
00063     }
00064     output_filename_job->output_filename = name;
00065     output_filename_job->gvc = gvc;
00066 }
00067 
00068 /* -T switches */
00069 boolean gvjobs_output_langname(GVC_t * gvc, char *name)
00070 {
00071     if (!gvc->jobs) {
00072         output_langname_job = gvc->job = gvc->jobs = zmalloc(sizeof(GVJ_t));
00073     } else {
00074         if (!output_langname_job) {
00075             output_langname_job = gvc->jobs;
00076         } else {
00077             if (!output_langname_job->next) {
00078                 output_langname_job->next = zmalloc(sizeof(GVJ_t));
00079             }
00080             output_langname_job = output_langname_job->next;
00081         }
00082     }
00083     output_langname_job->output_langname = name;
00084     output_langname_job->gvc = gvc;
00085 
00086     /* load it now to check that it exists */
00087     if (gvplugin_load(gvc, API_device, name))
00088         return TRUE;
00089     return FALSE;
00090 }
00091 
00092 GVJ_t *gvjobs_first(GVC_t * gvc)
00093 {
00094     return (gvc->job = gvc->jobs);
00095 }
00096 
00097 GVJ_t *gvjobs_next(GVC_t * gvc)
00098 {
00099     GVJ_t *job = gvc->job->next;
00100 
00101     if (job) {
00102         /* if langname not specified, then repeat previous value */
00103         if (!job->output_langname)
00104             job->output_langname = gvc->job->output_langname;
00105         /* if filename not specified, then leave NULL to indicate stdout */
00106     }
00107     return (gvc->job = job);
00108 }
00109 
00110 gv_argvlist_t *gvNEWargvlist(void)
00111 {
00112     return (gv_argvlist_t*)zmalloc(sizeof(gv_argvlist_t));
00113 }
00114 
00115 void gv_argvlist_set_item(gv_argvlist_t *list, int index, char *item)
00116 {
00117     if (index >= list->alloc) {
00118         list->alloc = index + 10;
00119         list->argv = grealloc(list->argv, (list->alloc)*(sizeof(char*)));
00120     }
00121     list->argv[index] = item;
00122 }
00123 
00124 void gv_argvlist_reset(gv_argvlist_t *list)
00125 {
00126     if (list->argv)
00127         free(list->argv);
00128     list->argv = NULL;
00129     list->alloc = 0;
00130     list->argc = 0;
00131 }
00132 
00133 void gv_argvlist_free(gv_argvlist_t *list)
00134 {
00135     if (list->argv)
00136         free(list->argv);
00137     free(list);
00138 }
00139 
00140 void gvjobs_delete(GVC_t * gvc)
00141 {
00142     GVJ_t *job, *j;
00143 
00144     job = gvc->jobs;
00145     while ((j = job)) {
00146         job = job->next;
00147         gv_argvlist_reset(&(j->selected_obj_attributes));
00148         gv_argvlist_reset(&(j->selected_obj_type_name));
00149         if (j->active_tooltip)
00150             free(j->active_tooltip);
00151         if (j->selected_href)
00152             free(j->selected_href);
00153         free(j);
00154     }
00155     gvc->jobs = gvc->job = gvc->active_jobs = output_filename_job = output_langname_job =
00156         NULL;
00157     gvc->common.viewNum = 0;
00158 }

Generated on Mon Mar 31 19:03:26 2008 for Graphviz by  doxygen 1.5.1