Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for dead/diplomovka/xgrafix/src/xginitc.c between version 1.2 and 1.3

version 1.2, 2002/07/07 23:55:16 version 1.3, 2002/08/29 01:24:23
Line 8  extern int findlen(char *string);
Line 8  extern int findlen(char *string);
 extern void InitTclCommands(void);  extern void InitTclCommands(void);
 int xgDebug = FALSE;  int xgDebug = FALSE;
   
   /* A procedure called by XGInit to determine the rootlength of filenames */
 // Function int findlen(char *string) {{{  // Function int findlen(char *string) {{{
 int findlen(char *string)  int findlen(char *string)
 {  {
Line 27  int findlen(char *string)
Line 28  int findlen(char *string)
 // Function void PrintUsage() {{{  // Function void PrintUsage() {{{
 void PrintUsage(char *string)  void PrintUsage(char *string)
 {  {
           if (!string)
                   string = theCodeName;
         printf("Usage: %s [options]\n",string);          printf("Usage: %s [options]\n",string);
         printf("\t-d dumpfile[.dmp]:\n");          printf("\t-d dumpfile[.dmp]:\n");
         printf("\t\tSpecify dump file name. Default is output.dmp\n");          printf("\t\tSpecify dump file name. Default is output.dmp\n");
Line 52  void PrintUsage(char *string)
Line 55  void PrintUsage(char *string)
 // Function void PrintUnknownOption() {{{  // Function void PrintUnknownOption() {{{
 void PrintUnknownOption(char *string, char *string2)  void PrintUnknownOption(char *string, char *string2)
 {  {
         printf("Unknown option specified: %s\n",string);          printf("Unknown option specified: %s\n", string);
         PrintUsage(string2);          PrintUsage(string2);
 } // }}}  } // }}}
   
Line 63  void PrintNoArg(char *string, char *stri
Line 66  void PrintNoArg(char *string, char *stri
         PrintUsage(string2);          PrintUsage(string2);
 } // }}}  } // }}}
   
 // Function void XGInit() {{{  // Function void XGInit(int argc, char **argv, double *t) {{{
 void XGInit(int argc, char **argv, double *t)  void XGInit(int argc, char **argv, double *t)
 {  {
         int index, endianInt = 1;          int index, endianInt = 1;
Line 86  void XGInit(int argc, char **argv, doubl
Line 89  void XGInit(int argc, char **argv, doubl
         WasInputFileGiven = FALSE;          WasInputFileGiven = FALSE;
         theExitFlag = FALSE;          theExitFlag = FALSE;
         xgDebug = FALSE;          xgDebug = FALSE;
         ReqDisp[0] = 0;  
           theCodeName = NULL;
           ReqDisp = NULL;
   
         /***********************************/          /***********************************/
         /* Checking the endianness of host */          /* Checking the endianness of host */
Line 103  void XGInit(int argc, char **argv, doubl
Line 108  void XGInit(int argc, char **argv, doubl
         /*****************************************/          /*****************************************/
         /* Getting the code and input file names */          /* Getting the code and input file names */
   
         if (snprintf(theCodeName, theCodeName_LEN, "%s", argv[0]) == -1){          if ((theCodeName = strdup(argv[0])) == NULL) {
                 fprintf(stderr, "Warning: theCodeName truncated at %s:%d\n", __FILE__, __LINE__);                  fprintf(stderr, "Not enought memory!\n");
                   exit(1);
         }          }
         theInputFile[0]='\0';  
   
         /* Try to read the input parameters, i.e. -i -d -dp, etc. options */          /* Try to read the input parameters, i.e. -i -d -dp, etc. options */
         for (index=1; index < argc; index++) {          for (index=1; index < argc; index++) {
Line 127  void XGInit(int argc, char **argv, doubl
Line 132  void XGInit(int argc, char **argv, doubl
                                 }                                  }
                                 switch (argv[index][2]) {                                  switch (argv[index][2]) {
                                         case '\0':                                          case '\0':
                                                 strcpy(theDumpFile, argv[++index]);                                                  if ((theDumpFile = strdup(argv[++index])) == NULL) {
                                                           fprintf(stderr, "Not enought memory!\n");
                                                           exit(1);
                                                   }
                                                 if (access(theDumpFile,F_OK)) {                                                  if (access(theDumpFile,F_OK)) {
                                                         strcat(theDumpFile, theDumpExtension);                                                          strcat(theDumpFile, theDumpExtension);
                                                         if (access(theDumpFile,F_OK)) {                                                          if (access(theDumpFile,F_OK)) {
                                                                 printf("Error: %s does not exist\n",theDumpFile);                                                                  printf("Error: file '%s' does not exist\n",theDumpFile);
                                                                 exit(1);                                                                  exit(1);
                                                         }                                                          }
                                                 }                                                  }
Line 144  void XGInit(int argc, char **argv, doubl
Line 152  void XGInit(int argc, char **argv, doubl
                                                 printf("Dumping every %d steps\n",theDumpPeriod);                                                  printf("Dumping every %d steps\n",theDumpPeriod);
                                                 break;                                                  break;
                                         case 'i':                                          case 'i':
                                                 strcpy(ReqDisp, argv[++index]);                                                  if ((ReqDisp = strdup(argv[++index])) == NULL) {
                                                 printf("Setting display to %s.\n",ReqDisp);                                                          fprintf(stderr, "Not enought memory!\n");
                                                           exit(1);
                                                   }
                                                   printf("Setting display to %s.\n", ReqDisp);
                                                 break;                                                  break;
                                 }                                  }
                                 break;                                  break;
Line 171  void XGInit(int argc, char **argv, doubl
Line 182  void XGInit(int argc, char **argv, doubl
                                         PrintNoArg(argv[index],argv[0]);                                          PrintNoArg(argv[index],argv[0]);
                                         exit(1);                                          exit(1);
                                 }                                  }
                                 strcpy(theInputFile, argv[++index]);                                  if ((theInputFile = strdup(argv[++index])) == NULL) {
                                           fprintf(stderr, "Not enought memory!\n");
                                           exit(1);
                                   }
   
                                 if (access(theInputFile,F_OK)) {                                  if (access(theInputFile,F_OK)) {
                                         strcat(theInputFile,theInputExtension);                                          strcat(theInputFile,theInputExtension);
Line 203  void XGInit(int argc, char **argv, doubl
Line 217  void XGInit(int argc, char **argv, doubl
                                         PrintNoArg(argv[index],argv[0]);                                          PrintNoArg(argv[index],argv[0]);
                                         exit(1);                                          exit(1);
                                 }                                  }
                                 strcpy(theEPSFile, argv[++index]);                                  if ((theEPSFile = strdup(argv[++index])) == NULL) {
                                           fprintf(stderr, "Not enought memory!\n");
                                           exit(1);
                                   }
                                 printf("Postscript file is '%s'\n",theEPSFile);                                  printf("Postscript file is '%s'\n",theEPSFile);
                                 break;                                  break;
                         case 's':                          case 's':
Line 247  void XGInit(int argc, char **argv, doubl
Line 264  void XGInit(int argc, char **argv, doubl
         /* End of trying to read parameters */          /* End of trying to read parameters */
   
         if (!WasInputFileGiven) {          if (!WasInputFileGiven) {
                 strcpy(theEPSFile,theDefaultEPSFile);                  theEPSFile  = strdup(theDefaultEPSFile);
                 strcpy(theDumpFile,theDefaultDumpFile);                  theDumpFile = strdup(theDefaultDumpFile);
                   if (theEPSFile == NULL || theDumpFile == NULL) {
                           fprintf(stderr, "Not enought memory!\n");
                           exit(1);
                   }
         }          }
         else if (!WasDumpFileGiven) {          else if (!WasDumpFileGiven) {
                 strncpy(theEPSFile,theInputFile,findlen(theInputFile));                  theEPSFile = (char *) malloc(
                 strncpy(theDumpFile,theInputFile,findlen(theInputFile));                                  (strlen(theInputFile) + strlen(theEPSExtension)) * sizeof(char));
                 strcat(theEPSFile,theEPSExtension);                  theDumpFile = (char *) malloc(
                 strcat(theDumpFile,theDumpExtension);                                  (strlen(theInputFile) + strlen(theEPSExtension)) * sizeof(char));
                   if (theEPSFile == NULL || theDumpFile == NULL) {
                           fprintf(stderr, "Not enought memory!\n");
                           exit(1);
                   }
                   strcpy(theEPSFile, theInputFile);
                   strcpy(theDumpFile, theInputFile);
                   strcat(theEPSFile, theEPSExtension);
                   strcat(theDumpFile, theDumpExtension);
         }          }
         else {          else {
                 strncpy(theEPSFile,theInputFile,findlen(theInputFile));                  theEPSFile = (char *) malloc(
                 strcat(theEPSFile,theEPSExtension);                                  (findlen(theInputFile) + strlen(theEPSExtension)) * sizeof(char));
                   strncpy(theEPSFile, theInputFile, findlen(theInputFile));
                   strcat(theEPSFile, theEPSExtension);
         }          }
   
         /*********************************/          /*********************************/
Line 292  void XGInitX(void) {
Line 323  void XGInitX(void) {
         /***********************/          /***********************/
         /* Remaining XLib code */          /* Remaining XLib code */
   
         if (ReqDisp[0] == 0) {          if (ReqDisp == NULL)
                 strcpy(ReqDisp, XDisplayName(NULL));                  ReqDisp = strdup(XDisplayName(NULL));
         }  
   
         theDisplay = XOpenDisplay(ReqDisp);          theDisplay = XOpenDisplay(ReqDisp);
         if (theDisplay == NULL) {          if (theDisplay == NULL) {
Line 512  void XGInitX(void) {
Line 542  void XGInitX(void) {
 // Function void XGInitTclTk(void) { {{{  // Function void XGInitTclTk(void) { {{{
 void XGInitTclTk(void)  void XGInitTclTk(void)
 {  {
         char *str, str2[200];          char *str, *str2;
         /************************************/          /************************************/
         /* Initializing the Tcl/Tk stuff    */          /* Initializing the Tcl/Tk stuff    */
   
         interp = Tcl_CreateInterp();          interp = Tcl_CreateInterp();
         Tcl_Init(interp);          Tcl_Init(interp);
         if (snprintf(str2, 200, "-display %s", ReqDisp) == -1) {          str2 = (char *) malloc((strlen(ReqDisp) + strlen("-display ")) * sizeof(char));
                 fprintf(stderr, "Warning: display truncated at %s:%d\n", __FILE__, __LINE__);          if (str2 != NULL)
                   sprintf(str2, "-display %s", ReqDisp);
           else {
                   fprintf(stderr, "Not enought memory!\n");
                   exit(1);
         }          }
         Tcl_SetVar(interp, "argv", str2, 0);          Tcl_SetVar(interp, "argv", str2, 0);
           free(str2);
         Tk_Init(interp);          Tk_Init(interp);
         mainWindow = Tk_MainWindow(interp);          mainWindow = Tk_MainWindow(interp);
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top