/* print out argument list of procedure */
static void
parglist (proc_list *proc, const char *addargtype)
{
  decl_list *dl;

  f_print(fout,"(");
  if (proc->arg_num < 2 && newstyle &&
      streq (proc->args.decls->decl.type, "void"))
    {
      /* 0 argument in new style:  do nothing */
    }
  else
    {
      for (dl = proc->args.decls; dl != NULL; dl = dl->next)
	{
	  ptype (dl->decl.prefix, dl->decl.type, 1);
	  if (!newstyle)
	    f_print (fout, "*");	/* old style passes by reference */

	  f_print (fout, ", ");
	}
    }
  if (mtflag)
    {
      ptype(proc->res_prefix, proc->res_type, 1);
      f_print(fout, "*, ");
    }

  f_print (fout, "%s);\n", addargtype);
}
예제 #2
0
파일: main.c 프로젝트: Nurb432/plan9front
static void
fsstat(Req *r)
{
	int rc;
	FInfo fi;
	Aux *a = r->fid->aux;

	if(ptype(r->fid->qid.path) == Proot)
		V2D(&r->d, r->fid->qid, "");
	else if(ptype(r->fid->qid.path) == Pinfo)
		dirgeninfo(pindex(r->fid->qid.path), &r->d);
	else if(ptype(r->fid->qid.path) == Pshare)
		V2D(&r->d, r->fid->qid, a->path +1);
	else{
		memset(&fi, 0, sizeof fi);
		if(Sess->caps & CAP_NT_SMBS)
			rc = T2queryall(Sess, a->sp, mapfile(a->path), &fi);
		else
			rc = T2querystandard(Sess, a->sp, mapfile(a->path), &fi);
		if(rc == -1){
			responderrstr(r);
			return;
		}
		I2D(&r->d, a->sp, a->path, &fi);
		if(Billtrog == 0)
			upd_names(Sess, a->sp, mapfile(a->path), &r->d);
	}
	respond(r, nil);
}
예제 #3
0
void print_pkt_derivedclass( definition *def )
{
  version_list *vers;
  proc_list *proc;
  int i;
  const char *ext;
  int vno ;
  decl_list *dl;

  if ( def->def_kind == DEF_PROGRAM ) {

    for ( vers = def->def.pr.versions; vers != NULL; vers = vers->next){

      for (proc = vers->procs; proc != NULL;proc = proc->next){

/* Argument packet */
      dl = proc->args.decls;

      fprintf(stderr,"QCDOC-RPC derived class: ");
      fprintf(stderr,"RPCPkt_%s\n",proc->proc_name);


      f_print (fout, "\n");
      f_print (fout, "class RPCPkt_%s : public RPCPkt {",proc->proc_name);

      /*Input and output arg/result*/
      f_print (fout, "\nprivate:\n");
      f_print (fout, "\t");
      ptype(dl->decl.prefix,dl->decl.type, 1);
      f_print (fout, "in;\n");
      f_print (fout, "\t");
      ptype(proc->res_prefix,proc->res_type, 1);
      f_print (fout,"out; \n");
      f_print (fout,"\tvirtual caddr_t Request(void) { return (caddr_t)&in; } ;\n");
      f_print (fout,"\tvirtual caddr_t Reply  (void) { return (caddr_t)&out; } ;\n\n");

      f_print (fout, "\npublic:\n");

      /*Constructor*/
      f_print (fout, "   RPCPkt_%s( %s *in) :\n",proc->proc_name,dl->decl.type);
      f_print (fout,"\n");
      f_print (fout, "\tRPCPkt( (xdrproc_t)xdr_");
      ptype(dl->decl.prefix,dl->decl.type, 1);
      f_print (fout,",\n\t\t(xdrproc_t)xdr_");
      ptype(proc->res_prefix,proc->res_type, 1);
      f_print (fout,",\n\t\t%s,%s,%s",proc->proc_name,vers->vers_name,def->def_name);
      f_print (fout,") {\n");
      f_print (fout,"       xdrencode((caddr_t)in);\n");
      f_print (fout,"    };\n");

      f_print (fout,"};\n");

      }

    }

   }
}
예제 #4
0
static void
printbody(proc_list *proc)
{
	decl_list      *l;
	bool_t          args2 = (proc->arg_num > 1);

	/* For new style with multiple arguments, need a structure in which
         * to stuff the arguments. */
	if (newstyle && args2) {
		f_print(fout, "\t%s", proc->args.argname);
		f_print(fout, " arg;\n");
	}
	f_print(fout, "\tstatic ");
	if (streq(proc->res_type, "void")) {
		f_print(fout, "char ");
	} else {
		ptype(proc->res_prefix, proc->res_type, 0);
	}
	f_print(fout, "%s;\n", RESULT);
	f_print(fout, "\n");
	f_print(fout, "\tmemset((char *)%s%s, 0, sizeof(%s));\n",
		ampr(proc->res_type), RESULT, RESULT);
	if (newstyle && !args2 && (streq(proc->args.decls->decl.type, "void"))) {
		/* newstyle, 0 arguments */
		f_print(fout,
			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_void, (caddr_t) NULL, "
			"(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
			proc->proc_name,
			stringfix(proc->res_type), ampr(proc->res_type), RESULT);

	} else if (newstyle && args2) {
		/* newstyle, multiple arguments:  stuff arguments into structure */
		for (l = proc->args.decls; l != NULL; l = l->next) {
			f_print(fout, "\targ.%s = %s;\n",
				l->decl.name, l->decl.name);
		}
		f_print(fout,
			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_%s, (caddr_t) &arg, "
			"(xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
			proc->proc_name, proc->args.argname,
			stringfix(proc->res_type), ampr(proc->res_type), RESULT);
	} else {		/* single argument, new or old style */
		f_print(fout,
			"\tif (clnt_call(clnt, %s, (xdrproc_t) xdr_%s, "
			"(caddr_t) %s%s, (xdrproc_t) xdr_%s, (caddr_t) %s%s, TIMEOUT) != RPC_SUCCESS) {\n",
			proc->proc_name,
			stringfix(proc->args.decls->decl.type),
			(newstyle ? "&" : ""),
			(newstyle ? proc->args.decls->decl.name : "argp"),
			stringfix(proc->res_type), ampr(proc->res_type), RESULT);
	}
	f_print(fout, "\t\treturn (NULL);\n");
	f_print(fout, "\t}\n");
	if (streq(proc->res_type, "void")) {
		f_print(fout, "\treturn ((void *)%s%s);\n",
			ampr(proc->res_type), RESULT);
	} else {
		f_print(fout, "\treturn (%s%s);\n", ampr(proc->res_type), RESULT);
	}
}
예제 #5
0
void InvokeMethod::on_comboMethods_activated(const QString &method)
{
    if (!activex)
	return;
    listParameters->clear();

    const QMetaObject *mo = activex->metaObject();
    const QMetaMethod slot = mo->method(mo->indexOfSlot(method.toLatin1()));
    QString signature = QString::fromLatin1(slot.signature());
    signature = signature.mid(signature.indexOf(QLatin1Char('(')) + 1);
    signature.truncate(signature.length()-1);

    QList<QByteArray> pnames = slot.parameterNames();
    QList<QByteArray> ptypes = slot.parameterTypes();

    for (int p = 0; p < ptypes.count(); ++p) {
	QString ptype(QString::fromLatin1(ptypes.at(p)));
	if (ptype.isEmpty())
	    continue;
	QString pname(QString::fromLatin1(pnames.at(p).constData()));
	if (pname.isEmpty())
	    pname = QString::fromLatin1("<unnamed %1>").arg(p);
	QTreeWidgetItem *item = new QTreeWidgetItem(listParameters);
        item->setText(0, pname);
        item->setText(1, ptype);
    }

    if (listParameters->topLevelItemCount())
	listParameters->setCurrentItem(listParameters->topLevelItem(0));
    editReturn->setText(QString::fromLatin1(slot.typeName()));
}
예제 #6
0
파일: main.c 프로젝트: Nurb432/plan9front
static void
fsopen(Req *r)
{
	int rc;
	FInfo fi;
	Aux *a = r->fid->aux;

	a->end = a->off = 0;
	a->cache = emalloc9p(max(Sess->mtu, MTU));

	if(ptype(r->fid->qid.path) == Pinfo){
		if(makeinfo(pindex(r->fid->qid.path)) != -1)
			respond(r, nil);
		else
			respond(r, "cannot generate info");
		return;
	}

	if(r->fid->qid.type & QTDIR){
		respond(r, nil);
		return;
	}

	if(Sess->caps & CAP_NT_SMBS)
		rc = ntcreateopen(a, mapfile(a->path), r->ifcall.mode, 0777,
			0, 0, &fi);
	else
		rc = smbcreateopen(a, mapfile(a->path), r->ifcall.mode, 0777,
			0, 0, &fi);
	if(rc == -1){
		responderrstr(r);
		return;
	}
	respond(r, nil);
}
예제 #7
0
파일: rpc_hout.c 프로젝트: libogdi/ogdi
void
pprocdef(proc_list *proc, version_list *vp, 
	 const char *addargtype, int server_p, int mode)
{




		ptype( proc->res_prefix, proc->res_type, 1 );
		f_print( fout, "* " );
		if( server_p )
			pvname_svc(proc->proc_name, vp->vers_num);
		else
			pvname(proc->proc_name, vp->vers_num);

		/*
		 * mode  0 == cplusplus, mode  1 = ANSI-C, mode 2 = old style C 
		 */
		if(mode == 0 || mode ==1) 
			parglist(proc, addargtype);
		else
			f_print(fout, "();\n");



}
예제 #8
0
파일: main.c 프로젝트: Nurb432/plan9front
static void
fsdestroyfid(Fid *f)
{
	Aux *a = f->aux;

	if(ptype(f->qid.path) == Pinfo)
		freeinfo(pindex(f->qid.path));
	f->omode = -1;
	if(! a)
		return;
	if(a->fh != -1)
		if(CIFSclose(Sess, a->sp, a->fh) == -1)
			fprint(2, "%s: close failed fh=%d %r\n", argv0, a->fh);
	if(a->sh != -1)
		if(CIFSfindclose2(Sess, a->sp, a->sh) == -1)
			fprint(2, "%s: findclose failed sh=%d %r\n",
				argv0, a->sh);
	if(a->path)
		free(a->path);
	if(a->cache)
		free(a->cache);

	if(a == Auxroot)
		Auxroot = a->next;
	a->prev->next = a->next;
	a->next->prev = a->prev;
	if(a->next == a->prev)
		Auxroot = nil;
	if(a)
		free(a);
}
예제 #9
0
static void
write_program(definition *def)
{
	version_list *vp;
	proc_list *proc;

	for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
		for (proc = vp->procs; proc != NULL; proc = proc->next) {
			f_print(fout, "\n");
			if (mtflag == 0) {
				ptype(proc->res_prefix, proc->res_type, 1);
				f_print(fout, "*\n");
				pvname(proc->proc_name, vp->vers_num);
				printarglist(proc, RESULT, "clnt", "CLIENT *");
			} else {
				f_print(fout, "enum clnt_stat \n");
				pvname(proc->proc_name, vp->vers_num);
				printarglist(proc, RESULT,  "clnt", "CLIENT *");

			}
			f_print(fout, "{\n");
			printbody(proc);

			f_print(fout, "}\n");
		}
	}
}
void
pprocdef (proc_list * proc, version_list * vp,
	  const char *addargtype, int server_p, int mode)
{
  if (mtflag)
    {/* Print MT style stubs */
      if (server_p)
	f_print (fout, "bool_t ");
      else
	f_print (fout, "enum clnt_stat ");
    }
  else
    {
      ptype (proc->res_prefix, proc->res_type, 1);
      f_print (fout, "* ");
    }
  if (server_p)
    pvname_svc (proc->proc_name, vp->vers_num);
  else
    pvname (proc->proc_name, vp->vers_num);

  /*
   * mode  1 = ANSI-C, mode 2 = K&R C
   */
  if (mode == 1)
    parglist (proc, addargtype);
  else
    f_print (fout, "();\n");
}
예제 #11
0
static void
printit (char *prefix, char *type)
{
  int len;
  int tabs;


  len = fprintf (fout, "\t(xdrproc_t) xdr_%s,", stringfix (type));
  /* account for leading tab expansion */
  len += TABSIZE - 1;
  /* round up to tabs required */
  tabs = (TABSTOP - len + TABSIZE - 1) / TABSIZE;
  f_print (fout, "%s", &tabstr[TABCOUNT - tabs]);

  if (streq (type, "void")) {
    f_print (fout, "0");
  }
  else {
    f_print (fout, "sizeof ( ");
    /* XXX: should "follow" be 1 ??? */
    ptype (prefix, type, 0);
    f_print (fout, ")");
  }
  f_print (fout, ",\n");
}
예제 #12
0
static void
printbody(proc_list *proc)
{
	f_print(fout, "\tstatic ");
	if (streq(proc->res_type, "void")) {
		f_print(fout, "char ");
	} else {
		ptype(proc->res_prefix, proc->res_type, 0);
	}
	f_print(fout, "res;\n");
	f_print(fout, "\n");
 	f_print(fout, "\tbzero((char *)%sres, sizeof(res));\n",
 		ampr(proc->res_type));
	f_print(fout,
		"\tif (clnt_call(clnt, %s, xdr_%s, argp, xdr_%s, %sres, TIMEOUT) != RPC_SUCCESS) {\n",
		proc->proc_name, stringfix(proc->arg_type),
		stringfix(proc->res_type), ampr(proc->res_type));
	f_print(fout, "\t\treturn (NULL);\n");
	f_print(fout, "\t}\n");
	if (streq(proc->res_type, "void")) {
		f_print(fout, "\treturn ((void *)%sres);\n",
			ampr(proc->res_type));
	} else {
		f_print(fout, "\treturn (%sres);\n", ampr(proc->res_type));
	}
}
예제 #13
0
void
printarglist(proc_list *proc, char *addargname, char *addargtype)
{

	decl_list      *l;

	if (!newstyle) {	/* old style: always pass arg by reference */
		if (Cflag) {	/* C++ style heading */
			f_print(fout, "(");
			ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
			f_print(fout, "*argp, %s%s)\n", addargtype, addargname);
		} else {
			f_print(fout, "(argp, %s)\n", addargname);
			f_print(fout, "\t");
			ptype(proc->args.decls->decl.prefix, proc->args.decls->decl.type, 1);
			f_print(fout, "*argp;\n");
		}
	} else if (streq(proc->args.decls->decl.type, "void")) {
		/* newstyle, 0 argument */
		if (Cflag)
			f_print(fout, "(%s%s)\n", addargtype, addargname);
		else
			f_print(fout, "(%s)\n", addargname);
	} else {
		/* new style, 1 or multiple arguments */
		if (!Cflag) {
			f_print(fout, "(");
			for (l = proc->args.decls; l != NULL; l = l->next)
				f_print(fout, "%s, ", l->decl.name);
			f_print(fout, "%s)\n", addargname);
			for (l = proc->args.decls; l != NULL; l = l->next) {
				pdeclaration(proc->args.argname, &l->decl, 1, ";\n");
			}
		} else {	/* C++ style header */
			f_print(fout, "(");
			for (l = proc->args.decls; l != NULL; l = l->next) {
				pdeclaration(proc->args.argname, &l->decl, 0, ", ");
			}
			f_print(fout, " %s%s)\n", addargtype, addargname);
		}
	}

	if (!Cflag)
		f_print(fout, "\t%s%s;\n", addargtype, addargname);
}
예제 #14
0
void
pprocdef(proc_list *proc, version_list *vp, const char *addargtype,
     int server_p)
{
	decl_list *dl;

	if (Mflag) {
		if (server_p)
			f_print(fout, "bool_t ");
		else
			f_print(fout, "enum clnt_stat ");
	} else {
		ptype(proc->res_prefix, proc->res_type, 1);
		f_print(fout, "*");
	}
	if (server_p)
		pvname_svc(proc->proc_name, vp->vers_num);
	else
		pvname(proc->proc_name, vp->vers_num);

	f_print(fout, "(");
	if (proc->arg_num < 2 && newstyle &&
	    streq(proc->args.decls->decl.type, "void")) {
		/* 0 argument in new style:  do nothing */
	} else {
		for (dl = proc->args.decls; dl != NULL; dl = dl->next) {
			ptype(dl->decl.prefix, dl->decl.type, 1);
			if (!newstyle)
				f_print(fout, "*");
			f_print(fout, ", ");
		}
	}
	if (Mflag) {
		if (streq(proc->res_type, "void"))
			f_print(fout, "char");
		else
			ptype(proc->res_prefix, proc->res_type, 0);
		if (!isvectordef(proc->res_type, REL_ALIAS))
			f_print(fout, "*");
		f_print(fout, ", ");
	}
	f_print(fout, "%s);\n", addargtype);
}
예제 #15
0
void
printarglist(proc_list *proc, const char *result, const char *addargname,
    const char *addargtype)
{

	decl_list *l;

	if (!newstyle) {
		/* old style: always pass argument by reference */
		f_print(fout, "(");
		ptype(proc->args.decls->decl.prefix,
		      proc->args.decls->decl.type, 1);

		if (mtflag) {/* Generate result field */
			f_print(fout, "*argp, ");
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, "*%s, %s%s)\n",
				result, addargtype, addargname);
		} else
			f_print(fout, "*argp, %s%s)\n", addargtype, addargname);
	} else if (streq(proc->args.decls->decl.type, "void")) {
		/* newstyle, 0 argument */
		if (mtflag) {
			f_print(fout, "(");
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, "*%s, %s%s)\n",
				result, addargtype, addargname);
		} else
			f_print(fout, "(%s%s)\n", addargtype, addargname);
	} else {
		/* new style, 1 or multiple arguments */
		f_print(fout, "(");
		for (l = proc->args.decls; l != NULL; l = l->next) {
			pdeclaration(proc->args.argname, &l->decl, 0, ", ");
		}
		if (mtflag) {
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, "*%s, ", result);

		}
		f_print(fout, "%s%s)\n", addargtype, addargname);
	}
}
예제 #16
0
CScriptVal ICmpFootprint::GetShape_wrapper()
{
	EShape shape;
	entity_pos_t size0, size1, height;
	GetShape(shape, size0, size1, height);

	JSContext* cx = GetSimContext().GetScriptInterface().GetContext();

	JSObject* obj = JS_NewObject(cx, NULL, NULL, NULL);
	if (!obj)
		return JSVAL_VOID;

	if (shape == CIRCLE)
	{
		JS::RootedValue ptype(cx);
		JS::RootedValue pradius(cx);
		JS::RootedValue pheight(cx);
		ScriptInterface::ToJSVal<std::string>(cx, ptype.get(), "circle");
		ScriptInterface::ToJSVal(cx, pradius.get(), size0);
		ScriptInterface::ToJSVal(cx, pheight.get(), height);
		JS_SetProperty(cx, obj, "type", ptype.address());
		JS_SetProperty(cx, obj, "radius", pradius.address());
		JS_SetProperty(cx, obj, "height", pheight.address());
	}
	else
	{
		JS::RootedValue ptype(cx);
		JS::RootedValue pwidth(cx);
		JS::RootedValue pdepth(cx);
		JS::RootedValue pheight(cx);
		ScriptInterface::ToJSVal<std::string>(cx, ptype.get(), "square");
		ScriptInterface::ToJSVal(cx, pwidth.get(), size0);
		ScriptInterface::ToJSVal(cx, pdepth.get(), size1);
		ScriptInterface::ToJSVal(cx, pheight.get(), height);
		JS_SetProperty(cx, obj, "type", ptype.address());
		JS_SetProperty(cx, obj, "width", pwidth.address());
		JS_SetProperty(cx, obj, "depth", pdepth.address());
		JS_SetProperty(cx, obj, "height", pheight.address());
	}

	return OBJECT_TO_JSVAL(obj);
}
예제 #17
0
const TypeData *TypeData::const_read_at (const Key &key) const {
  if (ptype() == tp_var) {
    return get_type (tp_var);
  }
  if (!structured()) {
    return get_type (tp_Unknown);
  }
  TypeData *res = at (key);
  if (res == NULL) {
    return get_type (tp_Unknown);
  }
  return res;
}
예제 #18
0
static void
write_program(definition * def)
{
    version_list *vp;
    proc_list *proc;

    for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
	for (proc = vp->procs; proc != NULL; proc = proc->next) {
	    f_print(fout, "\n");
	    ptype(proc->res_prefix, proc->res_type, 1);
	    f_print(fout, "*\n");
	    pvname(proc->proc_name, vp->vers_num);
	    f_print(fout, "(argp, clnt)\n");
	    f_print(fout, "\t");
	    ptype(proc->arg_prefix, proc->arg_type, 1);
	    f_print(fout, "*argp;\n");
	    f_print(fout, "\tCLIENT *clnt;\n");
	    f_print(fout, "{\n");
	    printbody(proc);
	    f_print(fout, "}\n\n");
	}
    }
}
예제 #19
0
const TypeData *TypeData::read_at (const Key &key) {
  if (ptype() == tp_var) {
    return get_type (tp_var);
  }
  if (!structured()) {
    return get_type (tp_Unknown);
  }
  TypeData *res = at_force (key);
  res->set_read_flag (true);

  if (key != Key::any_key()) {
    TypeData *any_value = at_force (Key::any_key());
    any_value->set_read_flag (true);
  }

  return res;
}
예제 #20
0
//**********************************************************************************************************************
vector<string> MakeFileCommand::setParameters(){
    try {
        CommandParameter ptype("type", "Multiple", "fastq-gz", "fastq", "", "", "","",false,false); parameters.push_back(ptype);
        CommandParameter pnumcols("numcols", "Multiple", "2-3", "3", "", "", "","",false,false, true); parameters.push_back(pnumcols);
        CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
        CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
        CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
        
        vector<string> myArray;
        for (int i = 0; i < parameters.size(); i++) {	myArray.push_back(parameters[i].name);		}
        return myArray;
    }
    catch(exception& e) {
        m->errorOut(e, "MakeFileCommand", "setParameters");
        exit(1);
    }
}
예제 #21
0
파일: htadd.c 프로젝트: acralfs/fricas
static void
add_new_pages(FILE *temp_db, FILE *new_file, char *addname, char *fullname)
{
    char type[15];
    int pos;
    int present_type;
    int pages = 0;
    struct stat fstats;

    stat(fullname, &fstats);
    fprintf(temp_db, "\t%s %d\n", addname, (int)fstats.st_mtime);
    cfile = new_file;
    init_scanner();
    while (get_token() != EOF) {
        if (Special(token.type)) {
            ptype(type, token.id);
            present_type = token.type;
            pos = keyword_fpos;
            get_token();
            if (token.type != Lbrace) {
                fprintf(stderr, "missing left brace after a page, macro or patch \
                         declaration\n");
                fprintf(stderr, "In the file %s on line %d\n", fullname, line_number);
                exit(-1);
            }
            get_token();
            if (present_type == Page && token.type != Word) {
                fprintf(stderr, "missing page name after \\begin{page}\n");
                fprintf(stderr, "In the file %s on line %d\n", fullname, line_number);
                exit(-1);
            }
            else if (present_type == Macro && token.type != Macro) {
                fprintf(stderr, "Expected a \\macro name after newcommand, got %s\n",
                        token.id);
                fprintf(stderr, "In the file %s on line %d\n", fullname, line_number);
                exit(-1);
            }
            else if (present_type == Patch && token.type != Word) {
                fprintf(stderr, "Missing patch name after a \\begin{patch}\n");
                fprintf(stderr, "In the file %s on line %d\n", fullname, line_number);
                exit(-1);
            }
            fprintf(temp_db, "\\%s %s %d %d\n", type,
                    token.id, pos, line_number);
            pages++;
        }
예제 #22
0
파일: main.c 프로젝트: Nurb432/plan9front
static void
fsread(Req *r)
{
	vlong n, m, got;
	Aux *a = r->fid->aux;
	char *buf = r->ofcall.data;
	vlong len = r->ifcall.count;
	vlong off = r->ifcall.offset;

	if(ptype(r->fid->qid.path) == Pinfo){
		r->ofcall.count = readinfo(pindex(r->fid->qid.path), buf, len,
			off);
		respond(r, nil);
		return;
	}

	if(r->fid->qid.type & QTDIR){
		dirread9p(r, dirgen, a);
		respond(r, nil);
		return;
	}

	got = 0;
	n = Sess->mtu -OVERHEAD;
	do{
		if(len - got < n)
			n = len - got;
		m = CIFSread(Sess, a->sp, a->fh, off + got, buf + got, n, len);
		if(m != -1)
			got += m;
	} while(got < len && m >= n);

	r->ofcall.count = got;
	if(m == -1)
		responderrstr(r);
	else
		respond(r, nil);
}
예제 #23
0
파일: qaxserver.cpp 프로젝트: RSATom/Qt
static QByteArray addDefaultArguments(const QByteArray &prototype, int numDefArgs)
{
    // nothing to do, or unsupported anyway
    if (!numDefArgs || prototype.contains("/**"))
        return prototype;

    QByteArray ptype(prototype);
    int in = -1;
    while (numDefArgs) {
        in = ptype.lastIndexOf(']', in);
        ptype.replace(in, 1, ",optional]");
        in = ptype.indexOf(' ', in) + 1;
        QByteArray type = ptype.mid(in, ptype.indexOf(' ', in) - in);
        if (type == "enum")
            type += ' ' + ptype.mid(in + 5, ptype.indexOf(' ', in + 5) - in - 5);
        if (type == "struct")
            type += ' ' + ptype.mid(in + 7, ptype.indexOf(' ', in + 7) - in - 7);
        ptype.replace(in, type.length(), QByteArray("VARIANT /*was: ") + type + "*/");
        --numDefArgs;
    }

    return ptype;
}
예제 #24
0
//------------------------------------------------------------------------------
void WBPageSetup::propagate_print_settings_to_grt_tree()
{
  std::string page_orientation_as_str;
  
  // Set orientation
  Gtk::PageOrientation page_orient = _page_setup->get_orientation();
  if ( page_orient == Gtk::PAGE_ORIENTATION_PORTRAIT )
    page_orientation_as_str = "portrait";
  else if ( page_orient == Gtk::PAGE_ORIENTATION_LANDSCAPE )
    page_orientation_as_str = "landscape";
  else
  {
    g_message("Unsupported page orientation. Setting page orientation to portrait");
    page_orientation_as_str = "portrait";
  }  
  _app_page_settings->orientation(page_orientation_as_str);
  
  // Set paper type
  Gtk::PaperSize   gtk_paper_size      = _page_setup->get_paper_size();
  app_PaperTypeRef paper_type          = _app_page_settings->paperType();

  const std::string paper_name = bec::replace_string(gtk_paper_size_get_name(gtk_paper_size.gobj()), "_", "-");

  grt::ListRef<app_PaperType> paper_types(grt::ListRef<app_PaperType>::cast_from(_app_page_settings.get_grt()->get("/wb/options/paperTypes")));
  
  app_PaperTypeRef ptype(app_PaperTypeRef::cast_from(grt::find_named_object_in_list(paper_types, paper_name)));

  _app_page_settings->marginBottom(gtk_paper_size.get_default_bottom_margin(Gtk::UNIT_MM));
  _app_page_settings->marginLeft(gtk_paper_size.get_default_left_margin(Gtk::UNIT_MM));
  _app_page_settings->marginRight(gtk_paper_size.get_default_right_margin(Gtk::UNIT_MM));
  _app_page_settings->marginTop(gtk_paper_size.get_default_top_margin(Gtk::UNIT_MM));

  if (ptype.is_valid())
    _app_page_settings->paperType(ptype);
  else
    g_warning("Unknown paper size selected in GTK Page Setup dialog: %s", paper_name.c_str());
}
예제 #25
0
static void
write_sample_client(const char *program_name, version_list *vp)
{
	proc_list *proc;
	int i;
	decl_list *l;

	f_print(fout, "\n\nvoid\n");
	pvname(program_name, vp->vers_num);
	f_print(fout, "(char *host)\n{\n");
	f_print(fout, "\tCLIENT *clnt;\n");

	i = 0;
	for (proc = vp->procs; proc != NULL; proc = proc->next) {
		f_print(fout, "\t");
		if (mtflag) {
			f_print(fout, "enum clnt_stat retval_%d;\n\t", ++i);
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, "result_%d;\n", i);
		} else {
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, " *result_%d;\n",++i);
		}
		/* print out declarations for arguments */
		if(proc->arg_num < 2 && !newstyle) {
			f_print(fout, "\t");
			if(!streq(proc->args.decls->decl.type, "void"))
				ptype(proc->args.decls->decl.prefix,
				      proc->args.decls->decl.type, 1);
			else
				f_print(fout, "char * "); /* cannot have "void" type */
			f_print(fout, " ");
			pvname(proc->proc_name, vp->vers_num);
			f_print(fout, "_arg;\n");
		} else if (!streq(proc->args.decls->decl.type, "void")) {
			for (l = proc->args.decls; l != NULL; l = l->next) {
				f_print(fout, "\t");
				ptype(l->decl.prefix, l->decl.type, 1);
				if (strcmp(l->decl.type,"string") == 1)
				    f_print(fout, " ");
				pvname(proc->proc_name, vp->vers_num);
				f_print(fout, "_%s;\n", l->decl.name);
			}
		}
	}

	/* generate creation of client handle */
	f_print(fout, "\n#ifndef\tDEBUG\n");
	f_print(fout, "\tclnt = clnt_create(host, %s, %s, \"%s\");\n",
		program_name, vp->vers_name, tirpcflag? "netpath" : "udp");
	f_print(fout, "\tif (clnt == (CLIENT *) NULL) {\n");
	f_print(fout, "\t\tclnt_pcreateerror(host);\n");
	f_print(fout, "\t\texit(1);\n\t}\n");
	f_print(fout, "#endif\t/* DEBUG */\n\n");

	/* generate calls to procedures */
	i = 0;
	for (proc = vp->procs; proc != NULL; proc = proc->next) {
		if (mtflag)
			f_print(fout, "\tretval_%d = ",++i);
		else
			f_print(fout, "\tresult_%d = ",++i);
		pvname(proc->proc_name, vp->vers_num);
		if (proc->arg_num < 2 && !newstyle) {
			f_print(fout, "(");
			if(streq(proc->args.decls->decl.type, "void"))
				/* cast to void * */
				f_print(fout, "(void *)");
			f_print(fout, "&");
			pvname(proc->proc_name, vp->vers_num);
			if (mtflag)
				f_print(fout, "_arg, &result_%d, clnt);\n",
					i);
			else
				f_print(fout, "_arg, clnt);\n");

		} else if (streq(proc->args.decls->decl.type, "void")) {
			if (mtflag)
				f_print(fout, "(&result_%d, clnt);\n", i);
			else
				f_print(fout, "(clnt);\n");
		}
		else {
			f_print(fout, "(");
			for (l = proc->args.decls;  l != NULL; l = l->next) {
				pvname(proc->proc_name, vp->vers_num);
				f_print(fout, "_%s, ", l->decl.name);
			}
			if (mtflag)
				f_print(fout, "&result_%d, ", i);
				
			f_print(fout, "clnt);\n");
		}
		if (mtflag) {
			f_print(fout, "\tif (retval_%d != RPC_SUCCESS) {\n", i);

		} else {
			f_print(fout, "\tif (result_%d == (", i);
			ptype(proc->res_prefix, proc->res_type, 1);
			f_print(fout, "*) NULL) {\n");
		}
		f_print(fout, "\t\tclnt_perror(clnt, \"call failed\");\n");
		f_print(fout, "\t}\n");
	}

	f_print(fout, "#ifndef\tDEBUG\n");
	f_print(fout, "\tclnt_destroy(clnt);\n");
	f_print(fout, "#endif\t	/* DEBUG */\n");
	f_print(fout, "}\n");
}
예제 #26
0
static void
return_type(proc_list *plist)
{
  ptype(plist->res_prefix, plist->res_type, 1);
}
예제 #27
0
void setnvols(struct data *d)
{
  int nvols;
  int listlen;
  char seqcon[6];

  /* To figure the number of volumes insist we must have the following */
  if ((ptype("np",&d->p) < 0) || (ptype("nv",&d->p) < 0)
    || (ptype("nv2",&d->p) < 0) || (ptype("pss",&d->p) < 0) 
    || (ptype("rcvrs",&d->p) < 0) || (ptype("seqcon",&d->p) < 0) 
    || (ptype("arraydim",&d->p) < 0) || (ptype("nf",&d->p) < 0)) {
    fprintf(stderr,"\n%s: %s()\n",__FILE__,__FUNCTION__);
    fprintf(stderr,"  The following values are required from a 'procpar':\n");
    fprintf(stderr,"  np nv nv2 pss rcvrs seqcon arraydim nf\n\n");
    fprintf(stderr," Aborting ...\n\n");
    fflush(stderr);
    exit(1);
  }

  if (d->seqmode>=IM4D) {  /* 4D or 3D CSI */
    if(ptype("nv3",&d->p) < 0)
      {
	fprintf(stderr,"  Invalid value for nv3 in procpar \n\n");
	fprintf(stderr,"  Aborting ...\n\n");
	fflush(stderr);
	exit(1);
      }
  }

  /* Sanity check */
  if ((d->np != d->fh.np) || ((int)*val("nf",&d->p) != d->fh.ntraces)) {
    fprintf(stderr,"\n%s: %s()\n",__FILE__,__FUNCTION__);
    fprintf(stderr,"  Check data file and procpar file are compatible\n");
    fprintf(stderr,"  procpar np = %d and nf = %d\n",d->np,(int)*val("nf",&d->p));
    fprintf(stderr,"  fid     np = %d and ntraces= %d\n",d->fh.np,d->fh.ntraces);
    fprintf(stderr,"  Aborting ...\n\n");
    fflush(stderr);
    exit(1);
  }

  /* Use value of arraydim to calculate the total number of volumes */
  nvols=(int)*val("arraydim",&d->p);
  /* Multiple echoes generate 'ne' volumes that are not arrayed */
  nvols*=d->ne;
  /* Multiple receivers generate 'nr' volumes included in arraydim */
  if (nvols%d->nr != 0) {
    fprintf(stderr,"\n%s: %s()\n",__FILE__,__FUNCTION__);
    fprintf(stderr,"  Problem calculating number of volumes\n");
    fprintf(stderr,"  Check data file and procpar file are compatible\n");
    fprintf(stderr,"  Aborting ...\n\n");
    fflush(stderr);
    exit(1);
  }
  nvols/=d->nr;

  /* Check for 'standard' slice and phase loops as these
     generate volumes included in arraydim */
  strcpy(seqcon,*sval("seqcon",&d->p));
  if (d->seqmode<IM3D) {  /* 2D */
    /* 'standard' slice loop has pss arrayed */
    if (seqcon[1] == 's') nvols/=d->ns;
  } else { /* 3D */
    /* 'compressed' slice loop generates 'ns' extra volumes  */
    if (seqcon[1] == 'c') nvols*=d->ns;
  }

  if (seqcon[2] == 's') /* 'standard' phase loop */
    nvols/=d->nseg;
  if (seqcon[3] == 's') /* 'standard' phase loop */
    nvols/=d->nv2;
  if (seqcon[4] == 's') /* volumes = slice encodes for 3D csi */
    nvols/=d->nv3;

  /* Allow for 2D LookLocker */
  if (im2DLL(d)) nvols*=nvals("ti",&d->p);

  /* special case for CSI and elliptical acquires NOT using DI's functions */
  if(imCSI(d) && nvols < 1)
  {
	  d->korder = TRUE;
	  nvols=(int)*val("arraydim",&d->p);
	  nvols*=d->ne;
	  nvols /= d->nr;
	  listlen = nvals("pelist",&d->p);
	  if(listlen > 0)
		  nvols /= listlen;

	 if(im4D(d))  // 3D csi
		  nvols *= d->nv3;  // for 3d nvols is number of slices
	  else
		  nvols *= d->ns;
  }
  else if(imCSI(d) && (im4D(d)))
  {
	  nvols *= d->nv3;
  }

  /* We now have the total number of volumes (nvols) according to
     the input parameter set */

  /* Set nvols */
  d->nvols=nvols;

  /* Set start volume and end volume */
  setstartendvol(d);

  /* Initialise volume counter */
  d->vol=d->startvol;

  /* Initialise block counter */
  d->block=0;

#ifdef DEBUG
  fprintf(stdout,"\n%s: %s()\n",__FILE__,__FUNCTION__);
  fprintf(stdout,"  Total number of volumes (d->nvols) = %d\n",d->nvols);
  fprintf(stdout,"  Start volume (d->startvol+1) = %d\n",d->startvol+1);
  fprintf(stdout,"  End volume (d->endvol) = %d\n",d->endvol);
  fflush(stdout);
#endif
}
예제 #28
0
void setseqmode(struct data *d)
{
  char seqcon[6];

  /* To figure the sequence mode insist we must have the following */
  if ((ptype("seqcon",&d->p) < 0) || (ptype("apptype",&d->p) < 0)) {
    fprintf(stderr,"\n%s: %s()\n",__FILE__,__FUNCTION__);
    fprintf(stderr,"  The 'procpar' must contain 'seqcon' and 'apptype' parameters:\n\n");
    fprintf(stderr,"  Aborting ...\n\n");
    fflush(stderr);
    exit(1);
  }

  /* Set sequence mode */
  d->seqmode=0;
  /* Standard cases */
  strcpy(seqcon,*sval("seqcon",&d->p));
  if ((seqcon[3] == 'n') && (seqcon[4] == 'n')) { /* standard 2D multislice */
    if ((seqcon[1] == 'c') && (seqcon[2] == 'c')) d->seqmode=IM2DCC;
    if ((seqcon[1] == 'c') && (seqcon[2] == 's')) d->seqmode=IM2DCS;
    if ((seqcon[1] == 's') && (seqcon[2] == 'c')) d->seqmode=IM2DSC;
    if ((seqcon[1] == 's') && (seqcon[2] == 's')) d->seqmode=IM2DSS;
  } else { /* standard 3D */
    if ((seqcon[2] == 'c') && (seqcon[3] == 'c')) d->seqmode=IM3DCC;
    if ((seqcon[2] == 'c') && (seqcon[3] == 's')) d->seqmode=IM3DCS;
    if ((seqcon[2] == 's') && (seqcon[3] == 'c')) d->seqmode=IM3DSC;
    if ((seqcon[2] == 's') && (seqcon[3] == 's')) d->seqmode=IM3DSS;
  }
  /* Special cases */
  if (spar(d,"apptype","im1Dglobal")) d->seqmode=IM1D;
  if (spar(d,"apptype","im1D")) d->seqmode=IM1D;
  if (spar(d,"apptype","im2Dfse")) {
    if ((seqcon[1] == 'c') && (seqcon[2] == 'c')) d->seqmode=IM2DCCFSE;
    if ((seqcon[1] == 'c') && (seqcon[2] == 's')) d->seqmode=IM2DCSFSE;
    if ((seqcon[1] == 's') && (seqcon[2] == 'c')) d->seqmode=IM2DSCFSE;
    if ((seqcon[1] == 's') && (seqcon[2] == 's')) d->seqmode=IM2DSSFSE;
  }
  if (spar(d,"apptype","im2Depi")) d->seqmode=IM2DEPI;
  if (im2DLL(d)) { /* 2D LookLocker */
    if ((seqcon[1] == 'c') && (seqcon[2] == 'c')) d->seqmode=IM2DCCLL;
    if ((seqcon[1] == 'c') && (seqcon[2] == 's')) d->seqmode=IM2DCSLL;
    if ((seqcon[1] == 's') && (seqcon[2] == 'c')) d->seqmode=IM2DSCLL;
    if ((seqcon[1] == 's') && (seqcon[2] == 's')) d->seqmode=IM2DSSLL;
  }
  if (spar(d,"apptype","im3Dfse")) {
    if (seqcon[3] == 'c') d->seqmode=IM3DCFSE;
    if (seqcon[3] == 's') d->seqmode=IM3DSFSE;
  }
  if (spar(d,"apptype","im2Dcsi")) {
	  if(seqcon[2] == 'c'){
		  if(seqcon[3] == 's')
			  d->seqmode=IM2DCSCSI;
		  if(seqcon[3] == 'c')
			  d->seqmode=IM2DCCCSI;
	  }
	  if(seqcon[2] == 's'){
		  if(seqcon[3] == 'c')
			  d->seqmode=IM2DSCCSI;
		  if(seqcon[3] == 's')
			  d->seqmode=IM2DSSCSI;
	  }
  }
  if (spar(d,"apptype","im3Dcsi")) {
	    if ((seqcon[2] == 'c') && (seqcon[3] == 'c')) {
					if (seqcon[4] == 's')d->seqmode=IM3DCCSCSI;
					else d->seqmode=IM3DCCCCSI;
	    }
	    if ((seqcon[2] == 'c') && (seqcon[3] == 's')) {
			if (seqcon[4] == 's')d->seqmode=IM3DCSSCSI;
			else d->seqmode=IM3DCSCCSI;
	    }
	    if ((seqcon[2] == 's') && (seqcon[3] == 'c')) {
			if (seqcon[4] == 's')d->seqmode=IM3DSCSCSI;
			else d->seqmode=IM3DSCCCSI;
	    }
	    if ((seqcon[2] == 's') && (seqcon[3] == 's'))  {
			if (seqcon[4] == 's')d->seqmode=IM3DSSSCSI;
			else d->seqmode=IM3DSSCCSI;
	    }
  }
#ifdef DEBUG
  fprintf(stdout,"\n%s: %s()\n",__FILE__,__FUNCTION__);
  fprintf(stdout,"  Sequence mode set to ");
  switch (d->seqmode) {
    case IM1D:      fprintf(stdout,"1D\n"); break;
    case IM2DCC:    fprintf(stdout,"2D with seqcon='*ccnn'\n"); break;
    case IM2DCS:    fprintf(stdout,"2D with seqcon='*csnn'\n"); break;
    case IM2DSC:    fprintf(stdout,"2D with seqcon='*scnn'\n"); break;
    case IM2DSS:    fprintf(stdout,"2D with seqcon='*ssnn'\n"); break;
    case IM2DCCFSE: fprintf(stdout,"2D with appmode='im2Dfse' and seqcon='nccnn'\n"); break;
    case IM2DCSFSE: fprintf(stdout,"2D with appmode='im2Dfse' and seqcon='ncsnn'\n"); break;
    case IM2DSCFSE: fprintf(stdout,"2D with appmode='im2Dfse' and seqcon='nscnn'\n"); break;
    case IM2DSSFSE: fprintf(stdout,"2D with appmode='im2Dfse' and seqcon='nssnn'\n"); break;
    case IM2DEPI:   fprintf(stdout,"2D with appmode='im2Depi'\n"); break;
    case IM2DCCLL:  fprintf(stdout,"2D with recontype='LookLocker' and seqcon='nccnn'\n"); break;
    case IM2DCSLL:  fprintf(stdout,"2D with recontype='LookLocker' and seqcon='ncsnn'\n"); break;
    case IM2DSCLL:  fprintf(stdout,"2D with recontype='LookLocker' and seqcon='nscnn'\n"); break;
    case IM2DSSLL:  fprintf(stdout,"2D with recontype='LookLocker' and seqcon='nssnn'\n"); break;
    case IM3DCC:    fprintf(stdout,"3D with seqcon='**ccn'\n"); break;
    case IM3DCS:    fprintf(stdout,"3D with seqcon='**csn'\n"); break;
    case IM3DSC:    fprintf(stdout,"3D with seqcon='**scn'\n"); break;
    case IM3DSS:    fprintf(stdout,"3D with seqcon='**ssn'\n"); break;
    case IM3DCFSE:  fprintf(stdout,"3D with appmode='im3Dfse' and seqcon='ncccn'\n"); break;
    case IM3DSFSE:  fprintf(stdout,"3D with appmode='im3Dfse' and seqcon='nccsn'\n"); break;
    default: break;
  }
  fflush(stdout);
#endif
}
예제 #29
0
static void
write_program(definition * def, char *storage)
{
    version_list *vp;
    proc_list *proc;
    int filled;

    for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) {
	f_print(fout, "\n");
	if (storage != NULL) {
	    f_print(fout, "%s ", storage);
	}
	f_print(fout, "void\n");
	pvname(def->def_name, vp->vers_num);
	f_print(fout, "(%s, %s)\n", RQSTP, TRANSP);
	f_print(fout, "	struct svc_req *%s;\n", RQSTP);
	f_print(fout, "	SVCXPRT *%s;\n", TRANSP);
	f_print(fout, "{\n");

	filled = 0;
	f_print(fout, "\tunion {\n");
	for (proc = vp->procs; proc != NULL; proc = proc->next) {
	    if (streq(proc->arg_type, "void")) {
		continue;
	    }
	    filled = 1;
	    f_print(fout, "\t\t");
	    ptype(proc->arg_prefix, proc->arg_type, 0);
	    pvname(proc->proc_name, vp->vers_num);
	    f_print(fout, "_arg;\n");
	}
	if (!filled) {
	    f_print(fout, "\t\tint fill;\n");
	}
	f_print(fout, "\t} %s;\n", ARG);
	f_print(fout, "\tchar *%s;\n", RESULT);
	f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT);
	f_print(fout, "\tchar *(*%s)();\n", ROUTINE);
	f_print(fout, "\n");
	f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP);

	if (!nullproc(vp->procs)) {
	    f_print(fout, "\tcase NULLPROC:\n");
	    f_print(fout, "\t\tsvc_sendreply(%s, xdr_void, NULL);\n", TRANSP);
	    f_print(fout, "\t\treturn;\n\n");
	}
	for (proc = vp->procs; proc != NULL; proc = proc->next) {
	    f_print(fout, "\tcase %s:\n", proc->proc_name);
	    f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG,
		    stringfix(proc->arg_type));
	    f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT,
		    stringfix(proc->res_type));
	    f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE);
	    pvname(proc->proc_name, vp->vers_num);
	    f_print(fout, ";\n");
	    f_print(fout, "\t\tbreak;\n\n");
	}
	f_print(fout, "\tdefault:\n");
	printerr("noproc", TRANSP);
	f_print(fout, "\t\treturn;\n");
	f_print(fout, "\t}\n");

	f_print(fout, "\tmemset(&%s, 0, sizeof(%s));\n", ARG, ARG);
	printif("getargs", TRANSP, "&", ARG);
	printerr("decode", TRANSP);
	f_print(fout, "\t\treturn;\n");
	f_print(fout, "\t}\n");

	f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG,
		RQSTP);
	f_print(fout,
		"\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n",
		RESULT, TRANSP, RESULT, RESULT);
	printerr("systemerr", TRANSP);
	f_print(fout, "\t}\n");

	printif("freeargs", TRANSP, "&", ARG);
	f_print(fout,
		"\t\tfprintf(stderr, \"unable to free arguments\\n\");\n");
	f_print(fout, "\t\texit(1);\n");
	f_print(fout, "\t}\n");

	f_print(fout, "}\n\n");
    }
}
예제 #30
0
static void extended_partition(struct gendisk *hd, kdev_t dev)
{
	struct buffer_head *bh;
	struct partition *p;
	unsigned long first_sector, first_size, this_sector, this_size;
	int mask = (1 << hd->minor_shift) - 1;
	int sector_size = sector_partition_scale(dev);
	int i;

	first_sector = hd->part[MINOR(dev)].start_sect;
	first_size = hd->part[MINOR(dev)].nr_sects;
	this_sector = first_sector;

	while (1) {
		if ((current_minor & mask) == 0)
			return;
		if (!(bh = bread(dev,0,get_ptable_blocksize(dev))))
			return;
	  /*
	   * This block is from a device that we're about to stomp on.
	   * So make sure nobody thinks this block is usable.
	   */
		bh->b_state = 0;

		if ((*(__u16 *) (bh->b_data+510)) != cpu_to_le16(MSDOS_LABEL_MAGIC))
			goto done;

		p = (struct partition *) (0x1BE + bh->b_data);

		this_size = hd->part[MINOR(dev)].nr_sects;

		/*
		 * Usually, the first entry is the real data partition,
		 * the 2nd entry is the next extended partition, or empty,
		 * and the 3rd and 4th entries are unused.
		 * However, DRDOS sometimes has the extended partition as
		 * the first entry (when the data partition is empty),
		 * and OS/2 seems to use all four entries.
		 */

		/* 
		 * First process the data partition(s)
		 */
		for (i=0; i<4; i++, p++) {
			if (!NR_SECTS(p) || is_extended_partition(p))
				continue;

			/* Check the 3rd and 4th entries -
			   these sometimes contain random garbage */
			if (i >= 2
				&& START_SECT(p) + NR_SECTS(p) > this_size
				&& (this_sector + START_SECT(p) < first_sector ||
				    this_sector + START_SECT(p) + NR_SECTS(p) >
				     first_sector + first_size))
				continue;

			add_gd_partition(hd, current_minor, this_sector+START_SECT(p)*sector_size,
				      NR_SECTS(p)*sector_size, ptype(SYS_IND(p)));
			hd->part[current_minor].sys_ind = SYS_IND(p);	// Hijack
			current_minor++;
			if ((current_minor & mask) == 0)
				goto done;
		}
		/*
		 * Next, process the (first) extended partition, if present.
		 * (So far, there seems to be no reason to make
		 *  extended_partition()  recursive and allow a tree
		 *  of extended partitions.)
		 * It should be a link to the next logical partition.
		 * Create a minor for this just long enough to get the next
		 * partition table.  The minor will be reused for the next
		 * data partition.
		 */
		p -= 4;
		for (i=0; i<4; i++, p++)
			if(NR_SECTS(p) && is_extended_partition(p))
				break;
		if (i == 4)
			goto done;	 /* nothing left to do */

		hd->part[current_minor].nr_sects = NR_SECTS(p) * sector_size; /* JSt */
		hd->part[current_minor].start_sect = first_sector + START_SECT(p) * sector_size;
		this_sector = first_sector + START_SECT(p) * sector_size;
		dev = MKDEV(hd->major, current_minor);
		brelse(bh);
	}
done:
	brelse(bh);
}