⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmdline.c

📁 波浪数值模拟
💻 C
字号:
/* * Copyright (c) 1998-2004 Falk Feddersen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <ctype.h>#include <glib.h>#include "cmdline.h"void help_report(){  fprintf(stderr,"funwaveC:  Bousinessq Wave and Circulation Model,  Version %d.%d.%d\n",            FUNWAVEC_MAJOR_VERSION_NUMBER, FUNWAVEC_MINOR_VERSION_NUMBER, FUNWAVEC_MICRO_VERSION_NUMBER);  fprintf(stderr,"(c) 1998-2004 Falk Feddersen\n");  fprintf(stderr,"Usage: shallow [OPTIONS] [init_file]\n");  fprintf(stderr,"Options:\n");  fprintf(stderr,"\t -v : verbose output\n");  fprintf(stderr,"\t -p : parse init file only and quit.\n");  fprintf(stderr,"\t -h : this help\n");  fprintf(stderr,"\t -g : GUI timing output\n");  fprintf(stderr,"\t -d <num>: diagnostic output, memory & numerical stability\n");  fprintf(stderr,"\n If no init_file is specified, 'default.init' is used as default.\n");  exit(-1);}cmdline* process_args2(int argc,char *argv[]){  int c,dd,index;  cmdline *A;  char *dval=NULL;  /* set getopt error reporting to nill */  opterr = 0;  /* initialize the cmdline A */  A = (cmdline * ) g_malloc(sizeof(cmdline));  A->init_file = g_string_new("default.init");  A->message = NULL;  A->verbose=0;  A->diagnostic=0;  A->help = 0;  A->gui = 0;  A->msg = 0;  A->parse = 0;  while ((c = getopt (argc, argv, "vhpgm:d:")) != -1)    switch (c)  {      case 'v':  A->verbose=1;  break;      case 'd': dval = optarg;        A->diagnostic=3;        if (dval) {          dd = atoi(dval);          switch (dd) {  	  case 1: A->diagnostic=1; break;	  case 2: A->diagnostic=2; break;	  case 3: A->diagnostic=3; break;	  default: fprintf(stderr,"Bad option to diagnostics flag -d\n"); exit(-1);	  }	}        break;      case 'h':  A->help=1; break;      case 'p':  A->parse=1; break;      case 'g':  A->gui=1; break;      case 'm':         if (optarg[0]=='-') {          fprintf (stderr,"** funwaveC: Bad argument to message option\n");          exit(-1);	}        A->msg=1;        A->message = g_string_new(optarg);        break;      case '?':        if (optopt=='d') {	  A->diagnostic=3;          break;	}        if (isprint (optopt))          fprintf (stderr, "Unknown option `-%c'.\n", optopt);        else          fprintf (stderr,"Unknown option character `\\x%x'.\n",optopt);      default:        exit (-1);      }  index = optind;  if (index<argc) {      A->init_file = g_string_assign(A->init_file,argv[index]);  //      strcpy(A->init_file,argv[index]);  }  if (A->help==1)     help_report();  return A;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -