Mail Archives: djgpp/1995/06/06/20:31:12

Xref: comp.os.msdos.djgpp:180
From: terra AT diku DOT dk (Morten Welinder)
Newsgroups: comp.os.msdos.djgpp
Subject: Code Standards
Date: 6 Jun 1995 20:31:04 GMT
Organization: Department of Computer Science, U of Copenhagen
Lines: 109
Sender: terra AT tyr DOT diku DOT dk
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

OK, some thoughts of mine.


Go32 is dead.  The majority of comments yours truthfully put
in there when I got tired of just seeing "case 0x40:".  If this
program was not dead it would IMHO need more commenting.

Having said that I want to add that there really are no or few
user-servicable parts inside.  If you don't have your i[345]86-
manual within reach (and know it almost be heart) don't mess
with it.


Better, but nor perfect.  Still, this is expert-only code.


Most of the routines are short.  Look at the current (for a few
more days) version of rename.c below.  What more comments do
you want?  (Forget about those in the docs and those that are
relevant to the entire libc, like what the heck is __tb?)


No comments needed here.


#include <libc/stubs.h>
#include <stdio.h>
#include <errno.h>
#include <dpmi.h>
#include <go32.h>

#include <libc/dosio.h>

rename(const char *old, const char *new)
  __dpmi_regs r;
  int olen    = strlen(old) + 1;
  int i;

  for (i=0; i<2; i++)
    r.h.ah = 0x56;
    _put_path2(new, olen);
    __dpmi_int(0x21, &r);
    if(r.x.flags & 1)
      if (r.h.ah == 5 && i == 0) /* access denied */
	remove(new);		 /* and try again */
	errno = __doserr_to_errno(;
	return -1;
  return 0;


@node rename, file system
@unnumberedsec @code{rename}
@subheading Syntax

#include <stdio.h>

int rename(const char *oldname, const char *newname);
@end example

@subheading Description

This function renames an existing file @var{oldname} to @var{newname}. 
Wildcards are not allowed, but the two file names may reflect different
subdirectories on the same file system.

@subheading Return Value

Zero on success, nonzero on failure.

@subheading Example

rename("some.doc", "some.sav");
@end example


- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019