示例#1
0
/* PROGRAM: dsmUserSetName - sets the user name associated w/current context
 *          
 *
 * RETURNS: 0 unqualified success
 *          DSM_S_FAILURE on failure
 */
dsmStatus_t
dsmUserSetName(
	dsmContext_t	*pcontext,	/* IN database context */
	dsmText_t	*pUsername,	/* IN username to set */
        QTEXT		*pq)		/* OUT the qptr to the filled string */
{
    dsmStatus_t	returnCode;
    dbcontext_t *pdbcontext = pcontext->pdbcontext;

    pdbcontext->inservice++; /* "post-pone" signal handling  while in DSM API */

    SETJMP_ERROREXIT(pcontext, returnCode) /* Ensure error exit address set */

    if ((returnCode = dsmThreadSafeEntry(pcontext)) != DSM_S_SUCCESS)
    {
        returnCode = dsmEntryProcessError(pcontext, returnCode,
                      (TEXT *)"dsmUserSetName");
        goto done;
    }

    returnCode = fillstr(pcontext, pUsername, pq);

    if (returnCode)
        returnCode = DSM_S_FAILURE;

done:
    dsmThreadSafeExit(pcontext);

    pdbcontext->inservice--;  /* re-allow signal handling */
    return(returnCode);

}  /* end dsmUserSetName */
示例#2
0
char *substr (char *target, char *source, int pos, int len) {
    if (target == NULL)
        return NULL;
    if (source == NULL)
        target[0] = '\0';
    else {
        strncpy(target, &source[pos], len);
        fillstr(target, len);
    }
    return target;
}
示例#3
0
文件: poutput.c 项目: cynthia/ocp-osx
void make_title(char *part)
{
	uint16_t sbuf[CONSOLE_MAX_X];
	char *verstr="opencp v" VERSION;

	fillstr(sbuf, 0, 0x30, 0, CONSOLE_MAX_X);
	writestring(sbuf, 2, 0x30, verstr, strlen(verstr));
	if (plScrWidth<100)
		writestring(sbuf, plScrWidth-58, 0x30, part, strlen(part));
	else
		writestring(sbuf, (plScrWidth-strlen(part))/2, 0x30, part, strlen(part));
	writestring(sbuf, plScrWidth-28, 0x30, "(c) '94-'10 Stian Skjelstad", 27);
	displaystrattr(0, 0, sbuf, plScrWidth);
}
示例#4
0
文件: report.c 项目: sdteffen/ooten
void  writeenergy()
/*
**-------------------------------------------------------------
**   Input:   none                                               
**   Output:  none                                               
**   Purpose: writes energy usage report to report file          
**-------------------------------------------------------------
*/
{
    int   j;
    float csum;
    char  s[MAXLINE+1];
    if (Npumps == 0) return;
    writeline(" ");
    writeheader(ENERHDR,0);
    csum = 0.0;
    for (j=1; j<=Npumps; j++)
    {
        csum += Pump[j].Energy[5];
        if (LineNum == (long)PageSize) writeheader(ENERHDR,1);
        sprintf(s,"%-8s  %6.2f %6.2f %9.2f %9.2f %9.2f %9.2f",
          Link[Pump[j].Link].ID,Pump[j].Energy[0],Pump[j].Energy[1],
          Pump[j].Energy[2],Pump[j].Energy[3],Pump[j].Energy[4],
          Pump[j].Energy[5]);
        writeline(s);
    }
    fillstr(s,'-',63);
    writeline(s);

/*** Updated 6/24/02 ***/
    sprintf(s,FMT74,"",Emax*Dcost);
    writeline(s);
    sprintf(s,FMT75,"",csum+Emax*Dcost);
/*** End of update ***/

    writeline(s);
    writeline(" ");
}                       /* End of writeenergy */
示例#5
0
文件: report.c 项目: sdteffen/ooten
void  writeheader(int type, int contin)
/*
**--------------------------------------------------------------
**   Input:   type   = table type                                
**            contin = table continuation flag                    
**   Output:  none                                                
**   Purpose: writes column headings for output report tables             
**--------------------------------------------------------------
*/
{
   char   s[MAXLINE+1],s1[MAXLINE+1],s2[MAXLINE+1],s3[MAXLINE+1];
   int    i,n;

   /* Move to next page if < 11 lines remain on current page. */
   if (Rptflag && LineNum+11 > (long)PageSize)
   {
      while (LineNum < (long)PageSize) writeline(" ");
   }
   writeline(" ");

   /* Hydraulic Status Table */
   if (type == STATHDR)
   {
      sprintf(s,FMT49);
      if (contin) strcat(s,t_CONTINUED);
      writeline(s);
      fillstr(s,'-',70);
      writeline(s);
   }

   /* Energy Usage Table */
   if (type == ENERHDR)
   {
      if (Unitsflag == SI) strcpy(s1,t_perM3);
      else                 strcpy(s1,t_perMGAL);
      sprintf(s,FMT71);
      if (contin) strcat(s,t_CONTINUED);
      writeline(s);
      fillstr(s,'-',63);
      writeline(s);
      sprintf(s,FMT72);
      writeline(s);
      sprintf(s,FMT73,s1);
      writeline(s);
      fillstr(s,'-',63);
      writeline(s);
   }

   /* Node Results Table */
   if (type == NODEHDR)
   {
      if      (Tstatflag == RANGE)  sprintf(s,FMT76,t_DIFFER);
      else if (Tstatflag != SERIES) sprintf(s,FMT76,TstatTxt[Tstatflag]);
      else if (Dur == 0)            sprintf(s,FMT77);
      else                          sprintf(s,FMT78,clocktime(Atime,Htime));
      if (contin) strcat(s,t_CONTINUED);
      writeline(s);
      n = 15;
      sprintf(s2,"%15s","");
      strcpy(s,t_NODEID);
      sprintf(s3,"%-15s",s);
      for (i=ELEV; i<QUALITY; i++) if (Field[i].Enabled == TRUE)
      {
        n += 10;
        sprintf(s,"%10s",Field[i].Name);
        strcat(s2,s);
        sprintf(s,"%10s",Field[i].Units);
        strcat(s3,s);
      }
      if (Field[QUALITY].Enabled == TRUE)
      {
        n += 10;
        sprintf(s,"%10s",ChemName);
        strcat(s2,s);
        sprintf(s,"%10s",ChemUnits);
        strcat(s3,s);
      }
      fillstr(s1,'-',n);
      writeline(s1);
      writeline(s2);
      writeline(s3);
      writeline(s1);
   }

   /* Link Results Table */
   if (type == LINKHDR)
   {
      if      (Tstatflag == RANGE)  sprintf(s,FMT79,t_DIFFER);
      else if (Tstatflag != SERIES) sprintf(s,FMT79,TstatTxt[Tstatflag]);
      else if (Dur == 0)            sprintf(s,FMT80);
      else                          sprintf(s,FMT81,clocktime(Atime,Htime));
      if (contin) strcat(s,t_CONTINUED);
      writeline(s);
      n = 15;
      sprintf(s2,"%15s","");
      strcpy(s,t_LINKID);
      sprintf(s3,"%-15s",s);
      for (i=LENGTH; i<=FRICTION; i++) if (Field[i].Enabled == TRUE)
      {
        n += 10;
        sprintf(s,"%10s",Field[i].Name);
        strcat(s2,s);
        sprintf(s,"%10s",Field[i].Units);
        strcat(s3,s);
      }
      fillstr(s1,'-',n);
      writeline(s1);
      writeline(s2);
      writeline(s3);
      writeline(s1);
  }
}                        /* End of writeheader */