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